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. |
草案 | 初始定义 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
encodingInfo
|
Chrome
67
Disabled
|
Edge
≤79
Disabled
|
Firefox 63 | IE ? | Opera ? | Safari ? | WebView Android No |
Chrome Android
67
Disabled
|
Firefox Android 63 | Opera Android ? | Safari iOS ? | Samsung Internet Android No |
完整支持
不支持
兼容性未知
实验。期望将来行为有所改变。
用户必须明确启用此特征。
MediaCapabilities
decodingInfo()
encodingInfo()