2020 API AWARDS WINNER - BEST IN MEDIA APIs LEARN MORE

AudioService

The AudioService allows an application to get an audio connection and manage it.

In this service the application:

Available in the package com.voxeet.sdk.services.AudioService.

Methods

getSoundManager

getSoundManager(): SoundManager

Retrieves the static SoundManager.

Returns: @Nullable SoundManager - the instance of the SoundManager or a null value if it is not initialized.

preInitSounds

preInitSounds(@NonNull applicationContext: Context): boolean

Initializes the SoundManager in cases when the SDK is not initialized. For example, when Cordova or React Native is used.

Parameters

NameTypeDescription
applicationContextContextnon null valid instance

Returns: boolean - the boolean indicating if the initialization has just happened or was initialized before using this method.

getAvailableRoutes

getAvailableRoutes(): List<AudioRoute>

Gets the available routes.

Returns: @NonNull List<AudioRoute> - the list of all possible routes.

currentRoute

currentRoute(): AudioRoute

Gets the current route used by the SoundManager instance.

Returns: @NonNull AudioRoute - the currently selected route.

registerUpdateDevices

registerUpdateDevices(callback: SoundManager.Call<List>): boolean

Register external listeners for update on platform MediaDevice.

Parameters

NameTypeDescription
callbackSoundManager.Call<List>callback to register

Returns: boolean - informs if the register call has been properly be done.

unregisterUpdateDevices

unregisterUpdateDevices(callback: SoundManager.Call<List>): void

Unregister an external listener for update on platform MediaDevice.

Parameters

NameTypeDescription
callbackSoundManager.Call<List>callback to unregister

isNotFiltered

isNotFiltered(@NonNull device: MediaDevice): boolean

Check if the device is not to be filtered. For instance, SmartWatches may be registered as compatible by the system but most won't be actually be compatible.

Parameters

NameTypeDescription
deviceMediaDevicenon null device

Returns: boolean - informs about the compatibility.

enumerateDevices

enumerateDevices(): Promise<List>

List the audio media devices on the platform.

Returns: @NonNull Promise<List> - the promise to resolve.

connect

connect(@NonNull device: MediaDevice): Promise<Boolean>

Connect the SDK to the specified device.

Parameters

NameTypeDescription
deviceMediaDevicenon null device

Returns: @NonNull Promise<Boolean> - the promise to resolve.

disconnect

disconnect(@NonNull device: MediaDevice): Promise<Boolean>

Disconnect the SDK from the specified device.

Parameters

NameTypeDescription
deviceMediaDevicenon null device

Returns: @NonNull Promise<Boolean> - the promise to resolve.

setAudioRoute

setAudioRoute(@NonNull route: AudioRoute): boolean

Changes the audio route and updates various states of sensors.

Parameters

NameTypeDescription
routeAudioRoutenon null new route to use

Returns: boolean - the boolean indicating if a switch was made.

checkOutputRoute

checkOutputRoute(): AudioService

Checks route side effects for internal management.

Returns: @NonNull AudioService - the current instance.

setSpeakerMode

setSpeakerMode(isSpeaker: boolean): void

Changes the speaker mode.

Parameters

NameTypeDescription
isSpeakerbooleanthe switch that activates and deactivates the speakers

isBluetoothHeadsetConnected

isBluetoothHeadsetConnected(): boolean

Gets the current Bluetooth device connection.

Returns: boolean - the boolean indicating if the device is currently connected or not.

isWiredHeadsetOn

isWiredHeadsetOn(): boolean

Gets the current wired headset connection state.

Returns: boolean - the boolean indicating if wired headsets are connected to the device.

isSpeakerOn

isSpeakerOn(): boolean

Checks the speaker mode.

Returns: boolean - the boolean indicating if the speakers are activated.

acquireLocks

acquireLocks(): AudioService

Acquires the system locks of the sensors.

Returns: @NonNull AudioService - the current instance.

releaseLocks

releaseLocks(): AudioService

Releases the system locks of the sensors

Returns: @NonNull AudioService - the current instance.

resetDefaultSoundType

resetDefaultSoundType(): AudioService

