播放單首歌曲
復制代碼 代碼如下:
player.URL = "歌曲文件路徑";
player.Ctlcontrols.play();
添加多首歌曲到播放列表
復制代碼 代碼如下:
IWMPPlaylist playList = player.playlistCollection.newPlaylist("MyPlayList"); //新建列表
IWMPMedia media;
foreach (DataRow drItem in MusicSettings.DtMusic.Rows)
{
media = player.newMedia(drItem["路徑"].ToString()); //參數為歌曲路徑
playList.appendItem(media);
}
player.currentPlaylist = playList;
player.Ctlcontrols.play(); //開始播放
或者直接在當前列表上添加
復制代碼 代碼如下:
player.currentPlaylist.clear();
IWMPMedia media;
foreach (DataRow drItem in MusicSettings.DtMusic.Rows)
{
media = player.newMedia(drItem["路徑"].ToString()); //參數為歌曲路徑
player.currentPlaylist.appendItem(media);
}
設置播放器音量
復制代碼 代碼如下:
player.settings.volume=100;