1
0
mirror of https://github.com/videojs/video.js.git synced 2025-01-02 06:32:07 +02:00

Use pagehide instead of unload for PiP (#8321)

This commit is contained in:
François Beaufort 2023-07-04 13:43:09 +02:00 committed by GitHub
parent b34cb2c207
commit 146008f610
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -3107,7 +3107,7 @@ class Player extends Component {
this.player_.trigger('enterpictureinpicture');
// Listen for the PiP closing event to move the video back.
pipWindow.addEventListener('unload', (event) => {
pipWindow.addEventListener('pagehide', (event) => {
const pipVideo = event.target.querySelector('.video-js');
pipContainer.replaceWith(pipVideo);
@ -3142,7 +3142,7 @@ class Player extends Component {
*/
exitPictureInPicture() {
if (window.documentPictureInPicture && window.documentPictureInPicture.window) {
// With documentPictureInPicture, Player#leavepictureinpicture is fired in the unload handler
// With documentPictureInPicture, Player#leavepictureinpicture is fired in the pagehide handler
window.documentPictureInPicture.window.close();
return Promise.resolve();
}

View File

@ -2925,7 +2925,7 @@ QUnit.test('docPiP moves player and triggers events', function(assert) {
return fakePiPWindow.document.body.querySelector(sel);
};
fakePiPWindow.close = function() {
fakePiPWindow.dispatchEvent(new Event('unload'));
fakePiPWindow.dispatchEvent(new Event('pagehide'));
delete window.documentPictureInPicture.window;
};