MediaKeySession: generateRequest() method

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since March 2019.

Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

The generateRequest() method of the MediaKeySession interface returns a Promise after generating a license request based on initialization data.

Syntax

js
generateRequest(initDataType, initData)

Parameters

initDataType

A string that specifies the format of the initData parameter. This must be one of the following values:

  • "cenc": The initData parameter uses the "cenc" format.
  • "keyids": The initData parameter uses the "keyids" format.
  • "webm": The initData parameter uses the "webm" format.
initData

Initialization data for the request, in the format specified by initDataType. It is an instance of any of the following types:

Return value

A Promise.

Exceptions

TypeError

Raised if initDataType is an empty string, if initData is an empty array, or if the provided initData is not valid according to the specified initDataType.

NotSupportedError DOMException

Raised if the Key System implementation associated with the MediaKeySession object does not support the provided initDataType, if the sanitized initialization data is empty, or if the sanitized initialization data is not supported by the content decryption module (CDM).

QuotaExceededError

Raised if the operation fails due to a lack of resources on the user agent or CDM.

InvalidStateError DOMException

Raised if the MediaKeySession object is in a closing or closed state, or if it has already been initialized.

Specifications

Specification
Encrypted Media Extensions
# dom-mediakeysession-generaterequest

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
generateRequest
Chrome – Full support
Chrome 42 (Release date: 2015-04-14)
footnote Full support
Edge – Full support
Edge 13 (Release date: 2015-11-12)
footnote Full support
Firefox – Full support
Firefox 38 (Release date: 2015-05-12)
footnote Full support
Opera – Full support
Opera 29 (Release date: 2015-04-28)
footnote Full support
Safari – Full support
Safari 12.1 (Release date: 2019-03-25)
footnote Full support
Chrome Android – Full support
Chrome Android 42 (Release date: 2015-04-15)
footnote Full support
Firefox for Android – Full support
Firefox for Android 38 (Release date: 2015-05-12)
footnote Full support
Opera Android – Full support
Opera Android 29 (Release date: 2015-04-28)
footnote Full support
Safari on iOS – Full support
Safari on iOS 12.2 (Release date: 2019-03-25)
footnote Full support
Samsung Internet – Full support
Samsung Internet 4 (Release date: 2016-03-11)
footnote Full support
WebView Android – Full support
WebView Android 43 (Release date: 2015-05-27)
footnote Full support
WebView on iOS – Full support
WebView on iOS 12.2 (Release date: 2019-03-25)
footnote Full support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support