2.2.8

Mobile Fullscreen

Last updated


This page covers how the full button behaves on desktop versus mobile, and how the hidden mobile fullscreen player stays in sync.

Device Detection


FlexPlyr detects the device from the User-Agent on load (src/js/*.js):
FlagCondition
isMobileUA contains iphone, ipad, ipod, or android
isIOSUA contains iphone, ipad, or ipod

Desktop


The full button calls requestFullscreen on the .FPlyr container (including the webkit/moz/ms prefixed versions), calls exitFullscreen on the next click, and updates player.stateFull.

Mobile


Inline video on mobile is bound by playsinline, so a custom panel cannot follow it into fullscreen. FlexPlyr therefore creates a hidden fullscreen player (class PDFullPlayer, moved off-screen by CSS):
SourceFullscreen playerHow it enters
videoA second <video> without playsinlinefull → pause the main player → play(true) plays the fullscreen player, which the OS shows natively fullscreen
youtubeA second YT.Player with playsinline: 0Same; calling play(true) before that player's onReady shows alert("not Ready")
vimeoNone; the main player is reusedplay(true) calls requestFullscreen() and then plays
audioNoneThe full button is not rendered

Syncing In and Out


WhenWhat happens
The fullscreen player starts (video playing / YouTube state 3)Pauses the main player, copies its time, volume, and speed to the fullscreen player, then plays
The fullscreen player pauses (leaving fullscreen)Copies time, volume, and speed back to the main player and updates the panel progress
iOS webkitpresentationmodechanged / otherwise fullscreenchangeUpdates player.stateFull

On mobile, tapping the video picture does not toggle playback; only the panel buttons do.

Example


Desktop browsers create no fullscreen player; open this page on iOS or Android and the count is 1:
  1. <div style="max-width: 480px; aspect-ratio: 16 / 9"><div id="player"></div></div>
  2. <script>
  3. const player = new FPlyr({
  4. id: "player",
  5. video: "https://cdn.pixabay.com/video/2023/11/28/191159-889246512_tiny.mp4",
  6. option: { panelItem: ["play", "progress", "full"] },
  7. });
  8. console.log("hidden fullscreen players:", document.querySelectorAll(".PDFullPlayer").length);
  9. console.log("stateFull:", player.stateFull);
  10. </script>
Live preview · @pardnchiu/flexplyr@2.2.9


中文