Home > @magiclane/maps-sdk > SoundPlayingService

SoundPlayingService class

High-level static API for playing sounds and TTS through the SDK.

This class exposes only static members and acts as a thin bridge to the native sound engine. Use SoundPlayingListener to observe playback lifecycle events, and SoundPlayingPreferences to configure per-severity playback settings.

Signature:

export declare abstract class SoundPlayingService 

Properties

Property

Modifiers

Type

Description

audioLowLatencyOutputFrameSize

static

readonly

number

Get the audio low-latency output frame size (Android only).

On iOS this returns 0.

audioOutput

static

AudioOutput

Returns the currently selected audio output type.

callTimingDelay

static

number

Returns the current call timing delay (milliseconds).

canPlaySounds

static

boolean

Returns whether automatic playback of TTS instructions is enabled.

nativeOutputSampleRate

static

readonly

number

Get the native audio output sample rate (Android only).

On iOS this returns 0.

soundPlayingListener

static

readonly

SoundPlayingListener

Obtain the singleton SoundPlayingListener used to observe playback events.

The listener is created once and registered with the platform. Use SoundPlayingListener.registerOnStart and SoundPlayingListener.registerOnStop to receive playback events.

soundSessionRequestPreferences

static

SoundSessionRequestPreferences

Return the currently configured sound session request preferences.

The returned instance is a copy; set soundSessionRequestPreferences to persist changes.

ttsDefaultLanguage

static

readonly

Language

Return the Language currently being used in the system as the default TTS language.

voiceVolume

static

number

Returns the current voice (TTS) volume.

warningsVolume

static

number

Returns the current warnings volume.

Methods

Method

Modifiers

Description

cancelNavigationSoundsPlaying()

static

Cancel currently playing navigation sounds.

Use this to immediately stop navigation-related audio playback.

getSoundPlayingPreferences(severity)

static

Retrieve sound playback preferences for the given severity.

The returned instance is a copy; call setSoundPlayingPreferences to persist modifications.

playSound(soundId)

static

Play a pre-recorded sound by id.

playText(text, severity)

static

Play the given text using TTS.

setSoundPlayingPreferences(soundPlayingPreferences, severity)

static

Apply sound playback preferences for the given severity.

Only fields present in the provided SoundPlayingPreferences instance are applied. To change preferences, modify an instance returned by getSoundPlayingPreferences and call this method to persist the change.

This method does not take into account any ongoing system interruptions.