Burak Kaan Bilgehan
Burak Kaan Bilgehan

Reputation: 721

Loading MediaPlayer as fullscreen in c# .net

I'm trying to open a new form from my main form. After selecting the video to play, I want the player to be fullscreen without clicking any button.

When i tried to add axWindowsMediaPlayer.fullscreen = true in constructor or axWindowsMediaPlayer_Load (or _Enter), it gives an error, saying "It's a very dangerous error".

But on the other hand when I add a button called fullscreen, and pasting axWindowsMediaPlayer.fullscreen = true code in it, it works, but that's not how I want it to be.

Isn't there a way to do it without clicking? By the way, I used timer method, but it gives the same error.

Upvotes: 0

Views: 2087

Answers (1)

active92
active92

Reputation: 654

Use PlayStateChange event. The code below detects the change in play state then change to fullscreen if the video is playing.

private void axWindowsMediaPlayer1_PlayStateChange(object sender, AxWMPLib._WMPOCXEvents_PlayStateChangeEvent e)
    {
        if (this.axWindowsMediaPlayer1.playState == WMPLib.WMPPlayState.wmppsPlaying)
        {
            this.axWindowsMediaPlayer1.fullScreen = true;
        }
    }

Upvotes: 1

Related Questions