我的程序在C#中使用Windows媒体播放器,这样我几乎可以播放任何声音文件。有些声音需要连续播放,一个接一个。我能想到的唯一方法是使用播放列表,但我无法弄清楚如何在调用Windows媒体播放器之间清除播放列表。
如何在Windows媒体播放器中一个接一个地播放声音,而不会遇到以前播放列表中的问题?
由于
我的代码:
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.
}
答案 0 :(得分:1)
请参阅PlaylistCollection.remove()。
所以我认为您可以删除播放列表:
axWindowsMediaPlayer1.playlistCollection.remove("myplaylist");
然后再次创建它:
playlist = axWindowsMediaPlayer1.playlistCollection.newPlaylist("myplaylist");