User enters PiP User resizes PiP window User exits PiP
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
}
}