Document: pictureInPictureEnabled プロパティ

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

pictureInPictureEnabledDocument インターフェイスの読み取り専用プロパティで、ピクチャインピクチャモードが利用できるかどうかを示します。

ピクチャインピクチャモードは、権限ポリシーで指定されていない限り、既定では利用できます。

このプロパティは読み取り専用ですが、変更しても例外は発生しません(厳格モードであっても)。セッターは何もせず、無視されます。

論理値で、 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 GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
pictureInPictureEnabled

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
See implementation notes.

関連情報