Interface AudioController
-
- All Implemented Interfaces:
public interface AudioControllerControls different audio settings. This object is only valid while the connected SinchClient is started. As soon as the SinchClient is stopped, it is invalidated and must not be used.
By default Sinch SDK does not try to force any specific audio device for input or output or adjust volume levels. That means that if you don't interact with AudioController or Android AudioManager it's the OS that decides which device to use based on:
AudioManager.MODE_IN_COMMUNICATION that is set internally by the SDK during the time the call is established.
AudioManager.STREAM_VOICE_CALL being the type of the stream the audio is played on.
You have several options to manipulate this behavior:
Use enableSpeaker / disableSpeaker methods (see method specific docs for more information).
Use enableAutomaticAudioRouting to allow the SDK to select automatically the communication device.
Implement your own logic based on callbacks SDK provides and interacting with Android AudioManager directly.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public enumAudioController.UseSpeakerphonepublic final classAudioController.AudioRoutingConfigAutomatic routing configuration data.
-
Method Summary
Modifier and Type Method Description abstract Unitmute()Mutes audio input. abstract Unitunmute()Unmutes audio input. abstract UnitenableSpeaker()Enables speaker mode. abstract UnitdisableSpeaker()Disables speaker mode. abstract UnitsetLocalAudioListener(LocalAudioListener listener)Sets a listener for the local audio listener. abstract UnitenableAutomaticAudioRouting(AudioController.AudioRoutingConfig audioRoutingConfig)Enables automatic audio routing between earpiece, speakerphone, wired headset and bluetooth audio devices. abstract UnitdisableAutomaticAudioRouting()Disables automatic audio routing (AAR). abstract BooleanisMute()Indicates whether the microphone is muted. abstract BooleanisSpeakerOn()Indicates whether the speaker is enabled. abstract BooleanisAutomaticAudioRoutingEnabled()Indicates whether the automatic audio routing is enabled. -
-
Method Detail
-
enableSpeaker
abstract Unit enableSpeaker()
Enables speaker mode.
Method sets current communication device to AudioDeviceInfo.TYPE_BUILTIN_SPEAKER disabling automatic audio routing functionality if it was previously enabled.
-
disableSpeaker
abstract Unit disableSpeaker()
Disables speaker mode.
Method resets any previously selected communication device disabling automatic audio routing functionality if it was previously enabled.
Note that by calling this the OS picks next communication device automatically. Use automatic audio routing or your custom logic if you want to override this behavior. Eg. by invoking
enableAutomaticAudioRouting(AudioRoutingConfig(UseSpeakerphone.SPEAKERPHONE_FALSE, true))SDK will select either built-in earpiece or bluetooth device if available.
-
setLocalAudioListener
abstract Unit setLocalAudioListener(LocalAudioListener listener)
Sets a listener for the local audio listener.
- Parameters:
listener- listener that will be called when the recording is being started, stopped and when new audio buffer is available or null to remove any previously assigned listeners.
-
enableAutomaticAudioRouting
abstract Unit enableAutomaticAudioRouting(AudioController.AudioRoutingConfig audioRoutingConfig)
Enables automatic audio routing between earpiece, speakerphone, wired headset and bluetooth audio devices. Priorities are following:
Bluetooth (if available and AudioRoutingConfig.isBluetoothAudioManaged == true).
Wired Headset.
Default audio device if AudioRoutingConfig.useSpeakerphoneState is UseSpeakerphone.SPEAKERPHONE_TRUE or UseSpeakerphone.SPEAKERPHONE_FALSE, or Proximity sensor's based decision (speakerphone / earpiece) if AudioRoutingConfig.useSpeakerphoneState is UseSpeakerphone.SPEAKERPHONE_AUTO.
Default audio device (speakerphone/ earpiece) is set using AudioRoutingConfig.useSpeakerphoneState parameter.
- Parameters:
audioRoutingConfig- automatic routing configuration data.
-
disableAutomaticAudioRouting
abstract Unit disableAutomaticAudioRouting()
Disables automatic audio routing (AAR). When AAR is disabled use AudioController.enableSpeaker to toggle between speakerphone and earpiece.
-
isSpeakerOn
abstract Boolean isSpeakerOn()
Indicates whether the speaker is enabled.
-
isAutomaticAudioRoutingEnabled
abstract Boolean isAutomaticAudioRoutingEnabled()
Indicates whether the automatic audio routing is enabled.
-
-
-
-