files/en-us/web/api/pictureinpicturewindow/index.md
{{APIRef("Picture-in-Picture API")}}
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 {{domxref("HTMLVideoElement.requestPictureInPicture()")}} promise return value.
{{InheritanceDiagram}}
The PictureInPictureWindow interface doesn't inherit any properties.
The PictureInPictureWindow interface doesn't inherit any methods.
The PictureInPictureWindow interface doesn't inherit any events.
PictureInPictureWindow when the floating video window is resized.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 = () => {
video.requestPictureInPicture().then((pictureInPictureWindow) => {
pictureInPictureWindow.onresize = printPipWindowDimensions;
});
};
{{Specifications}}
{{Compat}}