Amazon Developer

as

Settings
Sign out
Notifications
Alexa
Amazon Appstore
Ring
AWS
Documentation
Support
Contact Us
My Cases
Get Started
Design and Develop
Publish
Reference
Support
Skip to main content
This represents a media key session. For more information, see https://www.w3.org/TR/encrypted-media/#mediakeysession-interface.

Extends

Properties

sessionId

readonly sessionId: string The Session ID for this object and the associated key(s) or license(s). For more information, see https://www.w3.org/TR/encrypted-media/#dom-mediakeysession-sessionid.

expiration

readonly expiration: number The expiration time for all key(s) in the session, or NaN if no such time exists or if the license explicitly never expires, as determined by the CDM. For more information, see https://www.w3.org/TR/encrypted-media/#dom-mediakeysession-expiration.

closed

readonly closed: Promise<void> | null Signals when the object becomes closed as a result of the Session Closed algorithm being run. For more information, see https://www.w3.org/TR/encrypted-media/#dom-mediakeysession-closed.

keyStatuses

readonly keyStatuses: MediaKeyStatusMap | null A reference to a read-only map of key IDs known to the session to the current status of the associated key. Each entry has a unique key ID. For more information, see https://www.w3.org/TR/encrypted-media/#dom-mediakeysession-keystatuses.

onkeystatuseschange

onkeystatuseschange: ((this: MediaKeySession, ev: Event) => any) | null Event handler for the “keystatuseschange” event. For more information, see https://www.w3.org/TR/encrypted-media/#dom-mediakeysession-onkeystatuseschange.

onmessage

onmessage: ((this: MediaKeySession, ev: MediaKeyMessageEvent) => any) | null Event handler for the “message” event. For more information, see https://www.w3.org/TR/encrypted-media/#dom-mediakeysession-onmessage.

Methods

generateRequest()

generateRequest(initDataType: string, initData: ArrayBuffer): Promise<void> Generates a license request based on the initData. A message of type “license-request” or “individualization-request” will always be queued if the algorithm succeeds and the promise is resolved. For more information, see https://www.w3.org/TR/encrypted-media/#dom-mediakeysession-generaterequest.

Parameters

initDataType
string The Initialization Data Type of the initData.
initData
ArrayBuffer Initialization Data.

Returns

Promise<void>

load()

load(sessionId: string): Promise<boolean> | null Loads the data stored for the specified session into this object. For more information, see https://www.w3.org/TR/encrypted-media/#dom-mediakeysession-load

Parameters

sessionId
string The Session ID of the session to load.

Returns

Promise<boolean> | null

update()

update(response: ArrayBuffer): Promise<void> Provides messages, including licenses, to the CDM. For more information, see https://www.w3.org/TR/encrypted-media/#dom-mediakeysession-update.

Parameters

response
ArrayBuffer A message to be provided to the CDM. Promise that will get fulfilled when method executes successfully. The contents are Key System-specific. It must not contain executable code.

Returns

Promise<void>

close()

close(): Promise<void> | null Indicates that the application no longer needs the session and the CDM should release any resources associated with the session and close it. Persisted data is not released or cleared. For more information, see https://www.w3.org/TR/encrypted-media/#dom-mediakeysession-close.

Returns

Promise<void> | null

remove()

remove(): Promise<void> | null Removes all license(s) and key(s) associated with the session. For persistent session types, other session data will be cleared as defined for each session type once a release message acknowledgment is processed by update(). For more information, see https://www.w3.org/TR/encrypted-media/#dom-mediakeysession-remove.

Returns

Promise<void> | null

addEventListener()

addEventListener(type: K, listener: (this: MediaKeySession, ev: MediaKeySessionEventMap[K]) => any | EventListener, options?: boolean | AddEventListenerOptions | undefined): void Adds an even listener.

Parameters

type
K Type of event.
listener
(this: MediaKeySession, ev: MediaKeySessionEventMap[K]) => any | EventListener Event handler.
options?
boolean | AddEventListenerOptions | undefined Ignored.

addEventListener()

addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions | undefined): void Adds an even listener.

Parameters

type
string Type of event.
listener
EventListener Event handler.
options?
boolean | AddEventListenerOptions | undefined Ignored.
Last modified on July 22, 2026