Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm working on a project that uses WMPLib.WindowsMediaPlayer and allows the user to select an .mp3 or .wav file for play.

How do I go about setting the duration of play? I'd like to for the file to play for 5 seconds and that's it. How do I go about this?

Thanks in advance,
-DA

WMPLib.WindowsMediaPlayer wmp = new WMPLib.WindowsMediaPlayer();
wmp.URL = @"C:\Music\mySong.mp3";
wmp.controls.play();
Posted

1 solution

well, my first approach would be to create a timer for a repeat duration of 5 seconds, and then in the timer.Tick() event, call
C#
wmp.controls.Stop(); myTimer.Stop();
.
You can consult here for timers: http://msdn.microsoft.com/en-us/library/system.timers.timer.aspx[^]
You can also consult here for WindowsMediaPlayer controls: http://msdn.microsoft.com/en-us/library/windows/desktop/dd562662(v=vs.85).aspx[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900