MediaDevices:getSupportedConstraints() 方法
getSupportedConstraints() 是 MediaDevices 介面的一個方法。它返回一個基於 MediaTrackSupportedConstraints 字典的物件,該物件的成員欄位分別指定了 使用者代理 理解的約束屬性。
語法
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);
}
結果
規範
| 規範 |
|---|
| 媒體捕獲和流 # dom-mediadevices-getsupportedconstraints |
瀏覽器相容性
載入中…