toggleAudio method
Future<void>
toggleAudio(
{ - bool? forceValue,
})
override
Implementation
@override
Future<void> toggleAudio({bool? forceValue}) async {
if (_mParticipant == null) return;
final tracks = _localStream?.getAudioTracks() ?? [];
if (_mParticipant!.isAudioEnabled) {
for (final track in tracks) {
track.enabled = forceValue ?? false;
}
} else {
for (final track in tracks) {
track.enabled = forceValue ?? true;
}
}
_mParticipant!.isAudioEnabled =
forceValue ?? !_mParticipant!.isAudioEnabled;
_notify(CallbackEvents.shouldBeUpdateState);
if (_roomId != null) {
_socketEmiter.setAudioEnabled(
forceValue ?? _mParticipant!.isAudioEnabled,
);
}
}