我正在建立一个音乐播放器,因此我选择使用Window Media Player库:现在我卡住了因为我希望在listBox中显示歌曲的名称并实时更改歌曲但我不知道怎么做我存储文件夹中的歌曲,因此当音乐播放器播放来自Url的歌曲时。
代码段
private void PlaylistMidday(String folder, string extendsion)
{
string myPlaylist = "D:\\Music\\The_Chemical_Brothers-Do_It_Again-(US_CDM)-2007-SAW\\";
ListView musicList = new ListView();
WMPLib.IWMPPlaylist pl;
WMPLib.IWMPPlaylistArray plItems;
plItems = player1.playlistCollection.getByName(myPlaylist);
if (plItems.count == 0)
pl = player1.playlistCollection.newPlaylist(myPlaylist);
else
pl = plItems.Item(0);
DirectoryInfo dir = new DirectoryInfo(folder);
FileInfo[] files = dir.GetFiles(extendsion, SearchOption.AllDirectories);
foreach (FileInfo file in files)
{
string musicFile01 = file.FullName;
string mName = file.Name;
ListViewItem item = new ListViewItem(mName);
musicList.Items.Add(item);
WMPLib.IWMPMedia m1 = player1.newMedia(musicFile01);
pl.appendItem(m1);
}
player1.currentPlaylist = pl;
player1.Ctlcontrols.play();
}
在加载时我决定播放“myPLaylist”的歌曲,所以我想你知道如何在列表框中显示我的播放列表的歌曲,当我点击所选项目时歌曲会被更改吗? / p>