Interface MediaKeySession
closed: Promise<MediaKeySessionClosedReason>;
expiration: number;
keyStatuses: MediaKeyStatusMap;
onkeystatuseschange: ((this: MediaKeySession, ev: Event) => any) | null;
onmessage:
| ((this: MediaKeySession, ev: MediaKeyMessageEvent) => any)
| null;
sessionId: string;
addEventListener<K extends keyof MediaKeySessionEventMap>(
type: K,
listener: (this: MediaKeySession, ev: MediaKeySessionEventMap[K]) => any,
options?: boolean | AddEventListenerOptions,
): void;
addEventListener(
type: string,
listener: EventListenerOrEventListenerObject,
options?: boolean | AddEventListenerOptions,
): void;
close(): Promise<void>;
dispatchEvent(event: Event): boolean;
generateRequest(
initDataType: string,
initData: BufferSource,
): Promise<void>;
load(sessionId: string): Promise<boolean>;
remove(): Promise<void>;
removeEventListener<K extends keyof MediaKeySessionEventMap>(
type: K,
listener: (this: MediaKeySession, ev: MediaKeySessionEventMap[K]) => any,
options?: boolean | EventListenerOptions,
): void;
removeEventListener(
type: string,
listener: EventListenerOrEventListenerObject,
options?: boolean | EventListenerOptions,
): void;
update(response: BufferSource): Promise<void>;
}
Hierarchy
- EventTarget
- MediaKeySession
Properties
Readonlyclosed
The closed read-only property of the MediaKeySession interface returns a Promise signaling when a MediaKeySession closes.
Readonlyexpiration
The expiration read-only property of the MediaKeySession interface returns the time after which the keys in the current session can no longer be used to decrypt media data, or NaN if no such time exists.
ReadonlykeyStatuses
The keyStatuses read-only property of the MediaKeySession interface returns a reference to a read-only MediaKeyStatusMap of the current session's keys and their statuses.
onkeystatuseschange
onmessage
ReadonlysessionId
The sessionId read-only property of the MediaKeySession interface contains a unique string generated by the content decryption module (CDM) for the current media object and its associated keys or licenses.
Methods
addEventListener
- addEventListener<K extends keyof MediaKeySessionEventMap>(
type: K,
listener: (this: MediaKeySession, ev: MediaKeySessionEventMap[K]) => any,
options?: boolean | AddEventListenerOptions,
): voidThe
addEventListener()method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target.Type Parameters
- K extends keyof MediaKeySessionEventMap
Parameters
- type: K
- listener: (this: MediaKeySession, ev: MediaKeySessionEventMap[K]) => any
Optionaloptions: boolean | AddEventListenerOptions
Returns void
- addEventListener(
type: string,
listener: EventListenerOrEventListenerObject,
options?: boolean | AddEventListenerOptions,
): voidThe
addEventListener()method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target.Parameters
- type: string
- listener: EventListenerOrEventListenerObject
Optionaloptions: boolean | AddEventListenerOptions
Returns void
close
The
close()method of the MediaKeySession interface notifies that the current media session is no longer needed, and that the content decryption module should release any resources associated with this object and close it.Returns Promise<void>
dispatchEvent
The
dispatchEvent()method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order.Parameters
- event: Event
Returns boolean
generateRequest
The
generateRequest()method of the MediaKeySession interface returns a Promise after generating a license request based on initialization data.Parameters
- initDataType: string
- initData: BufferSource
Returns Promise<void>
load
The
load()method of the MediaKeySession interface returns a Promise that resolves to a boolean value after loading data for a specified session object.Parameters
- sessionId: string
Returns Promise<boolean>
remove
The
remove()method of the MediaKeySession interface returns a Promise after removing any session data associated with the current object.Returns Promise<void>
removeEventListener
- removeEventListener<K extends keyof MediaKeySessionEventMap>(
type: K,
listener: (this: MediaKeySession, ev: MediaKeySessionEventMap[K]) => any,
options?: boolean | EventListenerOptions,
): voidThe
removeEventListener()method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target.Type Parameters
- K extends keyof MediaKeySessionEventMap
Parameters
- type: K
- listener: (this: MediaKeySession, ev: MediaKeySessionEventMap[K]) => any
Optionaloptions: boolean | EventListenerOptions
Returns void
- removeEventListener(
type: string,
listener: EventListenerOrEventListenerObject,
options?: boolean | EventListenerOptions,
): voidThe
removeEventListener()method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target.Parameters
- type: string
- listener: EventListenerOrEventListenerObject
Optionaloptions: boolean | EventListenerOptions
Returns void
update
The
update()method of the MediaKeySession interface loads messages and licenses to the CDM, and then returns a Promise.Parameters
- response: BufferSource
Returns Promise<void>
The
MediaKeySessioninterface of the Encrypted Media Extensions API represents a context for message exchange with a content decryption module (CDM). Available only in secure contexts.MDN Reference