The leavepictureinpicture
event is fired when the HTMLVideoElement
leaves picture-in-picture mode successfully.
Bubbles | No |
Cancelable | No |
Interface | PictureInPictureEvent
|
Target | HTMLVideoElement
|
Default Action | None |
Event handler property | HTMLVideoElement.onleavepictureinpicture
|
Examples
These examples add an event listener for the HTMLVideoElement's leavepictureinpicture
event, then post a message when that event handler has reacted to the event firing.
Using addEventListener()
:
const video = document.querySelector('#video');
const button = document.querySelector('#button');
function onExitPip() {
console.log("Picture-in-Picture mode deactivated!");
}
video.addEventListener("leavepictureinpicture", onExitPip, false);
button.onclick = function() => {
if (document.pictureInPictureElement) {
document.exitPictureInPicture();
}
}
Using the onleavepictureinpicture
event handler property:
const video = document.querySelector('#video');
const button = document.querySelector('#button');
function onExitPip() {
console.log("Picture-in-Picture mode deactivated!");
}
video.onleavepictureinpicture = onExitPip;
button.onclick = function() => {
if (document.pictureInPictureElement) {
document.exitPictureInPicture();
}
}
Specifications
Specification | Status |
UnknownThe definition of 'leavepictureinpicture event' in that specification. | Unknown |
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.leavepictureinpicture_event" (depth: 1) to the MDN compatibility data repository.
See Also
HTMLVideoElement: leavepictureinpicture event by Mozilla Contributors is licensed under CC-BY-SA 2.5.