Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. Navigator
  4. requestMediaKeySystemAccess()

Navigator: requestMediaKeySystemAccess() method

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨March 2019⁩.

Secure context: This feature is available only insecure contexts (HTTPS), in some or allsupporting browsers.

TherequestMediaKeySystemAccess() method of theNavigator interface returns aPromise which delivers aMediaKeySystemAccess object that can be used to access a particular media key system, which can in turn be used to create keys for decrypting a media stream.

This method is part of theEncrypted Media Extensions API, which brings support for encrypted media and DRM-protected video to the web.

This method may have user-visible effects such as asking for permission to access one or more system resources.Consider that when deciding when to callrequestMediaKeySystemAccess(); you don't want those requests to happen at inconvenient times.As a general rule, this function should be called only when it's about time to create and use aMediaKeys object by calling the returnedMediaKeySystemAccess object'screateMediaKeys() method.

Syntax

js
requestMediaKeySystemAccess(keySystem, supportedConfigurations)

Parameters

keySystem

A string identifying the key system.For examplecom.example.some-system ororg.w3.clearkey.

supportedConfigurations

A non-emptyArray of objects conforming to the object returned byMediaKeySystemAccess.getConfiguration.The first element with a satisfiable configuration will be used.

Each object may have the following properties:

Note:EithervideoCapabilities oraudioCapabilities may be empty, but not both!

labelOptional

An optional label for the configuration, which defaults to"".This label is preserved for configurations fetched usingMediaKeySystemAccess.getConfiguration

initDataTypes

An array of strings that indicate the data type names for the supported initialization data formats (default to an empty array).These names are names like"cenc","keyids" and"webm" that are defined in theEncrypted Media Extensions Initialization Data Format Registry.

audioCapabilities

An array of supported audio capabilities.If the array is empty the content type does not support audio capabilities.

Each object in the array has the following properties:

contentType

A string indicating the media MIME-type of the media resource, such as"audio/mp4;codecs=\"mp4a.40.2\".Note that the empty string is invalid, and that if the MIME-type definition includes parameters, such ascodecs, these must also be included.

encryptionScheme

The encryption scheme associated with the content type, such ascenc,cbcs,cbcs-1-9.This value should be set by an application (it defaults tonull, indicating that any encryption scheme may be used).

robustness

The robustness level associated with the content type.The empty string indicates that any ability to decrypt and decode the content type is acceptable.

videoCapabilities

An array of supported video capabilities.The objects in the array have the same form as those inaudioCapabilities.

distinctiveIdentifier

A string indicating whether the implementation may use "distinctive identifiers" (or distinctive permanent identifiers) for any operations associated with any object created from this configuration.The allowed values are:

required

The returned object must support this feature.

optional

The returned object may support this feature.This is the default

not-allowed

The returned object must not support or use this feature.

persistentState

A string indicating whether the returned object must be able to persist session data or any other type of state.The values are the same as fordistinctiveIdentifier and have the same meaning:required,optional (default),not-allowed.Only "temporary" sessions may be created when persistent state is not allowed.

sessionTypes

An array of strings indicating the session types that must be supported.Permitted values include:

temporary

A session for which the license, key(s) and record of or data related to the session are not persisted.The application does not need to manage such storage.Implementations must support this option, and it is the default.

persistent-license

A session for which the license (and potentially other data related to the session) will be persisted.A record of the license and associated keys persists even if the license is destroyed, providing an attestation that the license and key(s) it contains are no longer usable by the client.

Return value

APromise that fulfils with aMediaKeySystemAccess object representing the media key system configuration described bykeySystem andsupportedConfigurations.

Exceptions

In case of an error, the returnedPromise is rejected with aDOMException whose name indicates what kind of error occurred.

NotSupportedErrorDOMException

Either the specifiedkeySystem isn't supported by the platform or the browser, or none of the configurations specified bysupportedConfigurations can be satisfied (if, for example, none of thecodecs specified incontentType are available).

SecurityErrorDOMException

Use of this feature was blocked byPermissions-Policy: encrypted-media.

TypeError

EitherkeySystem is an empty string or thesupportedConfigurations array is empty.

Examples

The example below shows how you might userequestMediaKeySystemAccess(), specifying a key system and configuration.

js
const clearKeyOptions = [  {    initDataTypes: ["keyids", "webm"],    audioCapabilities: [      { contentType: 'audio/webm; codecs="opus"' },      { contentType: 'audio/webm; codecs="vorbis"' },    ],    videoCapabilities: [      { contentType: 'video/webm; codecs="vp9"' },      { contentType: 'video/webm; codecs="vp8"' },    ],  },];navigator  .requestMediaKeySystemAccess("org.w3.clearkey", clearKeyOptions)  .then((keySystemAccess) => {    /* use the access to get create keys */  });

Specifications

Specification
Encrypted Media Extensions
# navigator-extension-requestmediakeysystemaccess

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp