![](/img/trans.png)
[英]How to play all songs from List<Song> with Windows Media Player?
[英]How to play a particular item from media play list?
我在Windows窗體應用程序中使用Windows Media Player。 我的播放列表中有10個媒體項目。 foo,foo1,foo2,foo3 ....
現在我的播放列表正在播放,請說foo1。 現在在按鈕上單擊我要播放項目foo6。 我該怎么玩? 即我該如何更改我當前的游戲項目foo6?
如果不清楚,請發表評論,我將添加更多信息。
編輯:以下是用於創建新播放列表的代碼。
WindowsMediaPlayerClass wmp = new WindowsMediaPlayerClass();
playlist = WMPLeft.playlistCollection.newPlaylist("myplaylist1");
for (int i = 0; i < FOO.Length; i++)
{
media = WMPLeft.newMedia(FOO[i]);
playlist.appendItem(media);
}
我想要的是這樣的
WMPLeft.playlist.Item(3).play();
錯了 但這是我想要的代碼。
經過大量研究,我發現了此msdn鏈接,該鏈接顯示了如何執行我想要的操作。
// Declare a variable to hold the position of the media item
// in the current playlist. An arbitrary value is supplied here.
int index = 3;
// Get the media item at the fourth position in the current playlist.
WMPLib.IWMPMedia media = player.currentPlaylist.get_Item(index);
// Play the media item.
player.Ctlcontrols.playItem(media);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.