setEnableSpeakerphone method

  1. @override
Future<void> setEnableSpeakerphone(
  1. bool enabled
)

Enables/Disables the audio playback route to the speakerphone.

If the default audio route of the SDK (see Set the Audio Route) or the setting in setDefaultAudioRoutetoSpeakerphone cannot meet your requirements, you can call this method to switch the current audio route. After successfully switching the audio route, the SDK triggers the audioRouteChanged callback to indicate the changes.

This method only sets the audio route in the current channel and does not influence the default audio route. If the user leaves the current channel and joins another channel, the default audio route is used.

Note

  • Call this method after calling joinChannel.
  • If the user uses an external audio playback device such as a Bluetooth or wired headset, this method does not take effect, and the SDK plays audio through the external device. When the user uses multiple external devices, the SDK plays audio through the last connected device.

Parameter enabled Sets whether to enable the speakerphone or earpiece:

  • true: Enable the speakerphone. The audio route is the speakerphone.
  • false: Disable the speakerphone. The audio route is the earpiece.

Implementation

@override
Future<void> setEnableSpeakerphone(bool enabled) {
  return _invokeMethod('setEnableSpeakerphone', {
    'enabled': enabled,
  });
}