Share via


Using Proactive License Acquisition

This topic describes the basic steps required to acquire a license for PlayReady protected media content proactively. With proactive license acquisition, your Web app can be programmed to anticipate a request from a media element instead of waiting for a needKey event. The following figure shows the basic steps required to acquire a PlayReady license proactively.

Note

The keyError event can occur at any time during the license acquisition process.

To acquire a PlayReady license proactively

Your Web app creates a MediaKeys object of the PlayReady protected system if it does not already exist.

Your Web app calls MediaKeys::createSession to create a MediaKeySession object and passes it an initData and a CDMData that contains:

  • Any optional custom data.
  • The proactive flag set to true to indicate that proactive license acquisition is needed.

Note

The initData does not need to contain any data (that is, it can be passed as a Uint8Array with no data). If initData is empty, then CDMData needs to contain a key identifier. If initData is not empty, then CDMData cannot contain a key identifier.

The CDM session (MediaKeySession) sends a keyMessage event, along with its payload, to your Web app.

Your Web app handles the keyMessage event by sending the license acquisition challenge in the payload to a license server and getting back a license response.

Your Web app calls MediaKeySession::Update along with the license response.

The CDM session sends your Web app either a keyAdded event if successful or a keyError event if an error occurs.