Only play one video in PiP at once.

This commit is contained in:
Jaroslav Polakovič 2022-01-31 13:50:18 +01:00
Родитель cd26b29d6c
Коммит f451221edc
1 изменённых файлов: 6 добавлений и 1 удалений

Просмотреть файл

@ -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();