The leavepictureinpicture
event is fired when the HTMLVideoElement
leaves picture-in-picture mode successfully.
This event is not cancelable and does not bubble.
The leavepictureinpicture
event is fired when the HTMLVideoElement
leaves picture-in-picture mode successfully.
This event is not cancelable and does not bubble.
Use the event name in methods like addEventListener()
, or set an event handler property.
addEventListener('leavepictureinpicture', event => { }); onleavepictureinpicture = event => { };
An PictureInPictureEvent
. Inherits from Event
.
This interface also inherits properties from its parent Event
.
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(); } }
Specification |
---|
Picture-in-Picture # eventdef-htmlvideoelement-leavepictureinpicture |
Picture-in-Picture # dom-htmlvideoelement-onleavepictureinpicture |
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
leavepictureinpicture_event |
69
|
79
|
No
|
No
|
56
|
13.1
|
No
|
No
|
No
|
No
|
13.4
|
No
|
© 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/HTMLVideoElement/leavepictureinpicture_event