MapboxVoiceInstructionsPlayer

class MapboxVoiceInstructionsPlayer @JvmOverloads constructor(    context: Context,     language: String,     options: VoiceInstructionsPlayerOptions = defaultOptions(),     audioFocusDelegate: AsyncAudioFocusDelegate = defaultAudioFocusDelegate(context, options),     timerFactory: Provider<Timer> = defaultTimerFactory())

Hybrid implementation of MapboxVoiceInstructionsPlayer combining VoiceInstructionsTextPlayer and VoiceInstructionsFilePlayer speech players. NOTE: do not use lazy initialization for this class since it takes some time to initialize the system services required for on-device speech synthesis. With lazy initialization there is a high risk that said services will not be available when the first instruction has to be played. MapboxVoiceInstructionsPlayer should be instantiated in Activity#onCreate.

Parameters

context

Context

language

Locale language (in a format acceptable by Locale)

audioFocusDelegate
timerFactory

Provider (optional)

Constructors

Link copied to clipboard
fun MapboxVoiceInstructionsPlayer(    context: Context,     language: String,     options: VoiceInstructionsPlayerOptions = defaultOptions(),     audioFocusDelegate: AudioFocusDelegate)
Link copied to clipboard
fun MapboxVoiceInstructionsPlayer(    context: Context,     language: String,     options: VoiceInstructionsPlayerOptions = defaultOptions(),     audioFocusDelegate: AsyncAudioFocusDelegate = defaultAudioFocusDelegate(context, options),     timerFactory: Provider<Timer> = defaultTimerFactory())

Functions

Link copied to clipboard
fun clear()

Clears any announcements queued.

Link copied to clipboard
fun play(announcement: SpeechAnnouncement, consumer: MapboxNavigationConsumer<SpeechAnnouncement>)

Given SpeechAnnouncement the method will play the voice instruction. If a voice instruction is already playing or other announcement are already queued, the given voice instruction will be queued to play after.

Link copied to clipboard
fun shutdown()

Releases the resources used by the speech player. If called while an announcement is currently playing, the announcement should end immediately and any announcements queued should be cleared.

Link copied to clipboard
fun updateLanguage(language: String)

Change language in runtime.

Link copied to clipboard
fun volume(state: SpeechVolume)

The method will set the volume to the specified level from SpeechVolume. Volume is specified as a float ranging from 0 to 1 where 0 is silence, and 1 is the maximum volume (the default behavior).