toggleAudioInput method

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

Implementation

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

  final tracks = _localCameraStream?.getAudioTracks() ?? [];
  final newValue = forceValue ?? !_mParticipant!.isAudioEnabled;

  for (final track in tracks) {
    track.enabled = newValue;
  }

  _mParticipant = _mParticipant?.copyWith(isAudioEnabled: newValue);
  _notify(CallbackEvents.shouldBeUpdateState);

  if (_currentRoomId != null) {
    _wsEmitter.toggleAudio(newValue);
  }
}