The PictureInPictureWindow interface represents an object able to programmatically obtain the width and height and resize event of the floating video window.
An object with this interface is obtained using the HTMLVideoElement.requestPictureInPicture() promise return value.
Properties
The PictureInPictureWindow interface doesn't inherit any properties.
PictureInPictureWindow.widthRead only- Determines the width of the floating video window.
PictureInPictureWindow.heightRead only- Determines the height of the floating video window.
Methods
The PictureInPictureWindow interface doesn't inherit any methods.
Events
'The PictureInPictureWindow interface doesn't inherit any events.'
PictureInPictureWindow.resize- Sent to a
PictureInPictureWindowwhen the floating video window is resized. The associated event handler isPictureInPictureWindow.onresize.
Examples
Given a <button> and a <video>, clicking the button will make the video enter the picture-in-picture mode; we then attach an event to print the floating video window dimensions to the console.
const button = document.querySelector("button");
const video = document.querySelector("video");
function printPipWindowDimensions(evt) {
const pipWindow = evt.target;
console.log(`The floating window dimensions are: ${pipWindow.width}x${pipWindow.height}px`);
// will print:
// The floating window dimensions are: 640x360px
}
button.onclick = function() {
video.requestPictureInPicture().then(pictureInPictureWindow => {
pictureInPictureWindow.onresize = printPipWindowDimensions;
});
};
Specifications
| Specification | Status | Comment |
|---|---|---|
| Unknown | Unknown | Initial specification. |
Browser compatibility
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
No compatibility data found. Please contribute data for "api.PictureInPictureWindow" (depth: 1) to the MDN compatibility data repository.
See also
PictureInPictureWindow by Mozilla Contributors is licensed under CC-BY-SA 2.5.