more PiP fixes

This commit is contained in:
wuggy 2026-09-13 11:52:14 -07:00
commit aac2156499
6 changed files with 56 additions and 7 deletions

View file

@ -11,6 +11,7 @@ var output = null;
var still = null;
var observer = null;
var sourceWindow = null;
var initialized = false;
var events = ["play", "pause", "volumechange", "ended", "seeked", "resize"];
function update() {
@ -63,6 +64,12 @@ function closePlayer() {
}
addMessageListener("PictureInPicture:Init", message => {
// takeSource consumes the handoff. A duplicate initialization must not
// consume it again or close an already playing window.
if (initialized) {
return;
}
initialized = true;
try {
source = PictureInPicture.takeSource(message.data.id);
sourceWindow = source.ownerGlobal;