HTMLVideoElement: leavepictureinpicture イベント
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
leavepictureinpicture
イベントは、HTMLVideoElement
がピクチャインピクチャモードを終了することに成功した場合に発行されます。
このイベントはキャンセル不可で、バブリングしません。
構文
このイベント名を addEventListener()
などのメソッドで使用するか、イベントハンドラープロパティを設定するかしてください。
js
addEventListener("leavepictureinpicture", (event) => {});
onleavepictureinpicture = (event) => {};
イベント型
PictureInPictureEvent
です。Event
を継承しています。
イベントプロパティ
このインターフェイスには、親である Event
から継承したプロパティもあります。
例
この例は HTMLVideoElement の leavepictureinpicture
イベントのイベントリスナーを追加し、イベントハンドラーがイベントの発行に反応したときにメッセージを投稿します。
addEventListener()
を使用した場合:
js
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 = () => {
if (document.pictureInPictureElement) {
document.exitPictureInPicture();
}
};
onleavepictureinpicture
イベントハンドラープロパティを使用した場合:
js
const video = document.querySelector("#video");
const button = document.querySelector("#button");
function onExitPip() {
console.log("Picture-in-Picture mode deactivated!");
}
video.onleavepictureinpicture = onExitPip;
button.onclick = () => {
if (document.pictureInPictureElement) {
document.exitPictureInPicture();
}
};
仕様書
Specification |
---|
Picture-in-Picture # eventdef-htmlvideoelement-leavepictureinpicture |
Picture-in-Picture # dom-htmlvideoelement-onleavepictureinpicture |
ブラウザーの互換性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
leavepictureinpicture event |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- No support
- No support
- See implementation notes.
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.