SyncMediaPlayer

interface SyncMediaPlayer

Used for playing synchronized media such as EPUB Media Overlays or TTS (Text-To-Speech).

Create a new player by calling ReadingSystemEngine.createSyncMediaPlayer with a SyncMediaTimeline.

The actual rendering of media such as audio or video are performed by SyncMediaObjectRenderers. These are currently not exposed in this API.

A SyncMediaPlayer can be attached to a ReaderView by assigning the player to ReaderView.syncMediaPlayer. When a SyncMediaPlayer is attached to a ReaderView, they are able to synchronize positions and enable features such as text highlighting (if the synchronized media format supports it).

Functions

Link copied to clipboard

Adds an instance of OnSyncMediaPlayerEventListener to the player. It will produce events with information about the playback state.

Link copied to clipboard

Attempts to synchronize the player with the ReaderView using the given method.

Link copied to clipboard
abstract fun pause()

Pauses media playback.

Link copied to clipboard
abstract fun play()

Attempts to resume playback from the current timeline position as soon as the player is ready. The player will pause if it fails to resume playback.

Link copied to clipboard

Removes an instance of OnSyncMediaPlayerEventListener from the player.

Link copied to clipboard
abstract fun seekToApproximateTimeMs(timeInMs: Int)

Seek to the approximate time from timeline start in milliseconds.

Link copied to clipboard
abstract fun seekToNextSegment(snapToVisiblePagesBoundary: Boolean = false)

Seeks to the next segment in the timeline, if such segment exists.

Link copied to clipboard
abstract fun seekToPreviousSegment(snapToVisiblePagesBoundary: Boolean = false)

Seeks to the previous segment in the timeline, if such segment exists.

Link copied to clipboard

Seeks to a position in the timeline.

Properties

Link copied to clipboard

Gets the approximate elapsed time from timeline start to current position in milliseconds.

Link copied to clipboard
abstract val atEnd: Boolean

If the player has reached the end of the timeline.

Link copied to clipboard
abstract val atStart: Boolean

If the player is at the start of the timeline.

Link copied to clipboard

Gets/sets the options related to how the SyncMediaPlayer automatically synchronizes with the ReaderView. Disable managed synchronization by setting SyncMediaManagedReaderViewSynchronizationOptions.enabled to false.

Link copied to clipboard
abstract var muted: Boolean

Gets/sets if audio should be muted.

Link copied to clipboard
abstract val paused: Boolean

If the player is currently in paused state

Link copied to clipboard
abstract var playbackRate: Double

Gets/sets the playback rate. This must be a value between 0.25 and 5.0, where 1.0 is "normal speed". Values lower than 1.0 make the media play slower than normal, higher values make it play faster.

Link copied to clipboard
abstract val playing: Boolean

If the player is currently playing the media in the timeline. This is the same as checking: !paused&&ready

Link copied to clipboard

Gets/sets the synchronization wait behavior for the SyncMediaPlayer when it is attached to a ReaderView. See SyncMediaReaderViewSynchronizationWaitBehavior for a description on how each mode works.

Link copied to clipboard
abstract val ready: Boolean

Returns true if the player is ready to play. Returns false if the player is currently seeking or waiting for data to be loaded. Returns false if the player is waiting to become synchronized with the ReaderView.

Link copied to clipboard
abstract val seeking: Boolean

Returns true if the player is currently seeking to a new timeline position

Link copied to clipboard

BasicSyncMediaTimeline instance used to create this player.

Link copied to clipboard

The current timeline position of the player

Link copied to clipboard
abstract var volume: Double

Gets/sets the volume as a value between 0.0 and 1.0.

Link copied to clipboard

Returns true if the player is waiting for SyncMediaObjectRenderers to load data. (SyncMediaObjectRenderers are currently not exposed in this API.)

Link copied to clipboard

Returns true if the player is waiting to become synchronized with the ReaderView.