document.exitPictureInPicture() asks the browser to take the document’s floating Picture-in-Picture video out of PiP and restore it to the page. It usually reverses HTMLVideoElement.requestPictureInPicture().
Pass the required arguments shown below. Check return values and browser support before you rely on the result.
Syntax
Call document.exitPictureInPicture. Start with this line.
JavaScript
document.exitPictureInPicture()
Call
What it does
document.exitPictureInPicture()
Primary signature.
document.exitPictureInPicture(...)
Call with the arguments your case needs.
Built into the browser. Call exitPictureInPicture(...) on document — no import required.
Library declarations
JavaScript
document.exitPictureInPicture()
Parameters
This member has no parameters beyond those shown in the signature.
Return Value
Return Value
Description
*
Promise that resolves when exit finishes
JavaScript Examples
Example 1 — Exit Only When Active
Check pictureInPictureElement before calling exit (MDN-safe pattern).
JavaScript
async function leavePiP() {
if (!document.pictureInPictureElement) {
console.log("Not in Picture-in-Picture");
return;
}
try {
await document.exitPictureInPicture();
console.log("Document Exited from Picture-in-Picture mode");
} catch (err) {
console.log("Exit failed:", err.name);
}
}
true
true
true
null
(values depend on the browser and permissions policy)
How It Works
Check exit. Missing function → hide the “Exit PiP” control.
Check enter. Exit is useless without requestPictureInPicture.
Read enabled. Policy may disable PiP even if methods exist.
Read element.null means nothing is currently floating.
Compatibility
Browser Support
Document.exitPictureInPicture() is part of the Picture-in-Picture API. MDN marks it Limited availability (not Baseline). Feature-detect before production use.
✓ Limited availability
Document.exitPictureInPicture()
Supported in modern Chromium, Firefox, and Safari with varying policy rules. Always check document.exitPictureInPicture and pictureInPictureEnabled.
It requests that a video currently floating in picture-in-picture mode leave PiP and return to the page. It usually reverses HTMLVideoElement.requestPictureInPicture().
No. MDN does not mark Document.exitPictureInPicture() as Deprecated, Experimental, or Non-standard. It is Limited availability (not Baseline), so feature-detect in production.
A Promise that resolves when the browser has finished exiting picture-in-picture mode. On failure, handle the rejection with catch().
An InvalidStateError is thrown (promise rejects) if document.pictureInPictureElement is null. Always check pictureInPictureElement before calling exitPictureInPicture().
Call video.requestPictureInPicture() on an HTMLVideoElement, usually from a user gesture. Check document.pictureInPictureEnabled first.
Listen for enterpictureinpicture and leavepictureinpicture on the video, or compare document.pictureInPictureElement to your video element.