My program uses windows media player in C# so that I can play almost any sound file. Some sounds need to play in succession, one after the other. The only way I could think to do that was with playlists, but I can't figure out how to clear the playlist between calls to the windows media player.
How can I play sounds, one after the other, in windows media player, without running into problems from previous playlists?
Thanks
My code:
WMPLib.IWMPPlaylist playlist = axWindowsMediaPlayer1.playlistCollection.newPlaylist("myplaylist");
WMPLib.IWMPMedia media;
foreach (string question in questionURL)
{
media = axWindowsMediaPlayer1.newMedia(question);
playlist.appendItem(media);
media = axWindowsMediaPlayer1.newMedia(answer);
playlist.appendItem(media);
axWindowsMediaPlayer1.currentPlaylist = playlist;
axWindowsMediaPlayer1.Ctlcontrols.play();
axWindowsMediaPlayer1.playlistCollection.remove(playlist);\\one of my many failed attempts at clearing the playlist. It doesn't throw an error, it doesn't clear the playlist either.
}
See PlaylistCollection.remove().
So I think you could remove the playlist with:
axWindowsMediaPlayer1.playlistCollection.remove("myplaylist");
Then simply create it again:
playlist = axWindowsMediaPlayer1.playlistCollection.newPlaylist("myplaylist");