0

我有一个在应用程序运行时创建的 WMPLib.WindowsMediaPlayer 实例。当播放器播放状态 =“已停止”时,我想隐藏一个面板。

这是我的代码:

private void PlayFile(String url)
{
    WMPLib.WindowsMediaPlayer Player = new WMPLib.WindowsMediaPlayer();
    Player.PlayStateChange += new WMPLib._WMPOCXEvents_PlayStateChangeEventHandler(Player_PlayStateChange);
    Player.MediaError += new WMPLib._WMPOCXEvents_MediaErrorEventHandler(Player_MediaError);
    Player.URL = url;
    plSpinner.Visible = true;
    Player.controls.play();
}
private void Player_PlayStateChange(int NewState)
{
    if ((WMPLib.WMPPlayState)NewState == WMPLib.WMPPlayState.wmppsStopped)
    {
        //This never gets executed
        plSpinner.Visible = false;
    }
}

任何帮助将不胜感激。

4

1 回答 1

0

如果您尝试检测歌曲何时自行完成,则需要检查 WMPPlayState.wmppsMediaEnded

于 2012-12-27T02:36:15.673 回答