melika melika - 26 days ago 10
C# Question

Windows Media Player - Hide player after it is done playing

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.

Answer

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();
}
Comments