这是我的媒体播放器播放列表代码设置,使用windows media player库。
现在我要做的是创建媒体播放器并给它一个播放列表。
WindowsMediaPlayer wmPlayer = new WindowsMediaPlayer();
wmPlayer.PlayStateChange += Player_PlayStateChange;
IWMPPlaylist playlist = wmPlayer.playlistCollection.newPlaylist("All");
wmPlayer.currentPlaylist = playlist;然后我将歌曲添加到播放列表中
IWMPMedia media = _wmPlayer.newMedia(path); //path to mp3 is given via method parameter
wmPlayer.currentPlaylist.appendItem(media);这使我可以轻松地执行基本的音乐播放器控制,而不需要手动转到下一首/上一首歌曲。
wmPlayer.controls.play();
wmPlayer.controls.pause();
wmPlayer.controls.next();
wmPlayer.controls.previous();我想要做的是获取播放列表(wmPlayer.currentPlaylist)中正在播放/暂停的当前媒体的索引。这有可能吗?
我知道您可以通过wmPlayer.currentPlaylist.Item[index];获取特定索引的歌曲,但我无法找到如何获取当前歌曲的索引。
任何帮助都是非常感谢的。谢谢。
发布于 2016-06-06 08:26:15
希望下面的代码对您有所帮助。
int index;
for (int i = 0; i < playlist.count - 1; i++)
{
if (wmPlayer.currentMedia.isIdentical[playlist.Item[i]])
{
index = i;
break;
}
}https://stackoverflow.com/questions/36047124
复制相似问题