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 |
浏览器兼容性
加载中…