Interface IMediaControlHandlerAsync
interface IMediaControlHandlerAsync
Extends com.amazon.apmf.IStandard
Interface for receiving media control requests.
A media control server application implements this interface and registers it
through IMediaControlServerAsync::setHandlerForComponent.
See IMediaControlHandlerAsync2 for additional context on the pause command initiator.
Methods
handlePlay()
Handles a request to resume or start playback. If the application is already playing and the playback speed is not normal (not 1.0) this may return playback to normal speed. Receiving multiple play requests while already in playing state is not an error and should signal success on the given [IActionResponseListener] instance. The media server should update the corresponding [MediaSessionState] to reflect the new playback status.voidhandlePlay(IActionResponseListener*listener,MediaSessionId?sessionId)
Parameters
listener
IActionResponseListener* — Required
Invoked when the request is accepted or an error occurred handling the request.
sessionId
MediaSessionId? — Optional
An optional id that identifies which session this request is intended for.
If not specified, the request is not intended for any particular session and
its up to this server to interpret how it should be handled.
handlePause()
Handles a request to pause playback. Receiving multiple pause requests while already in pause state is not an error and should signal success on the given [IActionResponseListener] instance. The media server should update the corresponding [MediaSessionState] to reflect the new playback status. Pause could be invoked by an user (e.g., through remote or Alexa) or by the system (e.g., when the display is off). Refer tovoidhandlePause(IActionResponseListener*listener,MediaSessionId?sessionId)
IMediaControlHandlerAsync2::handlePauseWithContext
below if you need more context about why Pause is invoked.
Parameters
listener
IActionResponseListener* — Required
Invoked when the request is accepted or an error occurred handling the request.
sessionId
MediaSessionId? — Optional
An optional id that identifies which session this request is intended for.
If not specified, the request is not intended for any particular session and
its up to this server to interpret how it should be handled.
handleTogglePlayPause()
Handles a request to start, resume or pause playback depending on the current playback status. When the current playback status is [PlaybackStatus#PLAYING] or [PlaybackStatus#BUFFERING] the request should be interpreted as a pause request. When the current playback status is [PlaybackStatus#PAUSED] or [PlaybackStatus#NOT_PLAYING] the request should be interpreted as a play request. The media server should update the corresponding [MediaSessionState] to reflect the new playback status.voidhandleTogglePlayPause(IActionResponseListener*listener,MediaSessionId?sessionId)
Parameters
listener
IActionResponseListener* — Required
Invoked when the request is accepted or an error occurred handling the request.
sessionId
MediaSessionId? — Optional
An optional id that identifies which session this request is intended for.
If not specified, the request is not intended for any particular session and
its up to this server to interpret how it should be handled.
handleStop()
Handles a request to stop playback. Receiving multiple stop requests while already in not_playing state is not an error and should signal success on the given [IActionResponseListener] instance. The media server should update the corresponding [MediaSessionState] to reflect the new playback status.voidhandleStop(IActionResponseListener*listener,MediaSessionId?sessionId)
Parameters
listener
IActionResponseListener* — Required
Invoked when the request is accepted or an error occurred handling the request.
sessionId
MediaSessionId? — Optional
An optional id that identifies which session this request is intended for.
If not specified, the request is not intended for any particular session and
its up to this server to interpret how it should be handled.
handleStartOver()
Handles a request to start playback over at the start of the media. The media server should update the corresponding [MediaSessionState] to reflect the new playback status and position.voidhandleStartOver(IActionResponseListener*listener,MediaSessionId?sessionId)
Parameters
listener
IActionResponseListener* — Required
Invoked when the request is accepted or an error occurred handling the request.
sessionId
MediaSessionId? — Optional
An optional id that identifies which session this request is intended for.
If not specified, the request is not intended for any particular session and
its up to this server to interpret how it should be handled.
handleFastForward()
Handles a request to fast forward playback. This server decides which accelerated playback speed should be used. Receiving multiple consecutive fast-foward requests should increase the playback speed at steps decided by this server. This server can decide to stop increasing playback speed after numerous fast-forward requests but it should accept and acknowledge the request normally. Audio playback can be muted or disabled when playback speed is not 1.0. The media server should update the corresponding [MediaSessionState] to reflect the new playback speed.voidhandleFastForward(IActionResponseListener*listener,MediaSessionId?sessionId)
Parameters
listener
IActionResponseListener* — Required
Invoked when the request is accepted or an error occurred handling the request.
sessionId
MediaSessionId? — Optional
An optional id that identifies which session this request is intended for.
If not specified, the request is not intended for any particular session and
its up to this server to interpret how it should be handled.
handleRewind()
Handles a request to rewind playback. Media should start playing backwards at a normal speed from the current playback position, upon receiving the first rewind request. If playback is already going backwards, this server decides which accelerated reverse playback speed should be used. Receiving multiple consecutive rewind requests can increase the playback speed at steps decided by this server. This server can decide to stop increasing playback speed after numerous rewind requests but it should accept and acknowledge the request normally. Audio playback can be muted or disabled when playback speed is not 1.0. The media server should update the corresponding [MediaSessionState] to reflect the new playback speed.voidhandleRewind(IActionResponseListener*listener,MediaSessionId?sessionId)
Parameters
listener
IActionResponseListener* — Required
Invoked when the request is accepted or an error occurred handling the request.
sessionId
MediaSessionId? — Optional
An optional id that identifies which session this request is intended for.
If not specified, the request is not intended for any particular session and
its up to this server to interpret how it should be handled.
handleSetPlaybackSpeed()
Handles a request to change the playback speed.voidhandleSetPlaybackSpeed(IActionResponseListener*listener,floatspeed,MediaSessionId?sessionId)
- A value of 1.0 indicates normal playback speed.
- Values greater than 1.0 represent accelerated playback.
- Values between 0.0 and 1.0 (excluding 0.0) indicate slowed playback.
- Values less than 0.0 but greater than -1.0 represent slowed down backwards playback.
- Values less than -1.0 represent accelerated backwards playback.
Parameters
listener
IActionResponseListener* — Required
Invoked when the request is accepted or an error occurred handling the request.
speed
float — Required
The new playback speed.
sessionId
MediaSessionId? — Optional
An optional id that identifies which session this request is intended for.
If not specified, the request is not intended for any particular session and
its up to this server to interpret how it should be handled.
handleSkipForward()
Handles a request to skip forward. The media server should update the corresponding [MediaSessionState] to reflect the new playback position.voidhandleSkipForward(IActionResponseListener*listener,com.amazon.apmf.MonotonicDurationdelta,MediaSessionId?sessionId)
Parameters
listener
IActionResponseListener* — Required
Invoked when the request is accepted or an error occurred handling the request.
delta
com.amazon.apmf.MonotonicDuration — Required
The amount to skip forward relative to the current playback position.
sessionId
MediaSessionId? — Optional
An optional id that identifies which session this request is intended for.
If not specified, the request is not intended for any particular session and
its up to this server to interpret how it should be handled.
handleSkipBackward()
Handles a request to skip backward. The media server should update the corresponding [MediaSessionState] to reflect the new playback position.voidhandleSkipBackward(IActionResponseListener*listener,com.amazon.apmf.MonotonicDurationdelta,MediaSessionId?sessionId)
Parameters
listener
IActionResponseListener* — Required
Invoked when the request is accepted or an error occurred handling the request.
delta
com.amazon.apmf.MonotonicDuration — Required
The amount to skip backward relative to the current playback position.
sessionId
MediaSessionId? — Optional
An optional id that identifies which session this request is intended for.
If not specified, the request is not intended for any particular session and
its up to this server to interpret how it should be handled.
handleSeek()
Handles a request to seek to seek to a given playback position. The media server should update the corresponding [MediaSessionState] to reflect the new playback position.voidhandleSeek(IActionResponseListener*listener,com.amazon.apmf.MonotonicDurationposition,MediaSessionId?sessionId)
Parameters
listener
IActionResponseListener* — Required
Invoked when the request is accepted or an error occurred handling the request.
position
com.amazon.apmf.MonotonicDuration — Required
The playback position to seek to, relative to the start of the media, where 0 represents
the start of the media.
sessionId
MediaSessionId? — Optional
An optional id that identifies which session this request is intended for.
If not specified, the request is not intended for any particular session and
its up to this server to interpret how it should be handled.
handleSetAudioVolume()
Handles a request change the audio volume of the currently playing audio track. The volume value is normalized, from 0.0 (silent) to 1.0 (full volume). The application is expected to notify the given IActionResponseListener either within the invoking thread or asynchronously later on a different thread.voidhandleSetAudioVolume(IActionResponseListener*listener,floatvolume,MediaSessionId?sessionId)
Parameters
listener
IActionResponseListener* — Required
Invoked when the request is accepted or an error occurred handling the request.
volume
float — Required
The target volume level, expressed in a normalized range from
0.0 (complete silence) to 1.0 (maximum volume).
sessionId
MediaSessionId? — Optional
An optional id that identifies which session this request is intended for.
If not specified, the request is not intended for any particular session and
its up to this server to interpret how it should be handled.
handleSetAudioTrack()
Handles a request to change the audio track. The media sesssion should update its [MediaSessionState] to reflect the new active audio track (see [MediaInfo#activeAudioTrack]).voidhandleSetAudioTrack(IActionResponseListener*listener,Track*audioTrack,MediaSessionId?sessionId)
Parameters
listener
IActionResponseListener* — Required
Invoked when the request is accepted or an error occurred handling the request.
audioTrack
Track* — Required
The audio track to change to.
sessionId
MediaSessionId? — Optional
An optional id that identifies which session this request is intended for.
If not specified, the request is not intended for any particular session and
its up to this server to interpret how it should be handled.
handleEnableTextTrack()
Handles a request to select and enable a given text track. The media sesssion should update its [MediaSessionState] to reflect the new active text track (see [MediaInfo#activeTextTrack]).voidhandleEnableTextTrack(IActionResponseListener*listener,Track*textTrack,MediaSessionId?sessionId)
Parameters
listener
IActionResponseListener* — Required
Invoked when the request is accepted or an error occurred handling the request.
textTrack
Track* — Required
The text track to select or disables text track if the value is null.
sessionId
MediaSessionId? — Optional
An optional id that identifies which session this request is intended for.
If not specified, the request is not intended for any particular session and
its up to this server to interpret how it should be handled.
handleDisableTextTrack()
Handles a request to disable the active text track. The media sesssion should update its [MediaSessionState] to reflect no active text track (see [MediaInfo#activeTextTrack]).voidhandleDisableTextTrack(IActionResponseListener*listener,MediaSessionId?sessionId)
Parameters
listener
IActionResponseListener* — Required
Invoked when the request is accepted or an error occurred handling the request.
sessionId
MediaSessionId? — Optional
An optional id that identifies which session this request is intended for.
If not specified, the request is not intended for any particular session and
its up to this server to interpret how it should be handled.
handleNext()
Handles a request to select the next media item in the playlist or queue. The media sesssion should update the media info (see [MediaSessionState#mediaInfo]).voidhandleNext(IActionResponseListener*listener,MediaSessionId?sessionId)
Parameters
listener
IActionResponseListener* — Required
Invoked when the request is accepted or an error occurred handling the request.
sessionId
MediaSessionId? — Optional
An optional id that identifies which session this request is intended for.
If not specified, the request is not intended for any particular session and
its up to this server to interpret how it should be handled.
handlePrevious()
Handles a request to select the previous media item in the playlist or queue. The media sesssion should update the media info (see [MediaSessionState#mediaInfo]).voidhandlePrevious(IActionResponseListener*listener,MediaSessionId?sessionId)
Parameters
listener
IActionResponseListener* — Required
Invoked when the request is accepted or an error occurred handling the request.
sessionId
MediaSessionId? — Optional
An optional id that identifies which session this request is intended for.
If not specified, the request is not intended for any particular session and
its up to this server to interpret how it should be handled.
handleEnableShuffle()
Handles a request to enable or disable the playlist shuffle mode.voidhandleEnableShuffle(IActionResponseListener*listener,boolenable,MediaSessionId?sessionId)
- When shuffle is true, tracks within the playlist are played in a random order.
- When shuffle is false, tracks are played in their original order.
Parameters
listener
IActionResponseListener* — Required
Invoked when the request is accepted or an error occurred handling the request.
enable
bool — Required
true enables shuffle mode, false disables it.
sessionId
MediaSessionId? — Optional
An optional id that identifies which session this request is intended for.
If not specified, the request is not intended for any particular session and
its up to this server to interpret how it should be handled.
handleSetRepeatMode()
Handles a request to change the playlist repeat mode.voidhandleSetRepeatMode(IActionResponseListener*listener,RepeatModemode,MediaSessionId?sessionId)
- RepeatMode.OFF indicates that repeat mode is disabled. When playback of the current track or playlist finishes, it will not automatically restart from the beginning.
- RepeatMode.REPEAT_TRACK specifies that the current track should be repeated indefinitely. Once the track ends, it will automatically start over from the beginning.
- RepeatMode.REPEAT_PLAYLIST indicates that the entire playlist (or album, queue, etc.) should be repeated indefinitely. When the last track in the playlist finishes, playback will return to the first track and continue.
Parameters
listener
IActionResponseListener* — Required
Invoked when the request is accepted or an error occurred handling the request.
mode
RepeatMode — Required
The mode to change to.
sessionId
MediaSessionId? — Optional
An optional id that identifies which session this request is intended for.
If not specified, the request is not intended for any particular session and
its up to this server to interpret how it should be handled.
handleSetRating()
Handles a request change the rating of a media item. The rating value is in the normalized range from 0.0 (worst rating) to 1.0 (best rating). The media sesssion should update its [MediaSessionState] to reflect the current rating (see [MediaInfo#currentRating]).voidhandleSetRating(IActionResponseListener*listener,com.amazon.kepler.media.types.MediaId*id,floatrating,MediaSessionId?sessionId)
Parameters
listener
IActionResponseListener* — Required
Invoked when the request is accepted or an error occurred handling the request.
id
com.amazon.kepler.media.types.MediaId* — Required
The identifier for the media item to rate
rating
float — Required
The rating value to assign, in a normalized range from 0.0 to 1.0.
sessionId
MediaSessionId? — Optional
An optional id that identifies which session this request is intended for.
If not specified, the request is not intended for any particular session and
its up to this server to interpret how it should be handled.
handleGetMetadataInfo()
Handles requests to retrieve media metadata. The application is expected to notify the given IGetMetadataResponseListener either within the invoking thread or asynchronously later on a different thread.voidhandleGetMetadataInfo(IGetMetadataResponseListener*listener,com.amazon.kepler.media.types.MediaId*id)
Parameters
listener
IGetMetadataResponseListener* — Required
Invoked when the meta-data has been retrieved or when an error occurred handling the request.
id
com.amazon.kepler.media.types.MediaId* — Required
The identifier of the media item for which metadata is requested.
handleCustomAction()
Handles a custom action request. The requested action should be one of the items advertised in [Capabilities#actions] from [MediaSessionState#capabilities]. The media sesssion will update any associated custom control state in [MediaSessionState#controls].voidhandleCustomAction(IActionResponseListener*listener,Action*action,MediaSessionId?sessionId)
Parameters
listener
IActionResponseListener* — Required
Invoked when the request is accepted or an error occurred handling the request.
action
Action* — Required
One of the actions from [Capabilities#actions].
sessionId
MediaSessionId? — Optional
An optional id that identifies which session this request is intended for.
If not specified, the request is not intended for any particular session and
its up to this server to interpret how it should be handled.
handleGetSessionState()
Handles a request to get one or all media session states. This method is also invoked as part of endpoint discovery so should invoke the listener promptly to ensure an available endpoint is discoverable.voidhandleGetSessionState(IGetMediaSessionStateResponseListener*listener,MediaSessionId?sessionId)
Parameters
listener
IGetMediaSessionStateResponseListener* — Required
Invoked when the media session state has been retrieved or when an error occurred handling the request.
sessionId
MediaSessionId? — Optional
An optional id that identifies which session this request is intended for.
If not specified, the request is to retrieve all known media session states.

