MediaTrackSupportedConstraints:latency 屬性

可用性有限

此特性不是基線特性,因為它在一些最廣泛使用的瀏覽器中不起作用。

MediaTrackSupportedConstraints 字典中的 latency 屬性是一個只讀布林值。如果 使用者代理 支援 latency 約束,則在 MediaDevices.getSupportedConstraints() 返回的物件中,該屬性會存在(且設定為 true)。如果該約束不受支援,則它不會包含在列表中,因此此值永遠不會是 false

您可以透過呼叫 navigator.mediaDevices.getSupportedConstraints() 來訪問支援的約束字典。

如果使用者代理支援 latency 約束,則該屬性會出現在字典中(且其值始終為 true)。如果該屬性不存在,則表示它在支援的約束字典中缺失,如果您嘗試檢視其值,將得到 undefined

示例

js
const result = document.getElementById("result");
const supported = navigator.mediaDevices.getSupportedConstraints().latency;
result.textContent = supported ? "Supported!" : "Not supported!";

結果

規範

規範
媒體捕獲和流
# dom-mediatrackconstraintset-latency

瀏覽器相容性

另見