MediaTrackSupportedConstraints: aspectRatio 属性
MediaTrackSupportedConstraints 字典的 aspectRatio 属性是一个只读的布尔值。当 MediaDevices.getSupportedConstraints() 返回的对象中包含此属性(并且其值为 true)时,表示 用户代理 支持 aspectRatio 约束。如果不支持该约束,它将不会包含在列表中,因此此值永远不会是 false。
您可以通过调用 navigator.mediaDevices.getSupportedConstraints() 来访问支持的约束字典。
值
如果用户代理支持 aspectRatio 约束,则该属性会存在于字典中(并且其值始终为 true)。如果该属性不存在,则表示它缺少于支持的约束字典中,如果您尝试查看其值,将得到 undefined。
示例
js
const result = document.getElementById("result");
const supported = navigator.mediaDevices.getSupportedConstraints().aspectRatio;
result.textContent = supported ? "Supported!" : "Not supported!";
结果
规范
| 规范 |
|---|
| 媒体捕获和流 # dom-mediatrackconstraintset-aspectratio |
浏览器兼容性
加载中…