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
Skip to main content
An interface that represents a PlayerClient.

Properties

clearTextView()

clearTextView: (sessionId?) => Promise<void> Request the media session in PlayerServer to clear the KeplerCaptionsView rendering the captions content.

Parameters

sessionId?
IPlayerSessionId Optional. The session ID to target for clearing the captions surface. If not specified, the PlayerServer decides how to handle the request.

Returns

Promise<void> A Promise that resolves when the request is successfully handled, or rejects with an error if the request fails.

Example


clearVideoView()

clearVideoView: (sessionId?) => Promise<void> Request the media session in PlayerServer to clear the KeplerVideoSurfaceView rendering the video content.

Parameters

sessionId?
IPlayerSessionId Optional. The session ID to target for clearing the video surface. If not specified, the PlayerServer decides how to handle the request.

Returns

Promise<void> A Promise that resolves when the request is successfully handled, or rejects with an error if the request fails.

Example


destroy()

destroy: () => void Destroys the kepler player client instance and stop the Kepler Player Service. Clients are expected to call this API for cleanup of media resources when interactive components gets destroyed.

Returns

void

Example


getCurrentPosition()

getCurrentPosition: (sessionId?) => Promise<number> Request the PlayerServer to get the current playback position of media playback (in seconds).

Parameters

sessionId?
IPlayerSessionId Optional. The session ID to target with the request. If not provided, the session to target is decided by the PlayerServer.

Returns

Promise<number> A Promise that resolves when the request is successfully handled, or rejects with an error if the request fails; and it returns number indicating current playback position corresponding to sessionId in seconds.

Details

The media sesssion should update its IPlayerSessionStatus to reflect the new playback status.

Example


load()

load: (mediaInfo, loadParams?, sessionId?) => Promise<void> Request the PlayerServer to load the content using the given URL.

Parameters

mediaInfo
IPlayerSessionMediaInfo The object to describe the necessary URLs and HTTP headers to load media content.
loadParams?
IPlayerSessionLoadParams Optional. Params required to load content by URL.
sessionId?
IPlayerSessionId Optional. The session ID to target for loading content. If not specified, the PlayerServer should create a new media session.

Returns

Promise<void> A Promise that resolves when the request is successfully handled, or rejects with an error if the request fails.

Example


pause()

pause: (sessionId?) => Promise<void> Request the PlayerServer to pause playback.

Parameters

sessionId?
IPlayerSessionId Optional. The session ID to target with the request. If not provided, the session to target is decided by the PlayerServer.

Returns

Promise<void> A Promise that resolves when the request is successfully handled, or rejects with an error if the request fails.

Details

The media sesssion should update its IPlayerSessionStatus to reflect the new playback status.

Example


play()

play: (sessionId?) => Promise<void> Request the PlayerServer to start or resume playback.

Parameters

sessionId?
IPlayerSessionId Optional. The session ID to target with the request. If not provided, the session to target is decided by the PlayerServer.

Returns

Promise<void> A Promise that resolves when the request is successfully handled, or rejects with an error if the request fails.

Details

The media sesssion should update its IPlayerSessionStatus to reflect the new playback status. The Kepler player server may reset playback speed back to normal.

Example


registerBufferedRangesListener()

registerBufferedRangesListener: (listener, sessionId?) => Promise<ISubscription> Subscribes a listener to monitor changes in the buffered ranges.

Parameters

listener
IPlayerSessionBufferedRangesListener The listener to add. See IPlayerSessionBufferedRangesListener.
sessionId?
IPlayerSessionId Optional. The session ID to target with the request. If not provided, the session to target is decided by the PlayerServer.

Returns

Promise<ISubscription> A Promise that resolves with an ISubscription object. This object can be used to unsubscribe the listener when it’s no longer needed.

Example


registerErrorListener()

registerErrorListener: (listener, sessionId?) => Promise<ISubscription> Subscribes a listener to receive error from service component.

Parameters

listener
IPlayerSessionErrorListener The listener to add. See IPlayerSessionErrorListener
sessionId?
IPlayerSessionId Optional. The session ID to target with the request. If not provided, the session to target is decided by the PlayerServer.

Returns

Promise<ISubscription> A Promise that resolves with an ISubscription object. This object can be used to unsubscribe the listener when it’s no longer needed.

Example


registerMessageListener()

