From 84d2314a38a02de09991214b5763ffc039afd5da Mon Sep 17 00:00:00 2001 From: EscherMoore Date: Sun, 12 Mar 2023 23:20:14 -0400 Subject: [PATCH] keep picture in picture open when switching videos --- src/components/VideoPlayer.vue | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/VideoPlayer.vue b/src/components/VideoPlayer.vue index 0b765342..64c4c5bf 100644 --- a/src/components/VideoPlayer.vue +++ b/src/components/VideoPlayer.vue @@ -370,6 +370,9 @@ export default { else this.setPlayerAttrs(this.$player, videoEl, uri, mime, this.$shaka); if (noPrevPlayer) { + videoEl.addEventListener("loadeddata", () => { + if (document.pictureInPictureElement) videoEl.requestPictureInPicture(); + }); videoEl.addEventListener("timeupdate", () => { const time = videoEl.currentTime; this.$emit("timeupdate", time); @@ -686,14 +689,14 @@ export default { if (markers) markers.style.background = `linear-gradient(${array.join(",")})`; }, destroy(hotkeys) { - if (this.$ui) { + if (this.$ui && !document.pictureInPictureElement) { this.$ui.destroy(); this.$ui = undefined; this.$player = undefined; } if (this.$player) { this.$player.destroy(); - this.$player = undefined; + if (!document.pictureInPictureElement) this.$player = undefined; } if (hotkeys) this.$hotkeys?.unbind(); this.$refs.container?.querySelectorAll("div").forEach(node => node.remove());