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:
parent
b34cb2c207
commit
146008f610
@ -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();
|
||||
}
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user