From 062d17d49a38f2a3805a179779f5917263001b0d Mon Sep 17 00:00:00 2001 From: Gernot Zwantschko Date: Mon, 2 Sep 2024 14:49:00 +0200 Subject: [PATCH 1/2] Remove `fixed-player` class for CSS-based PiP, in case native PiP is already active --- player/picture-in-picture/scrollListener.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/player/picture-in-picture/scrollListener.js b/player/picture-in-picture/scrollListener.js index 34ca92b0..86f2bfaf 100644 --- a/player/picture-in-picture/scrollListener.js +++ b/player/picture-in-picture/scrollListener.js @@ -5,9 +5,16 @@ function adjustPlayer() { const lowerEdge = container.offset().top + container.height(); const switchToMinPlayerPos = lowerEdge - (window.innerHeight / 3); const currentScrollPos = document.body.scrollTop || document.documentElement.scrollTop; + const nativePipEnabled = player.getViewMode() === bitmovin.player.ViewMode.PictureInPicture; + + /* Disable CSS PiP, if native PiP is already in use */ + if (nativePipEnabled) { + document.querySelector('.player-switch').classList.remove('fixed-player'); + return; + } /* toggle the css-class responsible for the player moving to the lower right corner */ - if (currentScrollPos > switchToMinPlayerPos) { + if (currentScrollPos > switchToMinPlayerPos && !nativePipEnabled) { $('.player-switch').addClass('fixed-player'); } else { $('.player-switch').removeClass('fixed-player'); From f909fa34c5ed16cbe31ade5368a6b86e062151c1 Mon Sep 17 00:00:00 2001 From: Gernot Zwantschko Date: Mon, 2 Sep 2024 14:52:27 +0200 Subject: [PATCH 2/2] Enable/Disable CSS PiP if native PiP gets enabled/disabled --- player/picture-in-picture/setup.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/player/picture-in-picture/setup.js b/player/picture-in-picture/setup.js index 5ec714ee..9dcb2847 100644 --- a/player/picture-in-picture/setup.js +++ b/player/picture-in-picture/setup.js @@ -21,7 +21,10 @@ var conf = { ) ; } - } + }, + viewmodechanged: function() { + adjustPlayer(); + }, } }; @@ -44,4 +47,4 @@ player.load(source).then(function () { if (container.height() <= playerHeight) { container.height(playerHeight); } -}); \ No newline at end of file +});