MediaCapabilities.encodingInfo() method, part of the MediaCapabilities 接口在 媒体能力 API , returns a promise with the tested media configuration's MediaCapabilitiesInfo ; this contains the three Boolean properties supported , smooth ,和 powerefficient , which describe how compatible the device is with the type of media.

句法

mediaCapabilities.encodingInfo(mediaEncodingConfiguration)
					

参数

mediaEncodingConfiguration
有效 MediaEncodingConfiguration dictionary containing a valid media encoding type of record or transmission and a valid media configuration: either an AudioConfiguration or VideoConfiguration 字典。

返回值

A Promise fulfilling with a MediaCapabilitiesInfo interface containing three Boolean attributes:

  • supported
  • smooth
  • powerEfficient

异常

A TypeError is raised if the MediaConfiguration passed to the encodingInfo() method is invalid, either because the type is not video or audio, the contentType is not a valid codec MIME type, or any other error in the media configuration passed to the method, including omitting any of the media encoding configuration 元素。

范例

//Create media configuration to be tested
const mediaConfig = {
    type : 'record', // or 'transmission'
    video : {
        contentType : "video/webm;codecs=vp8.0", // valid content type
        width : 1920,     // width of the video
        height : 1080,    // height of the video
        bitrate : 120000, // number of bits used to encode 1s of video
        framerate : 48   // number of frames making up that 1s.
     }
};
// check support and performance
navigator.mediaCapabilities.encodingInfo(mediaConfig).then(result => {
    console.log('This configuration is ' +
        (result.supported ? '' : 'not ') + 'supported, ' +
        (result.smooth ? '' : 'not ') + 'smooth, and ' +
        (result.powerEfficient ? '' : 'not ') + 'power efficient.')
});
					

规范

规范 状态 注释
Media Capabilities
The definition of 'encodingInfo()' in that specification.
草案 初始定义

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
encodingInfo Chrome 67 Disabled
67 Disabled
Disabled From version 67: this feature is behind the chrome://flags/#enable-experimental-web-platform-features preference (needs to be set to enabled ). To change preferences in Chrome, visit chrome://flags.
Edge ≤79 Disabled
≤79 Disabled
Disabled From version ≤79: this feature is behind the chrome://flags/#enable-experimental-web-platform-features preference (needs to be set to enabled ).
Firefox 63 IE ? Opera ? Safari ? WebView Android No Chrome Android 67 Disabled
67 Disabled
Disabled From version 67: this feature is behind the chrome://flags/#enable-experimental-web-platform-features preference (needs to be set to enabled ). To change preferences in Chrome, visit chrome://flags.
Firefox Android 63 Opera Android ? Safari iOS ? Samsung Internet Android No

图例

完整支持

完整支持

不支持

不支持

兼容性未知 ?

兼容性未知

实验。期望将来行为有所改变。

实验。期望将来行为有所改变。

用户必须明确启用此特征。

用户必须明确启用此特征。

另请参阅

元数据

  • 最后修改:
  1. MediaCapabilities
  2. 方法
    1. decodingInfo()
    2. encodingInfo()

版权所有  © 2014-2026 乐数软件    

工业和信息化部: 粤ICP备14079481号-1