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