How to automatically enter in fullscreen mode on Android devices?

I have a web page where I am triggering a video. On iOS when you click the play button it automatically goes into fullscreen mode but on Android doesn't, it only reproduces the video in the same window.

I tried something like this:

var videoPlayer = document.getElementById('myPlayer');
var user_agent = navigator.userAgent.toLowerCase();
if(user_agent.indexOf('android') > -1) {

But it throws this error:

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

I am using the Brightcove video player as a request from the client.

So I would like to know if there is a specific method for that player in order to go into fullscreen mode when you hit the play button?

1 answer

  • answered 2018-01-12 07:14 Pratik18

    Try this code,

    $('#videoPlayer').html("<video style='position:relative; z-index:999; margin-left:0%;' width='100%' height='100%' src='" + url + "' type='video/mp4' controls ></video>");