Skip to content

Commit a543b80

Browse files
fix(UI): Use pagehide instead of unload for PiP (#5303)
As noted in https://groups.google.com/a/chromium.org/g/blink-dev/c/JTPl7fM64Lc, we should use "pagehide" not "unload" JS event to monitor when PiP window gets closed.
1 parent 7209695 commit a543b80

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

demo/close_button.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ shakaDemo.CloseButton = class extends shaka.ui.Element {
3636
window.documentPictureInPicture, 'enter', () => {
3737
this.button_.style.display = 'none';
3838
const pipWindow = window.documentPictureInPicture.window;
39-
this.eventManager.listen(pipWindow, 'unload', () => {
39+
this.eventManager.listen(pipWindow, 'pagehide', () => {
4040
this.button_.style.display = 'block';
4141
});
4242
});

ui/pip_button.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ shaka.ui.PipButton = class extends shaka.ui.Element {
187187
this.onEnterPictureInPicture_();
188188

189189
// Listen for the PiP closing event to move the player back.
190-
this.eventManager.listenOnce(pipWindow, 'unload', () => {
190+
this.eventManager.listenOnce(pipWindow, 'pagehide', () => {
191191
placeholder.replaceWith(/** @type {!Node} */(pipPlayer));
192192
});
193193
}

0 commit comments

Comments
 (0)