MediaSession.setCameraActive()
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Experimental: これは実験的な機能です。
本番で使用する前にブラウザー互換性一覧表をチェックしてください。
MediaSession
の setCameraActive()
メソッドは、 ユーザーエージェントに対して、ユーザーのカメラがアクティブであると考えられるかどうかを示すために使用します。
このメソッドは navigator
オブジェクトの mediaSession
オブジェクトに対して呼び出してください。
なお、カメラの状態は MediaSession
自体では追跡されず、別個の追跡が必要です。
構文
js
setCameraActive(active)
引数
active
-
カメラがアクティブとみなされるかどうかを示す論理値です。
返値
なし (undefined
)。
例
下記は、現在の MediaSession
のカメラアクティブ状態を更新し、setActionHandler()
でカメラ状態を変更するリクエストを待ち受けする例です。
js
let cameraActive = false;
navigator.mediaSession.setCameraActive(cameraActive);
navigator.mediaSession.setActionHandler("togglecamera", () => {
cameraActive = !cameraActive;
navigator.mediaSession.setCameraActive(cameraActive);
});
仕様書
Specification |
---|
Media Session # dom-mediasession-setcameraactive |
ブラウザーの互換性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
setCameraActive() |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- In development. Supported in a pre-release version.
- In development. Supported in a pre-release version.
- No support
- No support
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.