/// <summary>
/// 自动下一曲
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void axPlayer_PlayStateChange(object sender, AxWMPLib._WMPOCXEvents_PlayStateChangeEvent e)
{
//musicPath是后台存储URL的List<string>
if (musicPath.Count == 0)
{
return;
}
if (axPlayer.playState == WMPLib.WMPPlayState.wmppsMediaEnded)
{
//lbSounds是播放列表
int index = lbSounds.SelectedIndex;
index++;
if (index > musicPath.Count - 1)
{
lbSounds.SelectedIndex = 0;
axPlayer.URL = musicPath[0];
//歌词的方法,不用看
InLrc(axPlayer.currentMedia.sourceURL);
}
else
{
lbSounds.SelectedIndex = index;
axPlayer.URL=musicPath[index];
InLrc(axPlayer.currentMedia.sourceURL);
}
}
if (axPlayer.playState == WMPLib.WMPPlayState.wmppsReady)
{
//执行到这里,抛出COMException异常
axPlayer.Ctlcontrols.play();
}
} |