Document.exitPictureInPicture()

The Document method exitPictureInPicture() requests that a video contained in this document, which is currently floating, be taken out of picture-in-picture mode, restoring the previous state of the screen. This usually reverses the effects of a previous call to HTMLVideoElement.requestPictureInPicture().

Syntax

exitPromise = document.exitPictureInPicture();

Parameters

None.

Return value

A Promise, which is resolved once the user agent has finished exiting picture-in-picture mode. If an error occurs while attempting to exit full-screen mode, the catch() handler for the promise is called.

Examples

This example causes the current document to exit picture-in-picture mode whenever the mouse button is clicked within it.

document.onclick = function (event) {
  if (document.pictureInPictureElement) {
    document.exitPictureInPicture()
      .then(() => console.log("Document Exited from Picture-in-Picture mode"))
      .catch((err) => console.error(err))
  } else {
    video.requestPictureInPicture();
  }
}

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
exitPictureInPicture
69
79
No
No
56
13.1
No
No
No
No
13.4
No

See also

© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/Document/exitPictureInPicture