MediaCapabilities Class
Tells whether the user agent can decode or encode media with a configuration (https://w3c.github.io/media-capabilities/, navigator.mediaCapabilities). The library validates the configurations as the specification requires, and the backends of the browsing context answer the support:
file:MediaBackend.CanPlayTypeofBrowsingContextOptions.MediaBackend(probablyfor a container with thecodecsparameter,maybeorprobablyfor a type of a single codec such asaudio/mpeg);media-source: the same answer, andMediaBackend.CreateSegmentParsercreates a parser;webrtc: the RTP payload formats (audio/opus,audio/PCMU,audio/PCMA,video/VP8,video/VP9,video/H264,video/AV1,video/H265) are converted to the WebCodecs configurations of their codec and checked byBrowsingContextOptions.MediaCodecs;record: whatMediaRecorderrecords, VP8 and Opus in WebM or Matroska, when the encoders ofBrowsingContextOptions.MediaCodecssupport the configuration.
Without a backend, nothing is supported. There is no performance model: a supported configuration is smooth, and not power efficient (the library cannot tell whether a backend uses hardware codecs). A colorGamut or a transferFunction must match the color space of a VP9 or AV1 codec string (BT.709 when the string does not give it), and a video with HDR metadata is not supported (the rendering is in sRGB). A configuration with a key system is checked by Encrypted Media Extensions (Clear Key): a supported one gets a MediaKeySystemAccess.
public sealed class MediaCapabilitiesMethods
| Name | Description |
|---|---|
| DecodingInfo(MediaDecodingConfiguration) | Returns whether the user agent can decode media with a configuration (https://w3c.github.io/media-capabilities/#dom-mediacapabilities-decodinginfo). |
| EncodingInfo(MediaEncodingConfiguration) | Returns whether the user agent can encode media with a configuration (https://w3c.github.io/media-capabilities/#dom-mediacapabilities-encodinginfo). |
DecodingInfo(MediaDecodingConfiguration)
MediaCapabilities.csReturns whether the user agent can decode media with a configuration (https://w3c.github.io/media-capabilities/#dom-mediacapabilities-decodinginfo).
public Task<MediaCapabilitiesDecodingInfo> DecodingInfo(MediaDecodingConfiguration configuration)Parameters
configurationMediaDecodingConfiguration- The configuration.
Returns
Task<MediaCapabilitiesDecodingInfo> A task that completes with the support, or fails with a TypeErrorException for an invalid configuration, or a DomException for a key system in a worker (InvalidStateError) or in a context that is not secure (SecurityError).
See also
EncodingInfo(MediaEncodingConfiguration)
MediaCapabilities.csReturns whether the user agent can encode media with a configuration (https://w3c.github.io/media-capabilities/#dom-mediacapabilities-encodinginfo).
public Task<MediaCapabilitiesEncodingInfo> EncodingInfo(MediaEncodingConfiguration configuration)Parameters
configurationMediaEncodingConfiguration- The configuration.
Returns
Task<MediaCapabilitiesEncodingInfo> A task that completes with the support, or fails with a TypeErrorException for an invalid configuration.