MediaDevices: getSupportedConstraints() メソッド

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2017.

安全なコンテキスト用: この機能は一部またはすべての対応しているブラウザーにおいて、安全なコンテキスト (HTTPS) でのみ利用できます。

getSupportedConstraints()MediaDevices インターフェイスのメソッドで、 MediaTrackSupportedConstraints 辞書に基づくオブジェクトを返却し、そのそれぞれのメンバーフィールドは、ユーザーエージェントが理解する制約可能なプロパティの 1 つを指定します。

構文

js
getSupportedConstraints()

引数

なし。

返値

MediaTrackSupportedConstraints 辞書に基づく新しいオブジェクトです。このオブジェクトはユーザーエージェントが扱うことができるメディア制約の一覧を含みます。 この一覧に含まれているものは、ユーザーエージェントが取り扱えるものだけなので、全ての論理型のプロパティは true の値になっています。

この例は、実行中のブラウザーで対応している制約の一覧を出力するものです。

js
const constraintList = document.querySelector("#constraintList");
const supportedConstraints = navigator.mediaDevices.getSupportedConstraints();

for (const constraint of Object.keys(supportedConstraints)) {
  const elem = document.createElement("li");
  elem.appendChild(document.createElement("code")).textContent = constraint;
  constraintList.appendChild(elem);
}

結果

仕様書

Specification
Media Capture and Streams
# dom-mediadevices-getsupportedconstraints

ブラウザーの互換性

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
getSupportedConstraints

Legend

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

Full support
Full support