Extends
Properties
closed
readonly closed: Promise<void>
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.
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.
keyStatuses
readonly keyStatuses: MediaKeyStatusMap
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, ev) => any
Event handler for the “keystatuseschange” event.
For more information, see
https://www.w3.org/TR/encrypted-media/#dom-mediakeysession-onkeystatuseschange.
Parameters
this
MediaKeySession
ev
Event
Returns
any
onmessage()
onmessage: (this, ev) => any
Event handler for the “message” event.
For more information, see
https://www.w3.org/TR/encrypted-media/#dom-mediakeysession-onmessage.
Parameters
this
MediaKeySession
ev
MediaKeyMessageEvent
Returns
any
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.
Methods
addEventListener()
Call Signature
addEventListener<K>(type, listener, options?): void
Adds an even listener.
Type Parameters
• K extends keyofMediaKeySessionEventMap
Parameters
type
K
Type of event.
listener
(this, ev) => any
Event handler.
options?
Ignored.Returns
void
Overrides
EventTarget.addEventListener
Call Signature
addEventListener(type, listener, options?): void
Adds an even listener.
Parameters
type
string
Type of event.
listener
EventListener
Event handler.
options?
Ignored.Returns
void
Overrides
EventTarget.addEventListener
close()
close():Promise<void>
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>
dispatchEvent()?
optional dispatchEvent(event): boolean
Dispatches an event to the target
Parameters
event
Event
The event which signals an occurrenceo.
Returns
boolean
TODO
Add and define in the implementations, keep it optional for now.Inherited from
EventTarget.dispatchEvent
generateRequest()
generateRequest(initDataType, initData): 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): Promise<boolean>
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>
remove()
remove():Promise<void>
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>
removeEventListener()
removeEventListener(type, listener, options?): void
Removes an event listener.
Parameters
type
string
The event to listen to.
listener
EventListener
The Event Handler function to be removed.
options?
Ignore.Returns
void
Inherited from
EventTarget.removeEventListener
update()
update(response): 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.
Returns
Promise<void>
Promise that will get fulfilled when method executes successfully.
The contents are Key System-specific. It must not contain executable code.

