AudioService
The AudioService allows an application to get an audio connection and manage it.
In this service the application:
- Calls the getSoundManager method to retrieve the static SoundManager. Then, it initializes the SoundManager through the preInitSounds method.
- Calls the currentRoute or getAvailableRoutes method to get the current or available routes. When the audio route changes, the application is notified about it via the AudioRouteChangeEvent. The checkOutputRoute method enables checking route side effects for internal management.
- Can ask for a focus on currently available or valid audio routes through the requestAudioFocus method and removes this focus by calling the abandonAudioFocusRequest.
- Can call the enable method to start audio service. The application can also disable and stop the audio service.
- Can call the playSoundType method to play audio and calls the stopSoundType to stop it.
- Can call the setSound method to attach assets.
- Can activate or deactivate the NS mode through the enableNoiseSuppressor.
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
Name | Type | Description |
---|---|---|
applicationContext | Context | non 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
Registers the external listeners to update the MediaDevice platform.
Parameters
Name | Type | Description |
---|---|---|
callback | SoundManager.Call<List> | callback to register |
Returns: boolean - informs if the register call has been properly be done.
unregisterUpdateDevices
▸ unregisterUpdateDevices(callback
: SoundManager.Call<List>): void
Deregisters the external listeners to update the MediaDevice platform.
Parameters
Name | Type | Description |
---|---|---|
callback | SoundManager.Call<List> | callback to deregister |
isNotFiltered
▸ isNotFiltered(@NonNull device
: MediaDevice): boolean
Checks if the device is compatible with the system, and, therefore can be filtered.
Parameters
Name | Type | Description |
---|---|---|
device | MediaDevice | non 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
Name | Type | Description |
---|---|---|
device | MediaDevice | non 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
Name | Type | Description |
---|---|---|
device | MediaDevice | non null device |
Returns: @NonNull Promise<Boolean> - the promise to resolve.
checkOutputRoute
▸ checkOutputRoute(): AudioService
Checks route side effects for internal management.
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
Name | Type | Description |
---|---|---|
type | AudioType | non null sound type |
assetName | String | non 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
Name | Type | Description |
---|---|---|
type | AudioType | non null sound type |
assetName | String | non null name of the asset |
soundMode | int | the 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
Name | Type | Description |
---|---|---|
type | AudioType | non 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
Name | Type | Description |
---|---|---|
type | AudioType | non null audio type to play |
soundMode | int | the sound mode |
Returns: @NonNull AudioService - the current instance.
stopSoundType
▸ stopSoundType(@NonNull audioType
: AudioType): AudioService
Stops the given type of audio.
Parameters
Name | Type | Description |
---|---|---|
audioType | AudioType | non 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
Name | Type | Description |
---|---|---|
audioType | AudioType | non null audio type |
soundMode | int | the 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.
disable
▸ disable(): AudioService
Disables the AudioService and stops elements inside it.
Returns: @NonNull AudioService - the current instance.
enableNoiseSuppressor
▸ enableNoiseSuppressor(enable
: boolean): boolean
Activates or deactivates the NS mode.
Parameters
Name | Type | Description |
---|---|---|
enable | boolean | the 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.