MapboxReplayer

class MapboxReplayer

This class is similar to a music player. It will include controls like play, pause, seek.

Constructors

Link copied to clipboard
fun MapboxReplayer()

Functions

Link copied to clipboard
fun clearEvents()

Stops the player, seeks to the beginning, and clears all replay events. In order to start playing a new route, pushEvents and then play.

Link copied to clipboard
fun clearPlayedEvents()

Remove all of the events that have been emitted by ReplayEventsObserver.

Link copied to clipboard
fun durationSeconds(): Double

The duration of the replay. This value will be between 0.0 and the total duration.

Link copied to clipboard
fun eventRealtimeOffset(eventTimestamp: Double): Double

Used when the replayer is actively playing and emitting replay events. Call this from your ReplayEventsObserver to offset the current time to accurately represent when the simulated or historical event occurred - needed for sub-millisecond accuracy or when simulating routes at high frequencies @see ReplayRouteOptions.frequency.

Link copied to clipboard
fun eventSeconds(eventTimestamp: Double): Double

The time of an event, relative to the duration of the replay.

Link copied to clipboard
fun finish()

Convenience function to stop, remove listeners, and clean up the player.

Link copied to clipboard
fun play()

This will begin playing the ReplayEventBase and notifying observers registered via registerObserver

Link copied to clipboard
fun playbackSpeed(scale: Double)

This determines the speed of event playback. Default is 1.0 for 1x playback speed.

Link copied to clipboard
fun playFirstLocation()

When initializing or testing an app, it is needed and useful to decide a code location to play the first location from GPS. When it is early, you may crash. When it is late, you may start in null island - LatLng(0,0). Use this function to play the first location received from your LocationEngine.

Link copied to clipboard
fun pushEvents(events: List<ReplayEventBase>): MapboxReplayer

Appends events to be replayed. Notice the basis of your ReplayEventBase.eventTimestamp. When they are drastically different, you may need to seekTo events.

Link copied to clipboard
@RequiresPermission(anyOf = ["android.permission.ACCESS_COARSE_LOCATION", "android.permission.ACCESS_FINE_LOCATION"])
fun pushRealLocation(context: Context, eventTimestamp: Double)

When initializing or testing an app, it is needed and useful to push a device location. This helper function can be used to push the actual location into the replayer.

Link copied to clipboard
fun registerObserver(observer: ReplayEventsObserver)

Register replay event observers.

Link copied to clipboard
fun seekTo(replayEvent: ReplayEventBase)

Seek to the event you want to play from.

fun seekTo(replayTime: Double)

Seek to a time to play from.

Link copied to clipboard
fun stop()

Stop playing all remaining and incoming events. To play events, you must restart the player by calling play.

Link copied to clipboard
fun unregisterObserver(observer: ReplayEventsObserver)

Remove registered observers.

Link copied to clipboard
fun unregisterObservers()

Remove all registered observers. If the player is still playing, none of the events will be observed.