Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Exit PIP if entering fullscreen #8082

Merged
merged 2 commits into from
Feb 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/js/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
23 changes: 23 additions & 0 deletions test/unit/player-fullscreen.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down