The MediaCapabilities.decodingInfo() method, part of the Media Capabilities API, returns a promise with the tested media configuration's capabilities info. This contains the three boolean properties supported, smooth, and powerefficient, which describe whether decoding the media described would be supported, smooth, and powerefficient.
decodingInfo(configuration)
A Promise fulfilling with an object containing three Boolean attributes:
supported -
true if the media content can be decoded at all. Otherwise, it is false.
smooth -
true if playback of the media will be smooth (of high quality). Otherwise it is false.
powerEfficient -
true if playback of the media will be power efficient. Otherwise, it is 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.
This example shows how to create a media configuration for an audio file and then use it in MediaCapabilities.decodingInfo().
const mediaConfig = {
type: "file",
audio: {
contentType: "audio/ogg; codecs=vorbis",
channels: 2,
bitrate: 132700,
samplerate: 5200,
},
};
navigator.mediaCapabilities.decodingInfo(mediaConfig).then((result) => {
console.log(
`This configuration is ${result.supported ? "" : "not "}supported,`,
);
console.log(`${result.smooth ? "" : "not "}smooth, and`);
console.log(`${result.powerEfficient ? "" : "not "}power efficient.`);
});
Similarly, the code below shows the configuration for a video file.
const mediaConfig = {
type: "file",
video: {
contentType: "video/webm;codecs=vp8",
width: 800,
height: 600,
bitrate: 10000,
framerate: 30,
},
};