我无法在下面的代码中添加随机播放。有人可以帮帮我吗?我只需要在playlist
添加项目之后随机随机播放这些项目。
WMPLib.WindowsMediaPlayer wplayer = new WMPLib.WindowsMediaPlayer();
System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(
@"C:\Users\Callum\Music\ItunesMusic\");
System.IO.FileInfo[] files = dir.GetFiles();
WMPLib.IWMPPlaylist playlist = wplayer.playlistCollection.newPlaylist("myplaylist");
foreach (System.IO.FileInfo file in files)
{
WMPLib.IWMPMedia media;
media = wplayer.newMedia(file.FullName);
playlist.appendItem(media);
}
wplayer.currentPlaylist = playlist;
wplayer.controls.play();
答案 0 :(得分:1)
在播放播放列表之前,您需要告诉播放器进行随机播放:
wplayer.currentPlaylist = playlist;
wplayer.settings.setMode("shuffle", true); // this does the trick
wplayer.controls.play();