web api instance method
HTMLMediaElement: setMediaKeys() method
Secure context
The setMediaKeys() method of the HTMLMediaElement interface sets the MediaKeys that will be used to decrypt media during playback.
It returns a Promise that fulfils if the new keys are successfully set, or rejects if keys cannot be set.
Syntax
setMediaKeys(mediaKeys)
Parameters
mediaKeys- : A
MediaKeysobject that theHTMLMediaElementcan use for decryption of media data during playback.
- : A
Return value
A Promise that fulfills with undefined.
Exceptions
The returned promise may reject an error:
InvalidStateErrorDOMException- : Media keys are already in the process of being attached, or the previous keys cannot be removed at the current time (for example, because the particular implementation does not allow removal during playback).
QuotaExceededError- : The passed keys are already in use by another element, or the browser is unable to use it with this element for other reasons.
NotSupportedErrorDOMException- : The media keys that are currently associated with the media cannot be disassociated, because this is not supported by either the CDM or the browser.
Specifications
SpecificationsStandards references are available on the canonical MDN page.
Browser compatibility
Browser compatibilityCompatibility data is available on the canonical MDN page.