From 79ce6f62d8c7e2211879e444c2401788e9bfeb25 Mon Sep 17 00:00:00 2001 From: wseymour15 Date: Thu, 15 Feb 2024 09:56:07 -0600 Subject: [PATCH] update metadata on enter pip event --- src/js/player.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/js/player.js b/src/js/player.js index 31f48469a..2f63bad32 100644 --- a/src/js/player.js +++ b/src/js/player.js @@ -3200,10 +3200,13 @@ class Player extends Component { } pipContainer.appendChild(Dom.createEl('p', { className: 'vjs-pip-text' }, {}, this.localize('Playing in picture-in-picture'))); + const pipWidth = this.videoWidth(); + const pipHeight = this.videoHeight(); + return window.documentPictureInPicture.requestWindow({ // The aspect ratio won't be correct, Chrome bug https://crbug.com/1407629 - width: this.videoWidth(), - height: this.videoHeight() + width: pipWidth, + height: pipHeight }).then(pipWindow => { Dom.copyStyleSheetsToWindow(pipWindow); this.el_.parentNode.insertBefore(pipContainer, this.el_); @@ -3212,7 +3215,7 @@ class Player extends Component { pipWindow.document.body.classList.add('vjs-pip-window'); this.player_.isInPictureInPicture(true); - this.player_.trigger('enterpictureinpicture'); + this.player_.trigger({type: 'enterpictureinpicture', width: pipWidth, height: pipHeight}); // Listen for the PiP closing event to move the video back. pipWindow.addEventListener('pagehide', (event) => {