shaka-player icon indicating copy to clipboard operation
shaka-player copied to clipboard

Rotate on Fullscreen (Android)

Open ziddey opened this issue 4 years ago • 3 comments

Have you read the FAQ and checked for duplicate open issues? Extension of closed issues https://github.com/google/shaka-player/issues/883 https://github.com/google/shaka-player/issues/2494 https://github.com/google/shaka-player/issues/2653

Is your feature request related to a problem? Please describe. I'm using shaka-ui and doing the reverse of the above (rotate-on-fullscreen). However, the two features combined prevent Android PIP from working when the device is locked to portrait.

Describe the solution you'd like This is happening because shaka-ui's fullscreen-on-rotate feature exits fullscreen on portrait rotation (which happens when triggering PIP if the device is portrait-locked).

Describe alternatives you've considered It's not a big deal to disable this via enableFullscreenOnRotation, but it may be worth tracking if the fullscreen request was triggered by a landscape rotation and then only exiting fullscreen on return to portrait if so.

Additional context As it is, without my rotate-on-fullscreen, it's possible to manually request fullscreen while in portrait. With autorotate, it's possible to switch to landscape, but then not back to fullscreen portrait again without shaka-ui automatically exiting fullscreen.

https://github.com/google/shaka-player/commit/20c60e65caaefd3bdcc82fa94c43ecbd82c69350#diff-0e63b8017cb301a39d856ad6afb203a028f5f5601423b2e301a6b64cc3ead593R212-R215

For reference, I'm currently implementing rotate-on-fullscreen externally like so:

  if (screen.orientation && screen.orientation.lock)
    document.querySelectorAll('[data-shaka-player-container]').forEach(el => {
      el.addEventListener('fullscreenchange', e => {
        if (document.fullscreenElement)
          screen.orientation.lock('landscape')
      })
    })

ziddey avatar Dec 25 '20 01:12 ziddey

Ack, just found https://github.com/google/shaka-player/commit/6694d3c13ede673b80fa36285a93584ab0e6a9b3 https://github.com/google/shaka-player/issues/2653

I imagine when using the two features together would still prevent Android PIP from working when the device is locked to portrait.

Closing

ziddey avatar Dec 25 '20 01:12 ziddey

@ziddey, I'm sorry, but I don't understand this issue. If you go into PiP while in fullscreen mode, don't you expect fullscreen to end? You can't be in PiP and fullscreen at the same time.

You also left a comment on 6694d3c, but it's not clear to me if there is still an issue, since you closed this one. Is there something we missed?

joeyparrish avatar Dec 28 '20 19:12 joeyparrish

When going fullscreen, the shaka player container is the fullscreen element.

From here, Android PIP can be triggered by escaping to the homescreen. Now in PIP mode, the fullscreen element is still the shaka player container.

However, with fullscreen-on-rotation enabled, document.exitFullscreen() is called if the screen goes back to portrait mode.

So this scenario can happen:

  1. Android device is set to portrait (auto-rotate disabled)
  2. Shaka player loaded (both forceLandscapeOnFullscreen and enableFullscreenOnRotation enabled as is the new default)
  3. Play video and go fullscreen
  4. Screen will be forced to landscape
  5. Go home (trigger PIP) -- video player container is no longer actually fullscreen, but the element still is for the document (it's "fullscreen" in the pip-box).
  6. Android device goes back to portrait since auto-rotate is disabled
  7. fullscreen-on-rotate detects portrait and exits fullscreen for the document
  8. Unsetting fullscreen for video player container element causes Android PIP to cancel
  9. Back at homescreen with no PIP (PIP

PIP requires there be a document.fullscreenElement.

ziddey avatar Dec 28 '20 20:12 ziddey

Can you test with v4.3.4? Thanks!

avelad avatar Feb 03 '23 08:02 avelad

Closing due to inactivity. If this is still an issue for you or if you have further questions, the OP can ask shaka-bot to reopen it by including @shaka-bot reopen in a comment.

github-actions[bot] avatar Feb 10 '23 08:02 github-actions[bot]