媒体播放器播放列表框中的所有文件如何?

我有一个列表框,其中包含所有必须播放的媒体文件。 如何让媒体播放器一个接一个播放? 这个代码播放1首歌曲,但是foreach应该播放所有文件,但是我感到这是因为它不会等到媒体结束。这个代码:

Listbox = listBox3

listBox3Dict[s] =列表框中所有文件的string

  Dictionary<string, string> listBox3Dict = new Dictionary<string, string>(); > private bool listbox3job() > { > AxWMPLib.AxWindowsMediaPlayer axWmp = wfh.Child as AxWMPLib.AxWindowsMediaPlayer; > { > foreach (var selected in listBox3.Items) > { > string s = selected.ToString(); > > if (listBox3Dict.ContainsKey(s)) > { WMPLib.IWMPPlaylist playlist = axWindowsMediaPlayer1.newPlaylist("myPlaylist", string.Empty); // you can add songs to url on for loop WMPLib.IWMPMedia temp = this.axWindowsMediaPlayer1.newMedia(listBox3Dict[s]); //Load media from URL. playlist.appendItem(temp); //Add song to playlist. // after you add all songs set the new playlist this.axWindowsMediaPlayer1.settings.autoStart = true; //not necessary this.axWindowsMediaPlayer1.currentPlaylist = playlist; //Set media player to use the playlist. > } > } > > return true; > } > return false; > } 

你可以做的是创建播放列表,并开始播放列表

 private bool listbox3job() { AxWMPLib.AxWindowsMediaPlayer axWmp = wfh.Child as AxWMPLib.AxWindowsMediaPlayer; WMPLib.IWMPPlaylist playlist = axWmp.newPlaylist("myPlaylist", string.Empty); foreach (var selected in listBox1.Items) { string s = selected.ToString(); if (listBox3Dict.ContainsKey(s)) { WMPLib.IWMPMedia temp = axWmp.newMedia(listBox3Dict[s]); //Load media from URL. playlist.appendItem(temp); //Add song to playlist. } } axWmp.settings.autoStart = true; //not necessary axWmp.currentPlaylist = playlist; //Set media player to use the playlist. return true; } 

http://www.timwylie.com/playlist.html

早些时候,我正在一个列表中处理一组语音文件。 我使用了PlayStateChange事件。 从此事件中,您可以找到MediaEnded状态,您可以在其中将播放文件重新分配到列表中的下一个项目。