Amazon Developer

as

Settings
Sign out
Notifications
Alexa
Amazon Appstore
Ring
AWS
Documentation
Support
Contact Us
My Cases
Get Started
Design and Develop
Publish
Reference
Support
Native
Skip to main content

Interface IMediaKeySession

interface IMediaKeySession
Extends com.amazon.apmf.IStandard Representation of MediaKeySession interface struct defined by EME spec. Apps should use this interface to generate license request and obtain decrypt key id, and close/remove session. For more details see https://www.w3.org/TR/encrypted-media/#mediakeysession-interface

Methods

addExpirationChangedListener()

com.amazon.apmf.ISubscription* addExpirationChangedListener(IMediaKeySessionExpirationListener* sessionExpirationChangedListener)
Add a callback to be notified when the expiration time of MediaKeySession changes.

Parameters

sessionExpirationChangedListener
IMediaKeySessionExpirationListener* — Required IMediaKeySessionExpirationListener instance for callback when the expiration time of the MediaKeySession changes.

Returns

com.amazon.apmf.ISubscription* ISubscription object instance

addKeySessionRemovedListener()

com.amazon.apmf.ISubscription* addKeySessionRemovedListener(IMediaKeySessionRemoveStatusListener* sessionRemovedListener)
Add a callback to be notified when MediaKeySession is removed

Parameters

sessionRemovedListener
IMediaKeySessionRemoveStatusListener* — Required IMediaKeySessionRemoveStatusListener instance for callback to be notified when MediaKeySession is removed.

Returns

com.amazon.apmf.ISubscription* ISubscription object instance

addKeyStatusChangeListener()

com.amazon.apmf.ISubscription* addKeyStatusChangeListener(IMediaKeyStatusChangeListener* keyStatusChangeListener)
Add a callback to be notified when key status has changed

Parameters

keyStatusChangeListener
IMediaKeyStatusChangeListener* — Required IMediaKeyStatusChangeListener instance for callback to receive changes to key status.

Returns

com.amazon.apmf.ISubscription* ISubscription object instance

addMediaKeyMessageEventListener()

com.amazon.apmf.ISubscription* addMediaKeyMessageEventListener(IMediaKeyMessageEventListener* keyMessageEventListener)
Add a callback to be notified when there is key message

Parameters

keyMessageEventListener
IMediaKeyMessageEventListener* — Required IMediaKeyMessageEventListener instance for callback to receive Media Key Message Events.

Returns

com.amazon.apmf.ISubscription* ISubscription object instance

generateLicenseRequest()

com.amazon.apmf.ISubscription* generateLicenseRequest(IContentProtectionInitData* contentProtectionInitData, ILicenseRequestListener* licenseRequestListener)
Generates a License request based on the parameters passed and the session type used while creating this MediaKeySession object. Upon a successful call, the actual License challenge/request will be served through OnMediaKeyMessageEventClosure For further details see https://www.w3.org/TR/encrypted-media/#dom-mediakeysession-generaterequest

Parameters

contentProtectionInitData
IContentProtectionInitData* — Required CDM specific init data (a.k.a PSSH)
licenseRequestListener
ILicenseRequestListener* — Required ILicenseRequestListener instance for callback when the licenseRequest is generated.

Returns

com.amazon.apmf.ISubscription* ISubscription object instance

load()

com.amazon.apmf.ISubscription* load(string sessionId, IMediaKeySessionLoadStatusListener* keySessionLoadStatusListener)
Loads a previous persistent session with all its keys. For further details see https://www.w3.org/TR/encrypted-media/#dom-mediakeysession-load

Parameters

sessionId
string — Required string. ID of previous, NOT REMOVED PERSISTENT Session.
keySessionLoadStatusListener
IMediaKeySessionLoadStatusListener* — Required IMediaKeySessionLoadStatusListener instance for callback when MediaKeySession is loaded.

Returns

com.amazon.apmf.ISubscription* ISubscription object instance

update()

com.amazon.apmf.ISubscription* update(u8[] licenseResponse, IMediaKeySessionUpdateStatusListener* keySessionUpdateStatusListener)
Once the client receives a valid license response from a license server, this function is used to pass the response for processing to the platform CDM implementation. Upon success, the client will be called back with onKeyStatusChanged() to nofity that a new license is valid for use in decrypt or make aware of its current status. For further details see https://www.w3.org/TR/encrypted-media/#dom-mediakeysession-update

Parameters

licenseResponse
u8[] — Required The license response from the license server
keySessionUpdateStatusListener
IMediaKeySessionUpdateStatusListener* — Required IMediaKeySessionUpdateStatusListener instance for callback when MediaKeySession is updated.

Returns

com.amazon.apmf.ISubscription* ISubscription object instance

close()

com.amazon.apmf.ISubscription* close(IMediaKeySessionCloseStatusListener* keySessionCloseStatusListener)
Closes a session. NOTE that the session is not removed. It only chaged to be closed if it is PERSISTENT. All the session’s keys are moved to RELEASED and are no longer usable for decryption but are still “known”. For further details see https://www.w3.org/TR/encrypted-media/#dom-mediakeysession-close

Parameters

keySessionCloseStatusListener
IMediaKeySessionCloseStatusListener* — Required IMediaKeySessionCloseStatusListener instance for callback when the MediaKeySession is closed

Returns

com.amazon.apmf.ISubscription* ISubscription object instance

remove()

com.amazon.apmf.ISubscription* remove(IMediaKeySessionRemoveStatusListener* keySessionRemoveStatusListener)
Removes a session. All the session’s keys and other data are removed from memory. Same effect as close if session type is TEMPORARY. For further details see https://www.w3.org/TR/encrypted-media/#dom-mediakeysession-remove

Parameters

keySessionRemoveStatusListener
IMediaKeySessionRemoveStatusListener* — Required IMediaKeySessionRemoveStatusListener instance for callback when MediaKeySession is removed

Returns

com.amazon.apmf.ISubscription* ISubscription object instance

getSessionId()

string getSessionId()
Session Id getter. A Session ID is a unique string identifier generated by the CDM that can be used by the application to identify MediaKeySession objects. A new Session ID is generated each time the user agent and CDM successfully create a new session. For more detail see https://www.w3.org/TR/encrypted-media/#dom-mediakeysession-sessionid

Returns

string null terminated id string

isVideoSecure()

bool isVideoSecure()
Checks whether the video is configured use for secure codec.

Returns

bool true if codec was requested to be secure for the given media type, otherwise false.

isAudioSecure()

bool isAudioSecure()
Checks whether the audio is configured use for secure codec.

Returns

bool true if codec was requested to be secure for the given media type, otherwise false.

getMediaKeyStatusMap()

IMediaKeyStatusMap* getMediaKeyStatusMap()
Getter for drm session’s MediaKeyStatusMap object. For further details see https://www.w3.org/TR/encrypted-media/#dom-mediakeysession-keystatuses

Returns

IMediaKeyStatusMap* MediaKeyStatus map for this drm session.

getExpirationTimeOutSecs()

double getExpirationTimeOutSecs()
Getter for drm session’s expiration.

Returns

double The expiration in seconds for the keys in this session
Last modified on October 29, 2026