Document: pictureInPictureEnabled プロパティ
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
pictureInPictureEnabled
は Document
インターフェイスの読み取り専用プロパティで、ピクチャインピクチャモードが利用できるかどうかを示します。
ピクチャインピクチャモードは、権限ポリシーで指定されていない限り、既定では利用できます。
このプロパティは読み取り専用ですが、変更しても例外は発生しません(厳格モードであっても)。セッターは何もせず、無視されます。
値
論理値で、 true
の場合は HTMLVideoElement.requestPictureInPicture()
を呼び出すことで、動画がピクチャインピクチャに入り、浮動動画ウィンドウに表示できます。ピクチャインピクチャモードが利用できない場合、この値は false
です。
例
この例では、 <video>
要素に対してピクチャインピクチャモードに入ろうとする前に pictureInPictureEnabled
の値を調べ、機能が利用できない場合に呼び出さないようにしています。
js
function requestPictureInPicture() {
if (document.pictureInPictureEnabled) {
videoElement.requestPictureInPicture();
} else {
console.log(
"お使いのブラウザーでは、ピクチャインピクチャを使用することができません。",
);
}
}
仕様書
Specification |
---|
Picture-in-Picture # ref-for-dom-document-pictureinpictureenabled |
ブラウザーの互換性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
pictureInPictureEnabled |
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.