I have this function:
public static void Play(string FileName, bool Async = false)
{
System.Windows.Media.MediaPlayer mp = new System.Windows.Med
You need to wait for the current file to finish playing before calling Play
on the next.
This you do by listening for the MediaEnded event.
You'll need to listen for the event:
mp.MediaEnded += MediaEndedEventHandler;
However, you'll need to make the MediaPlayer
object a static too so you only ever have one of them. Make sure you only add this handler the once. Then in the handler issue a new event to start playing the next file.
What you are implementing is a playlist. So you'll add the files to the playlist and then you'll need to keep a track of your current position in the playlist.