From f451221edca0b115005261d56ac967580553fb69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaroslav=20Polakovi=C4=8D?= Date: Mon, 31 Jan 2022 13:50:18 +0100 Subject: [PATCH 1/3] Only play one video in PiP at once. --- src/js/web-components/video-player/VideoPlayer.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/js/web-components/video-player/VideoPlayer.js b/src/js/web-components/video-player/VideoPlayer.js index d458e13..c73864a 100644 --- a/src/js/web-components/video-player/VideoPlayer.js +++ b/src/js/web-components/video-player/VideoPlayer.js @@ -27,7 +27,7 @@ import { PIP_CLASSNAME, } from '../../constants'; -export default class extends HTMLElement { +export default class VideoPlayer extends HTMLElement { /** * @param {VideoDownloader} downloader Video downloader associated with the current video. */ @@ -464,6 +464,11 @@ export default class extends HTMLElement { pipButton.disabled = true; try { if (this !== document.pictureInPictureElement) { + // If another video is already in PiP, pause it and exit PiP mode. + if (document.pictureInPictureElement instanceof VideoPlayer) { + document.pictureInPictureElement.videoElement.pause(); + await document.exitPictureInPicture(); + } await this.videoElement.requestPictureInPicture(); } else { await document.exitPictureInPicture(); From 599d9ab4c439d598146f69f60123996e993aee79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaroslav=20Polakovi=C4=8D?= Date: Mon, 31 Jan 2022 14:25:56 +0100 Subject: [PATCH 2/3] Remove the superfluous exitPictureInPicture call. --- src/js/web-components/video-player/VideoPlayer.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/js/web-components/video-player/VideoPlayer.js b/src/js/web-components/video-player/VideoPlayer.js index c73864a..42420a7 100644 --- a/src/js/web-components/video-player/VideoPlayer.js +++ b/src/js/web-components/video-player/VideoPlayer.js @@ -467,7 +467,6 @@ export default class VideoPlayer extends HTMLElement { // If another video is already in PiP, pause it and exit PiP mode. if (document.pictureInPictureElement instanceof VideoPlayer) { document.pictureInPictureElement.videoElement.pause(); - await document.exitPictureInPicture(); } await this.videoElement.requestPictureInPicture(); } else { From ff908c3f62f944c3549ffd7a4131d19dbb288474 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaroslav=20Polakovi=C4=8D?= Date: Mon, 31 Jan 2022 14:36:40 +0100 Subject: [PATCH 3/3] Update a misleading comment. --- src/js/web-components/video-player/VideoPlayer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/web-components/video-player/VideoPlayer.js b/src/js/web-components/video-player/VideoPlayer.js index 42420a7..b7d7914 100644 --- a/src/js/web-components/video-player/VideoPlayer.js +++ b/src/js/web-components/video-player/VideoPlayer.js @@ -464,7 +464,7 @@ export default class VideoPlayer extends HTMLElement { pipButton.disabled = true; try { if (this !== document.pictureInPictureElement) { - // If another video is already in PiP, pause it and exit PiP mode. + // If another video is already in PiP, pause it. if (document.pictureInPictureElement instanceof VideoPlayer) { document.pictureInPictureElement.videoElement.pause(); }