registerMessageListener: (listener, sessionId?) => Promise<ISubscription> Subscribes a listener to receive message from service component.

Parameters

listener
IPlayerSessionMessageListener The listener to add. See IPlayerSessionMessageListener
sessionId?
IPlayerSessionId Optional. The session ID to target with the request. If not provided, the session to target is decided by the PlayerServer.

Returns

Promise<ISubscription> A Promise that resolves with an ISubscription object. This object can be used to unsubscribe the listener when it’s no longer needed.

Example


registerPositionListener()

registerPositionListener: (listener, interval, sessionId?) => Promise<ISubscription> Subscribes a listener to monitor updates in the playback position. This position will be in seconds.

Parameters

listener
IPlayerSessionPositionListener The listener to add. See IPlayerSessionPositionListener
interval
number The interval (in seconds) at which to receive playback position updates. Must be non-negative value.
sessionId?
IPlayerSessionId Optional. The session ID to target with the request. If not provided, the session to target is decided by the PlayerServer.

Returns

Promise<ISubscription> A Promise that resolves with an ISubscription object. This object can be used to unsubscribe the listener when it’s no longer needed.

Example


registerStatusListener()

registerStatusListener: (listener, sessionId?) => Promise<ISubscription> Subscribes a listener to monitor changes in the player session status.

Parameters

listener
IPlayerSessionStatusListener The listener to add. See IPlayerSessionStatusListener
sessionId?
IPlayerSessionId Optional. The session ID to target with the request. If not provided, the session to target is decided by the PlayerServer.

Returns

Promise<ISubscription> A Promise that resolves with an ISubscription object. This object can be used to unsubscribe the listener when it’s no longer needed.

Example


registerTrackListener()

registerTrackListener: (listener, sessionId?) => Promise<ISubscription> Subscribes a listener to monitor changes in the track information.

Parameters

listener
IPlayerSessionTrackListener The listener to add. See IPlayerSessionTrackListener
sessionId?
IPlayerSessionId Optional. The session ID to target with the request. If not provided, the session to target is decided by the PlayerServer.

Returns

Promise<ISubscription> A Promise that resolves with an ISubscription object. This object can be used to unsubscribe the listener when it’s no longer needed.

Example


seek()

seek: (position, isRelative?, sessionId?) => Promise<void> Request the PlayerServer to seek to a given playback position (in seconds).

Parameters

position
number The playback position (in seconds) to seek to, either relative to the current playback position (isRelative = true); or relative to the start of the media where 0 represents the start of the media (isRelative = false).
isRelative?
boolean If the position provided is relative to the current playback position (isRelative = true) or an absolute position in the media (isRelative = false). Default value is false.
sessionId?
IPlayerSessionId Optional. The session ID to target with the request. If not provided, the session to target is decided by the PlayerServer.

Returns

Promise<void> A Promise that resolves when the request is successfully handled, or rejects with an error if the request fails.

Details

The media sesssion should update its IPlayerSessionStatus to reflect the new playback position.

Examples


sendMessage()

sendMessage: (message, sessionId?) => Promise<void> Provides a way for interactive component to send custom message to service component. Any JSON type can be sent as a message (except undefined).

Parameters

message
any Custom message to be sent. send JSON value (except undefined) as message.
sessionId?
IPlayerSessionId Optional. The session ID of the session for which custom message needs to be handled. If not provided, treat as a request for data on all sessions.

Returns

Promise<void> A Promise that resolves when the request is successfully handled, or rejects with an error if the request fails or message is undefined.

Example


setActiveTrack()

setActiveTrack: (trackType, trackId, sessionId?) => Promise<void> Request the PlayerServer to set the active track of media playback.

Parameters

trackType
ITrackType The type of the track to set as active.
trackId
string The track ID of the track to set as active.
sessionId?
IPlayerSessionId Optional. The session ID to target with the request. If not provided, the session to target is decided by the PlayerServer.

Returns

Promise<void> A Promise that resolves when the request is successfully handled, or rejects with an error if the request fails.

Details

The media sesssion should update its IPlayerSessionStatus to reflect the new playback status.

Example


setMediaControlFocus()

setMediaControlFocus: (componentInstance, mediaControlHandler?) => Promise<void> Register PlayerClientMediaControlHandler instance Available since version 2.1.0.

Parameters

