Constructor
new EmeManager(player, videonon-null, videoSourcenon-null)
Creates the EME manager.
Parameters:
Name | Type | Description |
---|---|---|
player |
shaka.player.Player | The player instance. |
video |
HTMLVideoElement | The video element. |
videoSource |
shaka.player.IVideoSource | The video source. |
- Extends:
- Source:
Fires:
Members
-
(private, non-null) allSessionsPresumedReady_ :shaka.util.PublicPromise
-
Resolved when all sessions are probably ready. This is a heuristic, and is intended to support persisting licenses for offline playback.
Type:
- Source:
-
(private, nullable) allSessionsReadyTimer_ :number
-
Type:
- number
- Source:
-
(private) drmInfo_ :shaka.player.DrmInfo
-
Type:
- Source:
-
(private, non-null) eventManager_ :shaka.util.EventManager
-
Type:
- Source:
-
(private) licenseRequestTimeout_ :number
-
Type:
- number
- Source:
-
(private, non-null) listeners_ :shaka.util.MultiMap.<shaka.util.FakeEventTarget.ListenerType>
-
Type:
- Inherited From:
- Source:
-
(private) mediaKeys_ :MediaKeys
-
Type:
- MediaKeys
- Source:
-
(private) numUpdates_ :number
-
Type:
- number
- Source:
-
(protected) parent :shaka.util.FakeEventTarget
-
Type:
- Inherited From:
- Source:
-
(private) player_ :shaka.player.Player
-
Type:
- Source:
-
(private, non-null) requestGenerated_ :Array.<{data: !Uint8Array, session: !MediaKeySession}>
-
Type:
- Array.<{data: !Uint8Array, session: !MediaKeySession}>
- Source:
-
(private, non-null) sessions_ :Array.<!MediaKeySession>
-
Type:
- Array.<!MediaKeySession>
- Source:
-
(private, non-null) video_ :HTMLVideoElement
-
Type:
- HTMLVideoElement
- Source:
-
(private, non-null) videoSource_ :shaka.player.IVideoSource
-
Type:
- Source:
Methods
-
addEventListener(type, listener, opt_capturingopt)
-
Add an event listener to this object.
Parameters:
Name Type Attributes Description type
string The event type to listen for. listener
shaka.util.FakeEventTarget.ListenerType The callback or listener object to invoke. opt_capturing
boolean <optional>
True to listen during the capturing phase, false to listen during the bubbling phase. Note that FakeEventTarget does not support the capturing phase from the standard event model. - Inherited From:
- Source:
-
allSessionsReady(timeoutMs) → (non-null) {Promise}
-
Parameters:
Name Type Description timeoutMs
number A timeout in ms after which the promise should be rejected. - Source:
Returns:
resolved when all sessions are presumed ready.- Type
- Promise
-
attach() → (non-null) {Promise}
-
Sets up MediaKeys after it has been created. The MediaKeys instance will be attached to the video, any fake events will be generated, and any event listeners will be attached to the video.
- Source:
Returns:
- Type
- Promise
-
(private) buildKeySystemPromiseChain_(mediaKeySystemConfigsnon-null, pnon-null) → (non-null) {Promise.<!MediaKeySystemAccess>}
-
Build a promise chain to check each MediaKey configuration. If the first config fails, the next will be checked as a series of fallbacks.
Parameters:
Name Type Description mediaKeySystemConfigs
Object.<string, !MediaKeySystemConfiguration> MediaKeySystemConfiguration} Key system configs, indexed by key system. p
Promise The beginning of the promise chain, which should be rejected to start the series of fallback queries. - Source:
Returns:
- Type
- Promise.<!MediaKeySystemAccess>
-
(private) buildKeySystemQueries_(configsnon-null, chosenStreamsnon-null) → (non-null) {Object.<string, !MediaKeySystemConfiguration>}
-
Build a set of MediaKeySystemConfigs to query for encrypted stream support.
Parameters:
Name Type Description configs
Array.<!shaka.media.StreamConfig> A list of configurations supported by the video source. chosenStreams
shaka.util.MultiMap.<!shaka.media.StreamConfig> Chosen streams indexed by content type. - Source:
Throws:
-
if DrmInfo is missing.
- Type
- Error
Returns:
Key system configs, indexed by key system.- Type
- Object.<string, !MediaKeySystemConfiguration>
-
(private) chooseEncrypted_(configsnon-null, chosenStreamsnon-null, mediaKeySystemAccessnon-null) → (non-null) {Promise}
-
When a key system query succeeds, chooses encrypted streams which match the chosen MediaKeySystemConfiguration, then creates a MediaKeys instance.
Parameters:
Name Type Description configs
Array.<!shaka.media.StreamConfig> A list of configurations supported by the video source. chosenStreams
shaka.util.MultiMap.<!shaka.media.StreamConfig> Chosen streams indexed by content type. mediaKeySystemAccess
MediaKeySystemAccess - Source:
Returns:
- Type
- Promise
-
(private) chooseUnencrypted_(configsnon-null, chosenStreamsnon-null)
-
Choose unencrypted streams for each type if possible. Store chosen streams into chosenStreams.
Parameters:
Name Type Description configs
Array.<!shaka.media.StreamConfig> A list of configurations supported by the video source. chosenStreams
shaka.util.MultiMap.<!shaka.media.StreamConfig> Chosen streams indexed by content type. - Source:
-
(private) createLicenseRequestInfo_(drmInfonon-null, licenseRequestBodynon-null) → (non-null) {shaka.player.DrmInfo.LicenseRequestInfo}
-
Creates a LicenseRequestInfo object, potentially calling a licenese request pre-processor.
Parameters:
Name Type Description drmInfo
shaka.player.DrmInfo licenseRequestBody
ArrayBuffer - Source:
Throws:
-
TypeError if the application sets a LicenseRequestInfo field to the wrong type.
-
Error if the application deletes a LicenseRequestInfo field or sets the |method| field of a LicenseRequestInfo object to something other than 'GET' or 'POST'.
Returns:
A LicenseRequestInfo object whose fields have correct types. -
(private) createMediaKeySystemConfig_(drmInfonon-null) → (non-null) {MediaKeySystemConfiguration}
-
Creates a MediaKeySystemConfiguration from the given DrmInfo.
Parameters:
Name Type Description drmInfo
shaka.player.DrmInfo - Source:
Returns:
- Type
- MediaKeySystemConfiguration
-
(private) createSession_() → {MediaKeySession}
-
Creates a new MediaKeySession.
- Source:
Returns:
- Type
- MediaKeySession
-
deleteSessions() → (non-null) {Promise}
-
Deletes all sessions from persistent storage.
- Source:
Returns:
- Type
- Promise
-
destroy()
-
Destroys the EME manager.
- Source:
-
dispatchEvent(eventnon-null) → {boolean}
-
Dispatch an event from this object.
Parameters:
Name Type Description event
Event The event to be dispatched from this object. - Inherited From:
- Source:
Returns:
True if the default action was prevented.- Type
- boolean
-
(private) generateFakeEncryptedEvents_()
-
Generate and dispatch any fake 'encrypted' events for |drmInfo_|.
- Source:
-
getDrmInfo() → {shaka.player.DrmInfo}
-
Returns the current DrmInfo.
- Source:
Returns:
- Type
- shaka.player.DrmInfo
-
initialize() → (non-null) {Promise}
-
Initializes the DrmInfo by choosing from stream configurations provided by the video source. This function sets |mediaKeys_| and |drmInfo_|.
- Source:
Returns:
- Type
- Promise
-
(private) loadSessions_()
-
Loads persistent sessions via sessionId saved within videoSource.
- Source:
-
(private) onEncrypted_(eventnon-null)
-
EME 'encrypted' event handler.
Parameters:
Name Type Description event
MediaEncryptedEvent The EME 'encrypted' event. - Source:
-
(private) onKeyStatusesChange_(eventnon-null)
-
EME status-change handler.
Parameters:
Name Type Description event
Event - Source:
-
(private) onSessionMessage_(eventnon-null)
-
EME key-message handler.
Parameters:
Name Type Description event
MediaKeyMessageEvent The EME message event. - Source:
-
(private) playReadyLicensePreProcessor_(infonon-null)
-
Standard pre-processor for PlayReady license requests.
Parameters:
Name Type Description info
shaka.player.DrmInfo.LicenseRequestInfo License request info. - Source:
-
(private) recursiveDispatch_(eventnon-null) → {boolean}
-
Dispatches an event recursively without changing its original target.
Parameters:
Name Type Description event
Event - Inherited From:
- Source:
Returns:
True if the default action was prevented.- Type
- boolean
-
(private) rejectDestroyed_() → (non-null) {Promise}
-
- Source:
Returns:
- Type
- Promise
-
removeEventListener(type, listener, opt_capturingopt)
-
Remove an event listener from this object.
Parameters:
Name Type Attributes Description type
string The event type for which you wish to remove a listener. listener
shaka.util.FakeEventTarget.ListenerType The callback or listener object to remove. opt_capturing
boolean <optional>
True to remove a listener for the capturing phase, false to remove a listener for the bubbling phase. Note that FakeEventTarget does not support the capturing phase from the standard event model. - Inherited From:
- Source:
-
(private) requestLicense_(sessionnon-null, drmInfonon-null, licenseRequestBodynon-null)
-
Requests a license.
Parameters:
Name Type Description session
MediaKeySession An EME session object. drmInfo
shaka.player.DrmInfo licenseRequestBody
ArrayBuffer The license request's body. - Source:
Throws:
-
TypeError
-
Error
-
setLicenseRequestTimeout(timeout)
-
Sets the license request timeout in seconds.
Parameters:
Name Type Description timeout
number The license request timeout in seconds. - Source:
Events
-
SessionReadyEvent
-
Fired when a new MediaKeySession is ready.
Properties:
Name Type Description type
string 'sessionReady' detail
MediaKeySession - Source: