The audio route is the pathway audio data takes through hardware components during playback. On mobile devices, the audio route mainly includes speakerphones, earphones, or wired or Bluetooth playback devices.
This page describes how to set the audio route to the earpiece or speakerphone on a mobile device.
The SDK type and channel profile determine the default audio route, as shown in the following table:
SDK type\Channel profile | Communication profile | Live streaming profile |
---|---|---|
Audio SDK | Earpiece | Speakerphone |
Video SDK | Speakerphone | Speakerphone |
disableVideo
, enableLocalVideo
, muteLocalVideoStream
, or muteAllRemoteVideoStreams
to disable the video, the default audio route automatically switches to the one that the Audio SDK uses.If the default audio route does not meet your needs, you can call the following methods to switch the audio route:
setDefaultAudioRouteToSpeakerphone
: Call this method before joining a channel to switch the default audio route. After successfully switching the audio route, the SDK starts to use the new audio route by default.setEnableSpeakerphone
: Call this method after joining a channel to switch the current audio route. This method only switches the audio route used in the current channel. It does not affect the default audio route. If the user leaves the current channel and joins a new channel, the SDK uses the default audio route.After you switch the audio route successfully, the SDK triggers the didAudioRouteChanged
callback to indicate that the audio route has been changed.
To query whether the current audio route is the speakerphone, call isSpeakerphoneEnabled
.
If the user uses an external audio playback device such as a wired or Bluetooth headset, the audio can only be played through the external device; the SDK cannot switch the audio route to the earpiece or speakerphone. When the user uses multiple external devices, the audio is played through the external device that is connected last.
setEnableSpeakerphone
> setDefaultAudioRouteToSpeakerphone
> the default audio route.setEnableSpeakerphone
> setDefaultAudioRouteToSpeakerphone
> the default audio route.The audio route setting is affected by the volume type and the presence of external audio devices. Consider the following when troubleshooting the issue: