The audio route is the pathway audio data takes through different audio hardware components during playback. For example, earpieces, headphones, speakerphone, and Bluetooth devices that output sound all work as an audio route.
This page explains what audio routes are and shows you how to change the audio route from one device to another.
The default audio route is the route audio data takes within a device, such as the speakerphone on a mobile device.
Depending on the use cases, the SDK uses different default audio routes:
The audio route can be changed using any of the following approaches:
setDefaultAudioRoutetoSpeakerphone
to change the default audio route.setEnableSpeakerphone
to set the audio route temporarily.Regardless of the approach used to change the audio route, the priority of changes taking effect follows these principles:
setDefaultAudioRoutetoSpeakerphone
can change the default setting. If the current audio route is the mobile device itself, setDefaultAudioRoutetoSpeakerphone
can change the current audio route.setEnableSpeakerphone
can temporarily set the audio route to speakerphone or earpiece, regardless of whether the current audio roure is an external device, speakerphone, or earpiece. Because setEnableSpeakerphone
is a transient API, any user behavior or audio-related API call might change the transient setting of setEnableSpeakerphone
to an audio route that follows principles 1 and 2.Any change to the audio route triggers the onAudioRouteChanged
(Android) or didAudioRouteChanged
(iOS) callback. You can use this callback to get the current audio route.
The following sections explain how these approaches affect the audio route.
When a user plugs in an audio device such as headphones, the audio route automatically changes to the headphones. When multiple devices are connected, the last device connected gets the audio route.
See how the audio route changes in the following example:
Call the setDefaultAudioRoutetoSpeakerphone
method before, during, or after a call to change the defaut audio route between the earpiece and the speakerphone. The setting of this method takes effect until you call destroy
to destroy the engine.
See how the audio route changes in the following example:
setDefaultAudioRoutetoSpeakerphone(true)
.setDefaultAudioRoutetoSpeakerphone(true)
.setDefaultAudioRoutetoSpeakerphone
works on the audio route of the device only.You can call the setEnableSpeakerphone
method to temporarily change the audio route to the speakerphone, if the operating system permits.
setDefaultAudioRoutetoSpeakerphone
to set the audio route.See how the audio route changes in the following examples:
Example 1
setEnableSpeakerphone(true)
.Example 2
setEnableSpeakerphone(true)
.