From 97378c2e221e8ba8b31abcdd9bd7a3b0de07be8a Mon Sep 17 00:00:00 2001 From: Jacob Hamblin Date: Thu, 19 Jan 2023 14:26:55 -0700 Subject: [PATCH 1/2] exit PIP if entering fullscreen --- src/js/player.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/js/player.js b/src/js/player.js index e8e5b30c4d..cc886944e4 100644 --- a/src/js/player.js +++ b/src/js/player.js @@ -2784,6 +2784,10 @@ class Player extends Component { * @fires Player#fullscreenchange */ requestFullscreen(fullscreenOptions) { + if (this.isInPictureInPicture()) { + this.exitPictureInPicture(); + } + const self = this; return new Promise((resolve, reject) => { From 1342c5970d95e8b392d04d0221386b5e67b0362d Mon Sep 17 00:00:00 2001 From: Jacob Hamblin Date: Fri, 27 Jan 2023 13:10:09 -0700 Subject: [PATCH 2/2] assert that entering full screen leaves PiP --- test/unit/player-fullscreen.test.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/test/unit/player-fullscreen.test.js b/test/unit/player-fullscreen.test.js index 77c2350637..fcadd46047 100644 --- a/test/unit/player-fullscreen.test.js +++ b/test/unit/player-fullscreen.test.js @@ -243,6 +243,29 @@ QUnit.test('full window can be preferred to fullscreen tech', function(assert) { player.dispose(); }); +QUnit.test('fullscreen mode should exit picture-in-picture if it was enabled', function(assert) { + const player = FullscreenTestHelpers.makePlayer(false, { + preferFullWindow: true + }); + + const fakeExitPictureInPicture = sinon.replace(player, 'exitPictureInPicture', sinon.fake(() => {})); + + player.fsApi_ = {}; + player.tech_.supportsFullScreen = () => true; + + assert.strictEqual(player.isFullscreen(), false, 'player should not be fullscreen initially'); + player.isInPictureInPicture(true); + player.trigger('enterpictureinpicture'); + assert.strictEqual(player.isInPictureInPicture(), true, 'player is in picture-in-picture'); + + assert.strictEqual(fakeExitPictureInPicture.called, false, 'should not have called exitPictureInPicture yet'); + player.requestFullscreen(); + assert.strictEqual(player.isFullscreen(), true, 'player should be fullscreen'); + assert.strictEqual(fakeExitPictureInPicture.called, true, 'should have called exitPictureInPicture'); + + player.dispose(); +}); + QUnit.test('fullwindow mode should exit when ESC event triggered', function(assert) { const player = TestHelpers.makePlayer();