setAudioRoute method
@detail api
@author dixing
@brief Set the current audio playback route. The default device is set via setDefaultAudioRoute{@link #RTCEngine#setDefaultAudioRoute}.
When the audio playback route changes, you will receive onAudioRouteChanged{@link #IRTCEngineEventHandler#onAudioRouteChanged}.
@param audioRoute Audio route. Refer to AudioRoute{@link #AudioRoute}.
For Android device, the valid audio playback devices may vary due to different audio device connection status. See Set the Audio Route.
@return
- 0: Success.
- < 0 : Fail. See ReturnStatus{@link #ReturnStatus} for more details
@note
- You can implement most scenarios by calling setDefaultAudioRoute{@link #RTCEngine#setDefaultAudioRoute} and the default audio route switching strategy of the RTC SDK. For details about the strategy, see Set the Audio Route. You should use this API in a few exceptional scenarios like manually switching audio route with external audio device connected.
- This interface is only supported in communication mode.
- For the volume type in different audio scenarios, refer to AudioScenarioType{@link #AudioScenarioType}.
Implementation
Future<int?> setAudioRoute(AudioRoute audioRoute) async {
$a() => ($instance as $p_a.RTCEngine)
.setAudioRoute(t_AudioRoute.code_to_android(audioRoute));
$i() => ($instance as $p_i.ByteRTCEngine)
.setAudioRoute(t_AudioRoute.code_to_ios(audioRoute));
if (Platform.isAndroid) {
return $a();
} else if (Platform.isIOS) {
return $i();
} else {
throw UnsupportedError(
'Not Support Platform ${Platform.operatingSystem}');
}
}