Resets the system audio for media or the system.

Returns: @NonNull AudioService - the current instance.

abandonAudioFocusRequest

abandonAudioFocusRequest(): AudioService

Removes the focus on the currently available or valid audio route.

Returns: @NonNull AudioService - the current instance.

requestAudioFocus

requestAudioFocus(): AudioService

Asks for a focus on the current available or valid audio route.

Returns: @NonNull AudioService - the current instance.

setSound

setSound(@NonNull type: AudioType, @NonNull assetName: String): boolean

Attaches the specific asset from the sound type name into the phone mode.

Parameters

NameTypeDescription
typeAudioTypenon null sound type
assetNameStringnon null name of the asset

Returns: boolean - information about the successful attach.

setSound

setSound(@NonNull type: AudioType, @NonNull assetName: String, soundMode: int): boolean

Attaches the specific asset from a sound type name into the specific sound mode pool.

Parameters

NameTypeDescription
typeAudioTypenon null sound type
assetNameStringnon null name of the asset
soundModeintthe sound mode reflecting the pool mode

Returns: boolean - information about the successful attach.

playSoundType

playSoundType(@NonNull type: AudioType): AudioService

Plays the specific type of audio in the phone mode.

Parameters

NameTypeDescription
typeAudioTypenon null audio type to play

Returns: @NonNull AudioService - the current instance.

playSoundType

playSoundType(@NonNull type: AudioType, soundMode: int): AudioService

Plays the given audio type.

Parameters

NameTypeDescription
typeAudioTypenon null audio type to play
soundModeintthe sound mode

Returns: @NonNull AudioService - the current instance.

stopSoundType

stopSoundType(@NonNull audioType: AudioType): AudioService

Stops the given type of audio.

Parameters

NameTypeDescription
audioTypeAudioTypenon null requested type

Returns: @NonNull AudioService - the current instance.

stopSoundType

stopSoundType(@NonNull audioType: AudioType, soundMode: int): AudioService

Stops the given type and mode of audio.

Parameters

NameTypeDescription
audioTypeAudioTypenon null audio type
soundModeintthe sound mode

Returns: @NonNull AudioService - the current instance.

stop

stop(): AudioService

Stops the service but does not free the holds or resources.

Returns: @NonNull AudioService - the current instance.

enable

enable(): AudioService

Enables the service and lets it manage sounds and mode modifications.

Returns: @NonNull AudioService - the current instance.

enableMedia

enableMedia(): AudioService

Enables the media mode in the manager to accept implementation features.

Returns: @NonNull AudioService - the current instance.

unsetMediaRoute

unsetMediaRoute(): AudioService

Unsets the media mode without restoring the phone mode. It does not hold any specific internal features.

Returns: @NonNull AudioService - the current instance.

setMediaRoute

setMediaRoute(): AudioService

Changes the Audio output to the Media mode (instead of the Phone mode).

Returns: @NonNull AudioService - the current instance.

disable

disable(): AudioService

Disables the AudioService and stops elements inside it.

Returns: @NonNull AudioService - the current instance.

updateSensors

updateSensors(@NonNull route: AudioRoute): void

Updates state of sensors given in the specified audio route.

Parameters

NameTypeDescription
routeAudioRoutenon null valid route to update the sensors

releaseSensors

releaseSensors(): void

Releases the sensors.

enableAec

enableAec(enable: boolean): boolean

Activates or deactivates the AEC mode.

Parameters

NameTypeDescription
enablebooleanthe new state

Returns: boolean - success or a failure.

enableNoiseSuppressor

enableNoiseSuppressor(enable: boolean): boolean

Activates or deactivates the NS mode.

Parameters

NameTypeDescription
enablebooleanthe new state

Returns: boolean - success or a failure.

currentMediaDevice

currentMediaDevice(): Promise<MediaDevice>

Get the currently connected media device.

Returns: Promise<MediaDevice> - the promise to resolve.

Events

AudioRouteChangeEvent

Emitted when the SDK changed the current AudioRoute.

Available in the package com.voxeet.sdk.events.sdk.AudioRouteChangeEvent.