MediaKeySession: generateRequest() method
MDN Web Docs · نسخهٔ df622a2a1c1e · CC BY-SA 2.5 و مجوز جداگانهٔ ناشر برای نمونهکد
{{APIRef("Encrypted Media Extensions")}}{{SecureContext_Header}}
The generateRequest() method of the {{domxref('MediaKeySession')}} interface returns a {{jsxref('Promise')}} after generating a license request based on initialization data.
Syntax
js-nolint
generateRequest(initDataType, initData)Parameters
initDataType- : A string that specifies the format of the
initDataparameter. This must be one of the following values: "cenc": TheinitDataparameter uses the ["cenc"](https://w3c.github.io/encrypted-media/format-registry/initdata/cenc.html) format."keyids": TheinitDataparameter uses the ["keyids"](https://w3c.github.io/encrypted-media/format-registry/initdata/keyids.html) format."webm": TheinitDataparameter uses the ["webm"](https://w3c.github.io/encrypted-media/format-registry/initdata/webm.html) format.initData- : Initialization data for the request, in the format specified by
initDataType. It is an instance of any of the following types: - {{jsxref("ArrayBuffer")}}
- {{jsxref("DataView")}}
- {{jsxref("TypedArray")}}
Return value
A {{jsxref('Promise')}}.
Exceptions
- {{jsxref("TypeError")}}
- : Raised if
initDataTypeis an empty string, ifinitDatais an empty array, or if the providedinitDatais not valid according to the specifiedinitDataType. NotSupportedError{{domxref("DOMException")}}- : Raised if the Key System implementation associated with the
MediaKeySessionobject does not support the providedinitDataType, if the sanitized initialization data is empty, or if the sanitized initialization data is not supported by the content decryption module (CDM). - {{domxref("QuotaExceededError")}}
- : Raised if the operation fails due to a lack of resources on the user agent or CDM.
InvalidStateError{{domxref("DOMException")}}- : Raised if the
MediaKeySessionobject is in aclosingorclosedstate, or if it has already been initialized.
Specifications
{{Specifications}}
Browser compatibility
{{Compat}}