files/en-us/web/api/htmlmediaelement/setmediakeys/index.md
{{APIRef("HTML DOM")}}{{SecureContext_Header}}
The setMediaKeys() method of the {{domxref("HTMLMediaElement")}} interface sets the {{domxref("MediaKeys")}} that will be used to decrypt media during playback.
It returns a {{jsxref("Promise")}} that fulfils if the new keys are successfully set, or rejects if keys cannot be set.
setMediaKeys(mediaKeys)
mediaKeys
A {{jsxref("Promise")}} that fulfills with {{jsxref('undefined')}}.
The returned promise may reject an error:
InvalidStateError {{domxref("DOMException")}}
NotSupportedError {{domxref("DOMException")}}
{{Specifications}}
{{Compat}}