Skip to content

Instantly share code, notes, and snippets.

@Jagathishrex
Created April 22, 2020 15:01
Show Gist options
  • Select an option

  • Save Jagathishrex/0d70473669ab3a708f94eeba481898bb to your computer and use it in GitHub Desktop.

Select an option

Save Jagathishrex/0d70473669ab3a708f94eeba481898bb to your computer and use it in GitHub Desktop.
var pipWindow;
video.addEventListener('enterpictureinpicture', function(event) {
pipWindow = event.pictureInPictureWindow;
console.log(`> Window size is ${pipWindow.width}x${pipWindow.height}`);
pipWindow.addEventListener('resize', onPipWindowResize);
});
video.addEventListener('leavepictureinpicture', function(event) {
pipWindow.removeEventListener('resize', onPipWindowResize);
});
function onPipWindowResize(event) {
console.log(`> Window size changed to ${pipWindow.width}x${pipWindow.height}`);
// Change video quality based on Picture-in-Picture window size.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment