Embeded Windows Media Player full screen

MarceloClaure picture MarceloClaure · Nov 24, 2013 · Viewed 8.4k times · Source

I have an embedded video in a winform using axwindowsmediaplayer and C#.

I have a timer to set the control to fullscreen=true after some time.

private void timer1_Tick(object sender, EventArgs e)
{
    timer1.Stop();
    videowmp.fullScreen = true;
}

I use a database to get the videos, and I call a function to obtain them every time the video finishes, for some reason I needed a second timer there to start the new video:

private void videowmp_PlayStateChange(object sender,
    AxWMPLib._WMPOCXEvents_PlayStateChangeEvent e)
{
    if (e.newState == 8)
    {
        timer2.Interval = 100;
        timer2.Enabled = true;
    }
}

private void timer2_Tick(object sender, EventArgs e)
{
    timer2.Enabled = false;
    selec_video();
}

The function selec_video() gets the video, set the URL for the windows media player control and set it to play().

My problem is that when a video finishes, I lose full-screen mode. I mean the video goes back to its original size. I tried to set fullscreen=true after calling selec_video(), but I got an error (catastrophic error). I suppose this happens because the control is already in full screen... So what I want to do, is call selec_video(), without losing the full-screen mode.

Answer

Thilina Sandunsiri picture Thilina Sandunsiri · Mar 10, 2014

The below code is checking your media player's play state. If it's playing something, it will set it to full screen mode.

private void timer2_Tick(object sender, EventArgs e)
{
     selec_video(); 
     if (videowmp.playState == WMPLib.WMPPlayState.wmppsPlaying)
     {
        videowmp.fullScreen = true;
     }
}