MediaTrackSupportedConstraints: echoCancellation 属性

Baseline 已广泛支持

此特性已相当成熟,可在许多设备和浏览器版本上使用。自 ⁨2020 年 1 月⁩ 起,所有主流浏览器均已支持。

MediaTrackSupportedConstraints 字典的 echoCancellation 属性是一个只读的布尔值。如果 用户代理 支持 echoCancellation 约束,则该属性会出现在由 MediaDevices.getSupportedConstraints() 返回的对象中(且值为 true)。如果不支持该约束,则它不会包含在列表中,因此此值永远不会是 false

您可以通过调用 navigator.mediaDevices.getSupportedConstraints() 来访问支持的约束字典。

如果用户代理支持 echoCancellation 约束,则此属性会出现在字典中(且其值始终为 true)。如果此属性不存在,则表示它在支持的约束字典中缺失,如果您尝试查看其值,将会得到 undefined

示例

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

结果

规范

规范
媒体捕获和流
# dom-mediatrackconstraintset-echocancellation

浏览器兼容性

另见