AudioService
The AudioService allows an application to get an audio connection and manage it.
In this service the application can:
-
Call the getSoundManager method to retrieve the static SoundManager. Then, the application can initialize the SoundManager through the preInitSounds method.
-
Call registerUpdateDevices and unregisterUpdateDevices to register and unregister the external listeners and update the MediaDevice platform.
-
Call enumerateDevices to list all available audio and media devices.
-
Call the connect method to connect a specific device to the SDK.
-
Call the disconnect method to disconnect a specific device from the SDK.
-
Call the checkOutputRoute method that enables checking route side effects for an internal management.
-
Ask for a focus on currently available or valid audio routes through the requestAudioFocus method and remove this focus by calling the abandonAudioFocusRequest.
-
Call the enable method to start the audio service. The application can also disable and stop the audio service.
-
Call the playSoundType method to play audio.
-
Call the stopSoundType method to stop playing audio.
-
Call the setSound method to attach assets.
-
Call currentMediaDevice to get a device that is currently connected to the SDK.
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.
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
Unregisters the external listeners to update the MediaDevice platform.
Parameters
Name | Type | Description |
---|---|---|
callback | SoundManager.Call<List> | callback to deregister |
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.
currentMediaDevice
▸ currentMediaDevice(): Promise<MediaDevice>
Get the currently connected media device.
Returns: Promise<MediaDevice> - the promise to resolve.
Updated 10 months ago