files/en-us/web/api/documentpictureinpicture/index.md
{{APIRef("Document Picture-in-Picture API")}}{{SeeCompatTable}}{{securecontext_header}}
The DocumentPictureInPicture interface of the {{domxref("Document Picture-in-Picture API", "Document Picture-in-Picture API", "", "nocode")}} is the entry point for creating and handling document picture-in-picture windows.
It is accessed via the {{domxref("Window.documentPictureInPicture")}} property.
{{InheritanceDiagram}}
Inherits properties from its parent, {{DOMxRef("EventTarget")}}.
Inherits methods from its parent, {{DOMxRef("EventTarget")}}.
Inherits events from its parent, {{DOMxRef("EventTarget")}}.
const videoPlayer = document.getElementById("player");
// …
// Open a Picture-in-Picture window.
const pipWindow = await window.documentPictureInPicture.requestWindow({
width: videoPlayer.clientWidth,
height: videoPlayer.clientHeight,
});
// …
See Document Picture-in-Picture API Example for a full working demo (see the full source code also).
{{Specifications}}
{{Compat}}