Skip to content

Commit

Permalink
fix(UI): Use pagehide instead of unload for PiP (shaka-project#5303)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
beaufortfrancois committed Jun 14, 2023
1 parent 7209695 commit a543b80
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion demo/close_button.js
Expand Up @@ -36,7 +36,7 @@ shakaDemo.CloseButton = class extends shaka.ui.Element {
window.documentPictureInPicture, 'enter', () => {
this.button_.style.display = 'none';
const pipWindow = window.documentPictureInPicture.window;
this.eventManager.listen(pipWindow, 'unload', () => {
this.eventManager.listen(pipWindow, 'pagehide', () => {
this.button_.style.display = 'block';
});
});
Expand Down
2 changes: 1 addition & 1 deletion ui/pip_button.js
Expand Up @@ -187,7 +187,7 @@ shaka.ui.PipButton = class extends shaka.ui.Element {
this.onEnterPictureInPicture_();

// Listen for the PiP closing event to move the player back.
this.eventManager.listenOnce(pipWindow, 'unload', () => {
this.eventManager.listenOnce(pipWindow, 'pagehide', () => {
placeholder.replaceWith(/** @type {!Node} */(pipPlayer));
});
}
Expand Down

0 comments on commit a543b80

Please sign in to comment.