Skip to content

Instantly share code, notes, and snippets.

@beaufortfrancois
Created May 30, 2017 13:09
Show Gist options
  • Save beaufortfrancois/797a4a20780dc7fa559fc7e59c196310 to your computer and use it in GitHub Desktop.
Save beaufortfrancois/797a4a20780dc7fa559fc7e59c196310 to your computer and use it in GitHub Desktop.

Use cases

User enters PiP User resizes PiP window User exits PiP

Proposal #1

document.addEventListener('enterpictureinpicture', function() {
  // Some element entered Picture-In-Picture mode.
  updateVideoBitRate();
});

document.addEventListener('leavepictureinpicture', function() {
  // Some element left Picture-In-Picture mode.
  updateVideoBitRate();
});

document.addEventListener('resizepictureinpicture', function() {
  // User resized element in Picture-In-Picture mode.
  updateVideoBitRate();
});


function updateVideoBitRate() {
  if (document.pictureInPictureElement == video) {
    const videoHeight = getComputedStyle(document.pictureInPictureElement).height;
    // TODO: Use videoHeight for Adaptive Bit Rate
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment