I am having a Bitmovin player instance and I am trying to force fullscreen when device orientation changes to landscape. Code goes like this:
const portrait = window.matchMedia("(orientation: portrait)");
portrait.addEventListener("change", function (e) {
window.dispatchEvent(new Event('resize'));
if (!e.matches && player.isPlaying() && (player.getViewMode() == 'inline')) {
player.setViewMode('fullscreen');
}
if (e.matches && player.isPlaying() && (player.getViewMode() == 'fullscreen')) {
player.setViewMode('inline');
}
})
Event listener works correctly, but on Chrome in Android phones I get a TypeError: fullscreen error
If I force fullscreen via console in dev tools and restore to inline view, behaviour changes and video goes fullscreen on orientation change.
Researching I found that Chrome requires either user gestures for fullscreen events, or call them through an event (as is the case here) so I cannot figure out what is wrong.
Behaviour is the same using the native fullscreen api instead of bitmovin's setViewMode()
functions
The problem is not specific to the Bitmovin Player but to the browser. I think you partly answered it yourself already:
User activation is required, but it seems that the
matchMedia
's change is simply not considered such.The HTML spec defines what should be considered an
activation triggering input event
as they call it:As you see, the event you try to use is not in this list. If those are truly the only events considered by Chrome, then I don't think your desired behavior is feasible.