3

I am creating a game, I want to display a short tutorial video to the player after they have registered. I am using a windows media player control. I don't know how to hide the video after it has finished playing ? I tried using the following:

WMP.Ctlcontrols.play();
Thread.Sleep(3000);
WMP.Dispose();

I am using the disposing as a way to close down the video. I tried hide and close as well but they close the video before it's finished playing, after 3 seconds.

Reza Aghaei
  • 120,393
  • 18
  • 203
  • 398
melika
  • 97
  • 2
  • 9
  • If you added Media player control to the form, you don't need to dispose it manually. It will be disposed after you closed the form. – Reza Aghaei Nov 08 '16 at 18:39
  • I am using the disposing as a way to close down the video. I tried hide and close as well but they close the video before it's finished playing. – melika Nov 08 '16 at 18:55
  • Do you mean you want to hide the player when the video finished playing? – Reza Aghaei Nov 08 '16 at 19:06
  • You can handle [PlayStateChange](https://msdn.microsoft.com/en-us/library/windows/desktop/dd562460(v=vs.85).aspx) event of control and check if `e.newState==1`, it means the playing has been stopped. Then you can hide the control. – Reza Aghaei Nov 08 '16 at 19:33
  • It's working now, Thank you very much . – melika Nov 08 '16 at 19:37

1 Answers1

4

You can handle PlayStateChange event of control and check if e.newState==1, it means the playing has been stopped. Then you can hide the control.

void axWindowsMediaPlayer1_PlayStateChange(object sender, 
    AxWMPLib._WMPOCXEvents_PlayStateChangeEvent e)
{
    if(e.newState== 1) // Stopped
        axWindowsMediaPlayer1.Hide();
}
Reza Aghaei
  • 120,393
  • 18
  • 203
  • 398