0

I have a WMPLib.WindowsMediaPlayer instance that I create during application runtime. I want to hide a panel when the player playstate = "Stopped".

this is my code:

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;
    }
}

Any help will be appreciated.

anonymous
  • 1
  • 1
  • 3
  • Is this [Windows 7](http://social.msdn.microsoft.com/Forums/en/vbgeneral/thread/670c6cfd-6124-47e2-93ce-d948e227f652) only problem? – Raj Ranjhan Mar 01 '12 at 18:18
  • I am developing on Windows 7. Have not tested on any other windows platform as yet. you think its Windows 7 problem?? – anonymous Mar 01 '12 at 18:46
  • When you call other state? It changes to 'stopped' when the music ends? Is the Visible=true should it be false? – Lukinha RS Mar 01 '12 at 19:31
  • Sorry, that was typo (corrected it).. Actually I am setting it to "false" in my code and it still wont work :( – anonymous Mar 01 '12 at 20:57

1 Answers1

0

If you are trying to detect when the song has finished by itself, you need to check for WMPPlayState.wmppsMediaEnded

sugar
  • 1