A
antidinosaur
Guest
I used the MediaPlayer library in my code to play a list of musics. I want the sequence to be random. However, the shuffle function did not give me any randomness. Here is my code snippet:
public partial class FrmGameOption : Form
{
public WMPLib.WindowsMediaPlayer wplayer = new WMPLib.WindowsMediaPlayer();
wplayer.controls.stop();
System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(
@"music\map\");
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.settings.setMode("shuffle", true);
wplayer.settings.setMode("Loop", true);
wplayer.controls.play();
}
Continue reading...
public partial class FrmGameOption : Form
{
public WMPLib.WindowsMediaPlayer wplayer = new WMPLib.WindowsMediaPlayer();
wplayer.controls.stop();
System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(
@"music\map\");
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.settings.setMode("shuffle", true);
wplayer.settings.setMode("Loop", true);
wplayer.controls.play();
}
Continue reading...