--- title: MediaTrackSupportedConstraints.sampleSize slug: Web/API/MediaTrackSupportedConstraints/sampleSize translation_of: Web/API/MediaTrackSupportedConstraints/sampleSize ---
{{APIRef("Media Capture and Streams")}}
MediaTrackSupportedConstraintsディクショナリーのsampleSizeプロパティは読み取り専用のBooleanの値です。user agentがsampleSizeの制約をサポートしている場合、MediaDevices.getSupportedConstraints()の戻り値のオブジェクトに含まれtrueが設定されます。この制約がサポートされない場合は含まれないため、falseになることはありません。
サポートされている制約のディクショナリーはnavigator.mediaDevices.getSupportedConstraints()を呼び出すことで取得できます。
sampleSizeConstraintSupported = supportedConstraintsDictionary["sampleSize"];
ユーザエージェントsampleSizeの制約をサポートしている場合、このプロパティはディクショナリーの中に含まれ、その値は常にtrueの値です。このプロパティが存在しない場合は、サポートされている制約ディクショナリーには存在しないため、undefinedの値を取ることになります。
<div id="result"> </div>
#result {
font: 14px "Arial", sans-serif;
}
let result = document.getElementById("result");
if (navigator.mediaDevices.getSupportedConstraints()["sampleSize"]) {
result.innerHTML = "Supported!";
} else {
result.innerHTML = "Not supported!";
}
{{ EmbedLiveSample('Example', 600, 80) }}
| 仕様 | 状況 | コメント |
|---|---|---|
| {{ SpecName('Media Capture', '#widl-MediaTrackSupportedConstraints-sampleSize', 'sampleSize') }} | {{ Spec2('Media Capture') }} | 初版 |
{{Compat("api.MediaTrackSupportedConstraints.sampleSize")}}