toggleSpeakerPhone method

  1. @override
Future<void> toggleSpeakerPhone({
  1. bool? forceValue,
})
override

Implementation

@override
Future<void> toggleSpeakerPhone({bool? forceValue}) async {
  if (_mParticipant == null) return;

  _mParticipant?.isSpeakerPhoneEnabled =
      forceValue ?? !_mParticipant!.isSpeakerPhoneEnabled;

  if (WebRTC.platformIsMobile) {
    await Helper.setSpeakerphoneOn(_mParticipant!.isSpeakerPhoneEnabled);

    if (_mParticipant?.isSpeakerPhoneEnabled ?? false) {
      await Helper.setSpeakerphoneOnButPreferBluetooth();
    }
  }

  _notify(CallbackEvents.shouldBeUpdateState);
}