startRecordingVideo method

Future<void> startRecordingVideo()

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

Implementation

Future<void> startRecordingVideo() async {
  if (!controller.value.isRecordingVideo) {
    controller.startVideoRecording().then((dynamic _) {
      safeSetState(() {});
      if (isRecordingRestricted) {
        _recordCountdownTimer = Timer(maximumRecordingDuration!, () {
          stopRecordingVideo();
        });
      }
    }).catchError((Object e) {
      realDebugPrint('Error when start recording video: $e');
      if (controller.value.isRecordingVideo) {
        controller.stopVideoRecording().catchError((Object e) {
          realDebugPrint(
            'Error when stop recording video after an error start: $e',
          );
          stopRecordingVideo();
        });
      }
      handleErrorWithHandler(e, widget.onError);
    });
  }
}