Cannot load mozRequestFullScreen [Android]

Hi, I’m working in a really simple addon for Firefox Android and I can’t make it work by calling mozRequestFullScreen in an EventListener(‘load’)

It works fine by using ‘click’ though.

I understand that Fullscreen needs a user input in order to make it work due to some policies, but from my understanding and previous experience with other addons, automatic fullscreen is possible when the user decides to install an Addon.

Here’s the code:

function toggleFullScreen() {
	if (!document.mozFullScreen) {
		if (videoElement.mozRequestFullScreen) {
			videoElement.mozRequestFullScreen();
		}
	} else {
		if (document.mozCancelFullScreen) {
			document.mozCancelFullScreen();
		} 
	}
}

window.addEventListener("load", function(e) {
   	videoElement.mozRequestFullScreen();
}, false);

window.addEventListener("click", function(e) {
	toggleFullScreen();
}, false);

Thank you!

requesting full screen is only allowed from user interactions and device orientation changes: https://fullscreen.spec.whatwg.org/#allowed-to-request-fullscreen

1 Like

Hi Martin, thanks for replying!

See the following 3 line code that doesn’t do nothing without user interaction, BUT, if you use it as an addon it works! This meaning installing addon = user interaction ¿?

browser.windows.getCurrent().then((currentWindow) => {
	browser.windows.update(currentWindow.id, {state: "fullscreen"});
});

Unfortunately, getCurrent() is not compatible with Firefox for Android, hence my workaround with mozRequestFullScreen()

Thank you for any suggestion!

This meaning installing addon = user interaction

Nope. You are simply using a completely different API without the user-interaction restriction (that also does something different, page fullscreen !== window fullscreen).

It would probably be nice to have a fullscreen property on tabs, though.

1 Like