Video.js: How to set fullscreen mode on Android devices right after clicking the play button?

Created on 11 Jan 2018  路  1Comment  路  Source: videojs/video.js

I need to know how to go into fullscreen mode right after clicking the play button of the video (On Android only).

I've tried something like this:

    var videoPlayer = document.getElementById('myPlayer');
    var user_agent = navigator.userAgent.toLowerCase();
    if(user_agent.indexOf('android') > -1) { // Check for Android.
       videoPlayer.requestFullscreen();
    }

But I am getting this error:

TypeError: videoPlayer.requestFullscreen is not a function. (In 'videoPlayer.requestFullscreen()', 'videoPlayer.requestFullscreen' is undefined)

Any suggestions?

Most helpful comment

With document.getElementById('myPlayer') you're getting the player element rather than the player. That el may or may have a vendor prefixed webkit/mozFullscreen(). Use the Video.js API's requestFullscreen() in response to a user interaction event.

var player = videojs('myPlayer');
player.bigPlayButton.one('tap', function() {
  if (videojs.browser.IS_ANDROID) {
    player.requestFullscreen();
  }
});

>All comments

With document.getElementById('myPlayer') you're getting the player element rather than the player. That el may or may have a vendor prefixed webkit/mozFullscreen(). Use the Video.js API's requestFullscreen() in response to a user interaction event.

var player = videojs('myPlayer');
player.bigPlayButton.one('tap', function() {
  if (videojs.browser.IS_ANDROID) {
    player.requestFullscreen();
  }
});
Was this page helpful?
0 / 5 - 0 ratings

Related issues

dingyaguang117 picture dingyaguang117  路  4Comments

victorpfm picture victorpfm  路  4Comments

shivamg705 picture shivamg705  路  4Comments

kocoten1992 picture kocoten1992  路  4Comments

askaliuk picture askaliuk  路  3Comments