HTMLVideoElement: requestPictureInPicture() method

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

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 an enterpictureinpicture event to let it know that it's now in picture-in-picture.

Syntax

js
requestPictureInPicture()

Parameters

None.

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.

Exceptions

NotSupportedError DOMException

Thrown if the feature is not supported (for example, disabled by a user preference or by a platform limitation).

SecurityError DOMException

Thrown if the feature is blocked by a Permissions Policy.

InvalidStateError DOMException

Thrown if the video element's readState is HAVE_NOTHING, or if the video element has no video track, or if the video element's disablePictureInPicture attribute is true.

NotAllowedError DOMException

Thrown if document.pictureInPictureElement is null and the document does not have transient activation.

Security

Transient user activation is required. The user has to interact with the page or a UI element for this feature to work.

Examples

This example requests that the video enters Picture-in-Picture mode, and sets an event listener to handle the floating window resizing.

js
function enterPictureInPicture() {
  videoElement.requestPictureInPicture().then((pictureInPictureWindow) => {
    pictureInPictureWindow.addEventListener("resize", () =>
      onPipWindowResize(),
    );
  });
}

Specifications

Specification
Picture-in-Picture
# request-pip

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
requestPictureInPicture
Chrome – Full support
Chrome 69 (Release date: 2018-09-04)
footnote Full support
Edge – Full support
Edge 79 (Release date: 2020-01-15)
footnote Full support
Firefox – No support
Firefox
footnote
footnote See bug 1463402
Opera – Full support
Opera 56 (Release date: 2018-09-25)
footnote Full support
Safari – Full support
Safari 13.1 (Release date: 2020-03-24)
footnote Full support
Chrome Android – Full support
Chrome Android 105 (Release date: 2022-09-02)
footnote Full support
Firefox for Android – No support
Firefox for Android
footnote
footnote See bug 1463402
Opera Android – Full support
Opera Android 72 (Release date: 2022-10-21)
footnote Full support
Safari on iOS – Full support
Safari on iOS 13.4 (Release date: 2020-03-24)
footnote Full support
Samsung Internet – Full support
Samsung Internet 20 (Release date: 2023-02-10)
footnote Full support
WebView Android – No support
WebView Android
footnote No support
WebView on iOS – Full support
WebView on iOS 13.4 (Release date: 2020-03-24)
footnote Full support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
See implementation notes.

See also