startRecordingVideo method

Future<void> startRecordingVideo()

Set record file path and start recording. 设置拍摄文件路径并开始录制视频

Implementation

Future<void> startRecordingVideo() async {
  if (controller.value.isRecordingVideo) {
    return;
  }
  try {
    await controller.startVideoRecording();
    if (isRecordingRestricted) {
      recordCountdownTimer = Timer(
        pickerConfig.maximumRecordingDuration!,
        stopRecordingVideo,
      );
    }
    recordStopwatch
      ..reset()
      ..start();
  } catch (e, s) {
    realDebugPrint('Error when start recording video: $e');
    if (!controller.value.isRecordingVideo) {
      handleErrorWithHandler(e, pickerConfig.onError, s: s);
      return;
    }
    try {
      await controller.stopVideoRecording();
    } catch (e, s) {
      realDebugPrint(
        'Error when stop recording video after an error start: $e',
      );
      recordCountdownTimer?.cancel();
      isShootingButtonAnimate = false;
      handleErrorWithHandler(e, pickerConfig.onError, s: s);
    }
    recordStopwatch.stop();
  } finally {
    safeSetState(() {});
  }
}