startRecordingVideo method

Future<void> startRecordingVideo()

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

Implementation

Future<void> startRecordingVideo() async {
  if (isControllerBusy) {
    return;
  }
  isControllerBusy = true;
  try {
    await controller.startVideoRecording();
    if (isRecordingRestricted) {
      recordCountdownTimer = Timer(
        pickerConfig.maximumRecordingDuration!,
        stopRecordingVideo,
      );
    }
    recordStopwatch
      ..reset()
      ..start();
  } catch (e, s) {
    if (!controller.value.isRecordingVideo) {
      handleErrorWithHandler(e, s, pickerConfig.onError);
      return;
    }
    try {
      await controller.stopVideoRecording();
    } catch (e, s) {
      recordCountdownTimer?.cancel();
      isShootingButtonAnimate = false;
      handleErrorWithHandler(e, s, pickerConfig.onError);
    } finally {
      recordStopwatch.stop();
    }
  } finally {
    safeSetState(() {
      isControllerBusy = false;
    });
  }
}