The HTMLVideoElement
method requestPictureInPicture()
issues an asynchronous request to display the video in picture-in-picture mode.
It's not guaranteed that the video will be put into picture-in-picture. If permission to enter that mode is granted, the returned Promise
will resolve and the video will receive a enterpictureinpicture
event to let it know that it's now in picture-in-picture.
Syntax
videoElement.requestPictureInPicture();
Return value
A Promise
that will resolve to a PictureInPictureWindow
object. that can be used to listen when a user will resize that floating window.
Examples
This example requests that the video enters Picture-in-Picture mode, and sets an event listener to handle the floating window resizing.
function enterPictureInPicture() {
videoElement.requestPictureInPicture()
.then(pictureInPictureWindow => {
pictureInPictureWindow.addEventListener("resize", () => onPipWindowResize(), false);
})
}
Specifications
Specification | Status | Comment |
UnknownThe definition of 'HTMLVideoElement.requestPictureInPicture()' in that specification. | Unknown | Initial definition. |
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.HTMLVideoElement.requestPictureInPicture" (depth: 1) to the MDN compatibility data repository.
See also
- The
<video>
element HTMLVideoElement.autoPictureInPicture
HTMLVideoElement.disablePictureInPicture
Document.pictureInPictureEnabled
Document.exitPictureInPicture()
DocumentOrShadowRoot.pictureInPictureElement
:picture-in-picture
HTMLVideoElement.requestPictureInPicture() by Mozilla Contributors is licensed under CC-BY-SA 2.5.