toggleVideoInput method

  1. @override
Future<void> toggleVideoInput({
  1. bool? forceValue,
  2. bool ignoreUpdateValue = false,
})
override

Implementation

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

  if (_mParticipant!.isSharingScreen && WebRTC.platformIsMobile) return;

  final tracks = _localCameraStream?.getVideoTracks() ?? [];
  final newValue = forceValue ?? !_mParticipant!.isVideoEnabled;

  if (kIsWeb) {
    await _handleWebVideoToggle(tracks, newValue);
  } else {
    for (final track in tracks) {
      track.enabled = newValue;
    }
  }

  if (ignoreUpdateValue) return;

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

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