0

I'm trying to play an online video in my windows forms application. I can successfully play the video but i'd like to make it fullScreen.

The url is this:

http://www.mitele.es/msplayer/popup/?editorialId=231609

I've been inspecting the site and I found that the code for the expand button is this:

<button ng-if="fullScreenBtIf" class="fullscreen-bt msplayer-icon-fullscreen ng-scope" title="Pantalla completa" ng-click="toggleFullscreen()" ms-skin-button="" style="color: rgb(5, 187, 237); opacity: 1;"><span class="screen-reader-text">Ir a pantalla completa</span>
</button>

CEFsharp is working fine as I have tested it with an alert:

myBrowser.ExecuteScriptAsync("alert('test');");

I've tried to expand the video player by doing:

myBrowser.ExecuteScriptAsync("toggleFullscreen();"); 

But i get that toggleFullScreen is undefined. Do you have any idea in order to achieve this?

Aldridge1991
  • 1,213
  • 4
  • 20
  • 45

1 Answers1

2

Your problem is one of scope, but it's not possible to make it full screen without user input anyway. Open the video you linked, open the browser console and run this...

MSPlayer.scopes[Object.keys(MSPlayer.scopes)[0]].toggleFullscreen();

That executes the function in its correct scope, but will also explain to you why it can't run.

In Chrome...

Failed to execute 'requestFullScreen' on 'Element': API can only be initiated by a user gesture.

However, since this is a Windows forms application you can make the form maximize at runtime and dock the webview to the form in order to make the html page full screen, and then inject the following script to resize the video...

$("div").eq(0).css({
    position: "absolute",
    top:0,
    left:0,
    width:"100%",
    height:"100%"
});

That will make the video fit the already maximized page and form.

Reinstate Monica Cellio
  • 24,939
  • 6
  • 47
  • 65