0

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

miminas
  • 1
  • 1

1 Answers1

0

The problem is not specific to the Bitmovin Player but to the browser. I think you partly answered it yourself already:

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.

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:

An activation triggering input event is any event whose isTrusted attribute is true and whose type is one of:

  • keydown, provided the key is neither the Esc key nor a shortcut key reserved by the user agent.
  • mousedown.
  • pointerdown, provided the event's pointerType is "mouse".
  • pointerup, provided the event's pointerType is not "mouse".
  • touchend.

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.

Daniel
  • 1,208
  • 9
  • 14