toggleSpeakerphone method

Future<void> toggleSpeakerphone(
  1. bool isSpeaker
)

Implementation

Future<void> toggleSpeakerphone(bool isSpeaker) async {
  try {
    final deviceName = isSpeaker ? 'SPEAKER_PHONE' : 'EARPIECE';
    await EnxRtc.switchMediaDevice(deviceName);
    selectedDevice.value = isSpeaker ? 'Speakerphone' : 'Earpiece';
  } catch (e) {
    print('Error in toggleSpeakerphone: $e');
  }
}