From 585667067be9f3696542f3909481f5767ca92c5f Mon Sep 17 00:00:00 2001 From: Bill Thornton Date: Wed, 29 Jul 2020 09:28:06 -0400 Subject: [PATCH] Fix fullscreen video in iOS Safari --- src/components/playback/playbackmanager.js | 20 ++++++++++++++++++++ src/plugins/htmlVideoPlayer/plugin.js | 5 +++++ 2 files changed, 25 insertions(+) diff --git a/src/components/playback/playbackmanager.js b/src/components/playback/playbackmanager.js index 829cd38f2c..0f3b0fbc55 100644 --- a/src/components/playback/playbackmanager.js +++ b/src/components/playback/playbackmanager.js @@ -18,6 +18,11 @@ define(['events', 'datetime', 'appSettings', 'itemHelper', 'pluginManager', 'pla screenfull.on('change', function () { events.trigger(player, 'fullscreenchange'); }); + } else { + // iOS Safari + document.addEventListener('webkitfullscreenchange', function () { + events.trigger(player, 'fullscreenchange'); + }, false); } } @@ -1399,6 +1404,11 @@ define(['events', 'datetime', 'appSettings', 'itemHelper', 'pluginManager', 'pla return player.isFullscreen(); } + if (!screenfull.isEnabled) { + // iOS Safari + return document.webkitIsFullScreen; + } + return screenfull.isFullscreen; }; @@ -1410,6 +1420,16 @@ define(['events', 'datetime', 'appSettings', 'itemHelper', 'pluginManager', 'pla if (screenfull.isEnabled) { screenfull.toggle(); + } else { + // iOS Safari + if (document.webkitIsFullScreen && document.webkitCancelFullscreen) { + document.webkitCancelFullscreen(); + } else { + const elem = document.querySelector('video'); + if (elem && elem.webkitEnterFullscreen) { + elem.webkitEnterFullscreen(); + } + } } }; diff --git a/src/plugins/htmlVideoPlayer/plugin.js b/src/plugins/htmlVideoPlayer/plugin.js index b3b2402c26..f9d0e19095 100644 --- a/src/plugins/htmlVideoPlayer/plugin.js +++ b/src/plugins/htmlVideoPlayer/plugin.js @@ -554,6 +554,11 @@ define(['browser', 'require', 'events', 'apphost', 'loading', 'dom', 'playbackMa if (screenfull.isEnabled) { screenfull.exit(); + } else { + // iOS Safari + if (document.webkitIsFullScreen && document.webkitCancelFullscreen) { + document.webkitCancelFullscreen(); + } } };