Table of Contents

Class MediaKeys

Namespace
CSharpToJavaScript.APIs.JS
Assembly
CSharpToJavaScript.dll

The MediaKeys interface of Encrypted Media Extensions API represents a set of keys that an associated HTMLMediaElement can use for decryption of media data during playback.

[Value("MediaKeys")]
public class MediaKeys
Inheritance
MediaKeys
Inherited Members

Remarks

Constructors

MediaKeys()

public MediaKeys()

Methods

CreateSession(MediaKeySessionType)

The createSession() method of the MediaKeys interface returns a new MediaKeySession object, which represents a context for message exchange with a content decryption module (CDM).

[Value("createSession")]
public MediaKeySession CreateSession(MediaKeySessionType sessionType = MediaKeySessionType.Temporary)

Parameters

sessionType MediaKeySessionType

Returns

MediaKeySession

A new MediaKeySession object.

Remarks

GetStatusForPolicy(MediaKeysPolicy)

The getStatusForPolicy() method of the MediaKeys interface is used to check whether the Content Decryption Module (CDM) would allow the presentation of encrypted media data using the keys, based on the specified policy requirements.

[Value("getStatusForPolicy")]
public Task<MediaKeyStatus> GetStatusForPolicy(MediaKeysPolicy policy = null)

Parameters

policy MediaKeysPolicy

Returns

Task<MediaKeyStatus>

A Promise that resolves with a string indicating whether the key can be used for decryption given the specified policy.The string can have one of the following values:

Remarks

The method returns a Promise that resolves with a string that indicates the status of the key with respect to all the specified policy requirements.
If the value resolves to &quot;usable&quot; then the content can be decrypted and presented at the ideal quality.
Other values indicate reasons why the keys cannot be used for presenting the content; in some cases they hint at fallback options, such as playing the content at a lower quality.

The policy restrictions currently only include a restriction on the minimum supported HDCP version.

Note that the method checks a &quot;hypothetical key&quot; against the restrictions.
The application does not need to first create a real key and fetch a real license using MediaKeySession, and the MediaKeys doesn't even have to be attached to audio or video elements.

See also on MDN

SetServerCertificate(Union224)

The setServerCertificate() method of the MediaKeys interface provides a server certificate to be used to encrypt messages to the license server.

[Value("setServerCertificate")]
public Task<bool> SetServerCertificate(Union224 serverCertificate)

Parameters

serverCertificate Union224

Returns

Task<bool>

A 'Promise' that resolves to a boolean. If the Key System implementation represented by this object's content decryption module's implementation value does not support server certificates, return a promise resolved with false.

Remarks