cordova-plugin-screen-orientation icon indicating copy to clipboard operation
cordova-plugin-screen-orientation copied to clipboard

can't call element.requestFullscreen() inside orientation change listener

Open BlueBomberman opened this issue 3 years ago • 0 comments

Bug Report

Hi everyone this is the first issue that i write on github, so correct me if something is not right.

Problem

I'm trying to open a videoplayer on fullscreen when rotating the device, and as I read on MDN this shoud be possible, because the rotation is considered a user gesture.

What is expected to happen?

The Video player goes fullscreen when rotating the device.

What does actually happen?

I get an error saying

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

Information

I have tried with both window.addEventListener("orientationchange",..), and screen.orientation.addEventListener('change',..) but it doesn't seem to change.

Command or Code

window.screen.orientation.addEventListener("change", function () { if (window.screen.orientation.type.startsWith("landscape") && !document.fullscreenElement) { try { container.requestFullscreen(); } catch (err) {...); } } else if ( window.screen.orientation.type.startsWith("portrait") && document.fullscreenElement ) { try { document.exitFullscreen(); } catch (err) { ... } } }); });

Version information

Plugin version: 3.0.2. The project is a ionic 5.6.3 application, with capacitor 2.4.7, I have only tested android for now.

Checklist

  • [x] I searched for existing GitHub issues
  • [x] I updated all Cordova tooling to most recent version
  • [] I included all the necessary information above

BlueBomberman avatar Jun 07 '21 13:06 BlueBomberman