MediaTrackSupportedConstraints: sampleSize 屬性
MediaTrackSupportedConstraints 字典的 sampleSize 屬性是一個只讀的布林值。當且僅當 使用者代理 支援 sampleSize 約束時,該屬性會出現在由 MediaDevices.getSupportedConstraints() 返回的物件中(並設定為 true)。如果該約束不受支援,則不會包含在列表中,因此該值永遠不會是 false。
您可以透過呼叫 navigator.mediaDevices.getSupportedConstraints() 來訪問支援的約束字典。
值
如果使用者代理支援 sampleSize 約束,則該屬性會出現在字典中(其值始終為 true)。如果該屬性不存在,則表示該屬性從支援的約束字典中缺失,如果您嘗試檢視其值,將得到 undefined。
示例
js
const result = document.getElementById("result");
const supported = navigator.mediaDevices.getSupportedConstraints().sampleSize;
result.textContent = supported ? "Supported!" : "Not supported!";
結果
規範
| 規範 |
|---|
| 媒體捕獲和流 # dom-mediatrackconstraintset-samplesize |
瀏覽器相容性
載入中…