Adds an EngineEvent listener to this instance.
The EngineEvent type to listen to.
The object or callback function that should receive events.
Adds a SyncMediaObjectRenderer to this player, possibly replacing an existing media object renderer if they handle the same SyncMediaObjectRefType.
Attempts to synchronize the player with the ReaderView using the given method
.
If managed synchronization is enabled, this method is called automatically by the reading system.
See SyncMediaPlayer.setManagedReaderViewSynchronization()
for more details.
If the SyncMediaPlayer is not attached to a ReaderView, this method does nothing.
the method that will be used to attempt synchronization.
If set, it will be used instead of resolving a new SyncMediaTimelinePosition from the ReaderView's readingPosition. (Only relevant if method is SEEK_SYNC_MEDIA)
If set, it will be used instead of resolving a new ContentLocation from the current timelinePosition. (Only relevant if method is NAVIGATE_VIEW_GOTO)
Gets the approximate elapsed time from timeline start to current position in milliseconds.
Get the approximate elapsed time from timeline start in milliseconds to the specified timeline position.
Get all EngineEvent listeners for the specified type that has been added to this instance.
Get all SyncMediaObjectRenderer instances currently attached to this player.
Get the name of this SyncMediaPlayer.
Returns the current active playback range, previously set with setPlaybackRange()
.
Returns null if there is no active playback range.
Get the current playback rate, where 1.0 means normal speed. For example: 0.5 is half speed, and 2.0 is double speed.
Get the ReaderView instance that this player is currently attached to.
Get the synchronization wait behavior used when this player is attached to a ReaderView.
Get the ReadingSystemEngine that created this player.
Get a copy of the current skippability options for this player.
Get the SyncMediaTimeline that this player is using.
Get this player's current timeline position.
Get the current volume as a value between 0.0 and 1.0
If the player has reached the end of the timeline. Calling play() has no effect when this method returns true.
If the player is currently at the start of the timeline.
Checks if this instance has been destroyed.
If audio is muted.
If the player is currently paused.
Even if this method returns false,
the player might still be waiting for media to load or for ReaderView synchronization.
Also see isWaitingForMediaObjectRenderers()
and isWaitingForReaderViewSynchronization()
.
If the player is currently playing media.
This is a shorthand for: !isPaused() && isReady()
True if the media player is ready to play. False if either isWaitingForReaderViewSynchronization() or isWaitingForMediaObjectRenderers() returns true.
Clients can still call play() to make the media player resume playback when it has reached ready state.
Returns true if the player is currently seeking to a new timeline position.
Returns true if the player is waiting for SyncMediaObjectRenderers to load data.
Returns true if the player is waiting to become synchronized with the ReaderView.
Pause playback.
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.
Removes an EngineEvent listener that was previously added to this instance.
The EngineEvent type to remove.
The object or callback function to remove.
Removes the specified SyncMediaObjectRenderer from this player.
true if the renderer was found and removed, false otherwise.
If the SyncMediaPlayer has an active playback range, it will be removed,
and the engine event syncMediaRangePlaybackRemoved
will be emitted by the reading system.
The event object's reason
property will be set to SyncMediaRangePlaybackRemoveReason.APP_GENERATED
.
This method has no effect if the SyncMediaPlayer don't have an active playback range.
Seek to the approximate time from timeline start in milliseconds.
true if the player started seeking, false if it was not possible to do so.
Seeks to the next segment in the timeline, if such segment exists.
If set to true while seeking from a segment that spans across the end of the
currently visible pages and the next page(s), the media player will seek inside that segment to match the
start position of the content on the next page. Calling seekToNextSegment
again will then seek to the
beginning of the next segment.
If set to false, the media player will seek to the beginning of the next segment.
true if the player started seeking to the new segment, false if it was not possible to do so.
Seeks to the previous segment in the timeline, if such segment exists.
If set to true while seeking to a segment that spans across the beginning of
the currently visible pages and the previous page(s), the media player will seek inside that segment to
match the starting position of the currently visible content. Calling seekToPreviousSegment
again will
then seek to the beginning of the segment.
If set to false, the media player will seek to the beginning of the previous segment.
true if the player started seeking to the new segment, false if it was not possible to do so.
Seek to a position in the timeline.
true if the player started seeking to the new position, false if it was not possible to do so.
Sets if the SyncMediaPlayer should automatically keep synchronized with the ReaderView. Defaults to being enabled.
Set if audio should be muted.
Sets a new active playback range on this SyncMediaPlayer, and by default, immediately seeks to range.start
.
When the SyncMediaPlayer reaches range.end
during playback, it will automatically pause
and the engine event syncMediaRangeEndReached
will be emitted by the reading system.
By default, the playback range is removed when the SyncMediaPlayer reaches range.end
, but you
can change this behaviour by setting removeRangeOnEndReached
to false in the options object.
An active playback range can be removed by calling removedPlaybackRange()
.
The playback range may also be removed due to seeking, either by calling any of the seek
methods
in ISyncMediaPlayer, or due to a synchronization operation with an attached ReaderView.
You can control how seeking affects the active playback range by setting a seekBehavior
in the options
object.
When a playback range is removed, the engine event syncMediaRangePlaybackRemoved
is emitted by the reading system.
The property ISyncMediaRangeEngineEvent.reason
contains details to why the playback range was removed.
The resulting playback range.
Sets the playback rate of the media player as a value between 0.25 and 5.0.
A value of 1.0 means "normal speed". Values less than 1.0 make the media to play slower than normal. Values greater than 1.0 make it play faster.
The new playback rate. The value will be clamped between 0.25 and 5.0.
Sets the synchronization wait behavior for the SyncMediaPlayer when it is attached to a ReaderView. The default value is WAIT_OUTSIDE_ADJACENT. See SyncMediaPlayerViewSynchronizationBehavior for a description on how each mode works.
Set options to use for skippability.
Sets the volume for the media player as a value between 0.0 and 1.0.
The new volume. The value will be clamped between 0.0 and 1.0.
Generated using TypeDoc
Used for playing synchronized media such as EPUB Media Overlays or TTS (Text-To-Speech).
The SyncMediaPlayer coordinates the playback of a SyncMediaTimeline and exposes methods for controlling playback, such as play/pause/skip.
Create a new player by calling
ReadingSystemEngine.createSyncMediaPlayer(syncMediaTimeline)
. SyncMediaTimeline can be created from ReaderPublication instances. For example:EpubReaderPublication.createMediaOverlaySyncMediaTimeline()
orEpubReaderPublication.createTtsSyncMediaTimeline()
.The SyncMediaTimeline can consist of various media formats such as audio, video, TTS, content highlighting instructions. Several media objects can be played parallel. The actual playback of each type of media is handled by SyncMediaObjectRenderers. All this is handled by the SyncMediaPlayer.
By default, SyncMediaPlayer will create default SyncMediaObjectRenderer using SyncMediaTimeline.createDefaultMediaObjectRenderers(). You can override this behaviour by setting the SyncMediaPLayerInitOption
addDefaultMediaObjectRenderers
to false, and then manually calladdMediaObjectRenderer()
for each media type you wish to support.A SyncMediaPlayer is able to synchronize playback position with publication content visible in the ReaderView. This can be used to enable features such as test highlighting, automatic page turn, etc. To enable this feature, call
readerView.setSyncMediaPlayer()
.