MediaCapabilitiesInfo

翻译不完整。 请帮助我们翻译这篇文章!

 Media Capabilities APIMediaCapabilitiesInfo 接口在 MediaCapabilities接口的  MediaCapabilities.encodingInfo() 或 MediaCapabilities.decodingInfo() 方法返回的 promise 完成时变得可用。它提供了媒体类型是否支持,在编码或解码此媒体时是否流畅和能效等信息。

属性

 MediaCapabilitiesInfo 接口包含3个布尔属性:

  • supported: 给出 MediaConfiguration 中定义的属性,确定指定的媒体内容能否完全被 编码 (如果 MediaEncodingConfiguration 已设置) 或 解码 (如果 MediaDecodingConfiguration 已设置) 。 如果是, supported 为 true. 否则为 false.
  • smooth: 给出 MediaConfiguration 中定义的属性, 确定指定的媒体内容在回放时能否高质量和流畅。 如果 supported 为 true, 并且回放时将流畅, smooth 为 true, 否则为 false.
  • powerEfficient: 给出 MediaConfiguration 中定义的属性,确定指定的媒体内容在回放时能否高能效。如果 supported 为 true, 并且回放时将高能效, powerEfficient 为 true, 否则为 false.

浏览器将报告一个支持的媒体配置为 smooth 和 powerEfficient 直到此设备的统计信息被记录. 所有受支持的音频编解码器将报告为高能效。

范例

// 测试的 MediaConfiguration
const mediaConfig = {
    type : 'file', 
    audio : {
        contentType : "audio/ogg",
        channels : 2,   
        bitrate : 132700, 
        samplerate : 5200 
     }, 
}; 

// 检查支持和性能 
navigator.mediaCapabilities.decodingInfo(mediaConfig).then(result => { // result 包含媒体兼容信息
    console.log('This configuration is ' +                     
        (result.supported ? '' : 'not ') + 'supported, ' +             // 配置的媒体能否被用户代理解码?
        (result.smooth ? '' : 'not ') + 'smooth, and ' +               // 是否流畅?
        (result.powerEfficient ? '' : 'not ') + 'power efficient.').   // 是否高能效?
});

规范

规范 状态 注释
Media Capabilities
MediaCapabilitiesInfo
Draft 初始定义

浏览器兼容性

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
MediaCapabilitiesInfo
Experimental
Chrome Full support 66Edge Full support ≤79Firefox Full support 63IE ? Opera ? Safari ? WebView Android Full support 66Chrome Android Full support 66Firefox Android Full support 63Opera Android ? Safari iOS ? Samsung Internet Android Full support 9.0
powerEfficient
Experimental
Chrome Full support 66Edge Full support ≤79Firefox Full support 63IE ? Opera ? Safari ? WebView Android Full support 66Chrome Android Full support 66Firefox Android Full support 63Opera Android ? Safari iOS ? Samsung Internet Android Full support 9.0
smooth
Experimental
Chrome Full support 66Edge Full support ≤79Firefox Full support 63IE ? Opera ? Safari ? WebView Android Full support 66Chrome Android Full support 66Firefox Android Full support 63Opera Android ? Safari iOS ? Samsung Internet Android Full support 9.0
supported
Experimental
Chrome Full support 66Edge Full support ≤79Firefox Full support 63IE ? Opera ? Safari ? WebView Android Full support 66Chrome Android Full support 66Firefox Android Full support 63Opera Android ? Safari iOS ? Samsung Internet Android Full support 9.0

Legend

Full support  
Full support
Compatibility unknown  
Compatibility unknown
Experimental. Expect behavior to change in the future.
Experimental. Expect behavior to change in the future.

参考