到目前为止,我已经附加了我的代码,我的问题是所有播放列表都为其类型返回“auto”或“wpl”。 (这都是使用WMPLib参考)
mediaplayer = new WindowsMediaPlayer();
// Init. Playlists
IWMPPlaylistCollection plcollection = mediaplayer.playlistCollection;
plarray = plcollection.getAll();
int i = 0, count = plarray.count;
string[] t = new string[count];
// Here is where I want to sort out non-music playlists
// And add them to the ListBox
for (i = 0; i < count - 1; i++)
t[i] = plarray.Item(i).getItemInfo("PlaylistType");
for (i = 0; i < count; i++ )
PlaylistBox.Items.Add("" + plarray.Item(i).name);
不相关,但是如果您知道如何将播放列表作为数据附加而不是将有用的字符串:)
答案 0 :(得分:1)
我猜您可以遍历播放列表项,如果项目的“ MediaType ”属性等于“ audio ”,则将此列表视为包含音频文件的列表。像这样的Smth:
private bool ListHasAudio(IWMPPlaylist playList)
{
if (playList != null && playList.count > 0)
{
for (int n = 0; n < playList.count; n++)
{
IWMPMedia media = playList.get_Item(n);
string mediaType = media.getItemInfo("MediaType");
if (mediaType != null && mediaType.Equals("audio", StringComparison.CurrentCultureIgnoreCase))
return true;
}
}
return false;
}
这是你如何使用它:
var mediaplayer = new WindowsMediaPlayer();
// Init. Playlists
IWMPPlaylistCollection plcollection = mediaplayer.playlistCollection;
var plarray = plcollection.getAll();
// Load list box items
for (int i = 0; i < plarray.count; i++)
{
IWMPPlaylist playList = plarray.Item(i);
if (ListHasAudio(playList))
PlaylistBox.Items.Add(playList.name);
}
希望这有帮助,尊重