MediaCapabilitiesInfo - Web APIs 编辑

The MediaCapabilitiesInfo interface of the Media Capabilities API is made available when the promise returned by the MediaCapabilities.encodingInfo() or MediaCapabilities.decodingInfo() methods of the MediaCapabilities interface fulfills, providing information as to whether the media type is supported, and whether encoding or decoding such media would be smooth and power efficient.

Properties

The MediaCapabilitiesInfo interface contains three Boolean attribues:

  • supported: Given the properties defined in the MediaConfiguration, can the specified piece of media content be encoded (if MediaEncodingConfiguration is set) or decode (if MediaDecodingConfiguration is set) at all? If yes, supported is true. Otherwise, it is false.
  • smooth: Given the properties defined in the MediaConfiguration, will the playback of the specified piece of media be high quality? Will it be smooth?  If supported is true, and playback will be smooth, smooth is true, Otherwise, is it false.
  • powerEfficient: Given the properties defined in the MediaConfiguration, will the playback of the specified piece of media be power efficient? If supported is true, and playback will be power efficient, powerEfficient is true, Otherwise, is it false.

Browsers will report a supported media configuration as smooth and powerEfficient until stats on this device have been recorded. All supported audio codecs are reported to be power efficient.

Example

// MediaConfiguration to be tested
const mediaConfig = {
    type : 'file',
    audio : {
        contentType : "audio/ogg",
        channels : 2,
        bitrate : 132700,
        samplerate : 5200
     },
};

// check support and performance
navigator.mediaCapabilities.decodingInfo(mediaConfig).then(result => { // result contains the media capabilities information
    console.log('This configuration is ' +
        (result.supported ? '' : 'not ') + 'supported, ' +             // Can the media, as configured, be decoded by the user agent
        (result.smooth ? '' : 'not ') + 'smooth, and ' +               // is it smooth?
        (result.powerEfficient ? '' : 'not ') + 'power efficient.')    // is it power efficient?
});

Specifications

SpecificationStatusComment
Media Capabilities
The definition of 'MediaCapabilitiesInfo' in that specification.
DraftInitial definition

Browser compatibility

BCD tables only load in the browser

See also

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:111 次

字数:4701

最后编辑:7 年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文