componentInstance
IComponentInstance The component instance for which the handler needs to be set.
mediaControlHandler?
PlayerClientMediaControlHandler Object containing the event handlers.

Returns

Promise<void> A Promise that resolves when the request is successfully handled, or rejects with an error if the request fails, or targeted version is less than 2.1.0

Example


setMute()

setMute: (isMuted, sessionId?) => Promise<void> Request the PlayerServer to mute or unmute playback.

Parameters

isMuted
boolean If true, the media should be muted
sessionId?
IPlayerSessionId Optional. The session ID to target with the request. If not provided, the session to target is decided by the PlayerServer.

Returns

Promise<void> A Promise that resolves when the request is successfully handled, or rejects with an error if the request fails.

Details

The media sesssion should update its IPlayerSessionStatus to reflect the new playback status.

Example


setPlaybackRate()

setPlaybackRate: (playbackRate, sessionId?) => Promise<void> Request the PlayerServer to set playback rate of media playback.

Parameters

playbackRate
number The playback rate to set, like 0.25, 0.5, 2.0 etc If the input playback rate is not supported, promise will be rejected and registered IPlayerSessionErrorListener instance will receive IPlayerSessionError.
sessionId?
IPlayerSessionId Optional. The session ID to target with the request. If not provided, the session to target is decided by the PlayerServer.

Returns

Promise<void> A Promise that resolves when the request is successfully handled, or rejects with an error if the request fails.

Details

The media sesssion should update its IPlayerSessionStatus to reflect the new playback status.

Example


setTextView()

setTextView: (viewHandle, sessionId?) => Promise<void> Request the media session in PlayerServer to set the KeplerCaptionsView with the loaded content.

Parameters

viewHandle
IViewHandle Surface handle of KeplerCaptionsView.
sessionId?
IPlayerSessionId Optional. The session ID to target for setting the captions surface. If not specified, the PlayerServer decides how to handle the request.

Returns

Promise<void> A Promise that resolves when the request is successfully handled, or rejects with an error if the request fails.

Details

setTextView should be called after the media content has been loaded by calling one of the load APIs.

Example


setVideoView()

setVideoView: (viewHandle, sessionId?) => Promise<void> Request the media session in PlayerServer to set the KeplerVideoSurfaceView with the loaded content.

Parameters

viewHandle
IViewHandle The identifier for the KeplerVideoSurfaceView.
sessionId?
IPlayerSessionId Optional. The session ID to target for setting the video surface. If not specified, the PlayerServer decides how to handle the request.

Returns

Promise<void> A Promise that resolves when the request is successfully handled, or rejects with an error if the request fails.

Details

setVideoView should be called after the media content has been loaded by calling one of the load APIs.

Example


setVolume()

setVolume: (volume, sessionId?) => Promise<void> Request the PlayerServer to set volume of media playback.

Parameters

volume
number The volume to set, in the range of 0.0 to 1.0.
sessionId?
IPlayerSessionId Optional. The session ID to target with the request. If not provided, the session to target is decided by the PlayerServer.

Returns

Promise<void> A Promise that resolves when the request is successfully handled, or rejects with an error if the request fails.

Details

The media sesssion should update its IPlayerSessionStatus to reflect the new playback status.

Example


unload()

unload: (sessionId?) => Promise<void> Request the media session in PlayerServer to unload media content. To unload media content synchronously, for instance, in case when app state changes to background, call unloadSync.

Parameters

sessionId?
IPlayerSessionId Optional. The session ID to target for unloading content. If not specified, the PlayerServer decides how to handle the request.

Returns

Promise<void> A Promise that resolves when the request is successfully handled, or rejects with an error if the request fails.

Example


unloadSync()

unloadSync: (timeoutMsec, sessionId?) => IUnloadSyncStatus Request the media session in PlayerServer to unload media content synchronously. Use this API to release media resources when app state changes to background.

Parameters

timeoutMsec
number Maximum allowed time (in milliseconds) for unloadSync API to execute. Note Minimum value is 1000, and maximum value is 5000.
sessionId?
IPlayerSessionId Optional. The session ID to target for unloading content. If not specified, the PlayerServer decides how to handle the request.

Returns

IUnloadSyncStatus One of the enum values in @amazon-devices/kepler-player-server#IUnloadSyncStatus|PlayerServer IUnloadSyncStatus.

Since

2.2.0

Example

Last modified on October 2, 2025