Navigator:mediaCapabilities 属性

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since January 2020.

Navigator 接口的 Navigator.mediaCapabilities 只读属性返回一个 MediaCapabilities 对象,该对象可以暴露有关给定格式的解码和编码能力以及由媒体能力 API 定义的输出能力的信息。

一个 MediaCapabilities 对象。

示例

js
navigator.mediaCapabilities
  .decodingInfo({
    type: "file",
    audio: {
      contentType: "audio/mp3",
      channels: 2,
      bitrate: 132700,
      samplerate: 5200,
    },
  })
  .then((result) => {
    console.log(`${result.supported ? "" : "不"}支持此配置,`);
    console.log(`${result.smooth ? "" : "不"}流畅,`);
    console.log(`${result.powerEfficient ? "" : "不"}节能。`);
  });

规范

Specification
Media Capabilities
# dom-navigator-mediacapabilities

浏览器兼容性

BCD tables only load in the browser

参见