使用WMPLib.WindowsMediaPlayer自动播放歌曲不起作用。 PlayStateChange事件引发了多次,但player.controls.play()无法开始播放歌曲。
public void play(string path)
{
if (player.playState != WMPLib.WMPPlayState.wmppsPaused)
{
player.controls.stop();
player.URL= path;
player.settings.volume = 90;
}
else
player.controls.play();
}
private void Player_PlayStateChange(int NewState)
{
switch (NewState)
{
case 3:
Play_State();
break;
case 4:
Stop_State();
break;
case 8:
MediaEnded();
next_song = true;
break;
case 10:
if (!next_song) return;
player.controls.play();
next_song = false;
System.Threading.Thread.Sleep(3000);
break;
}
}