stopRecording method

Future<void> stopRecording({
  1. OnVideoCallback? onVideo,
  2. OnVideoFailedCallback? onVideoFailed,
})

Implementation

Future<void> stopRecording({
  OnVideoCallback? onVideo,
  OnVideoFailedCallback? onVideoFailed,
}) async {
  var currentCapture = cameraContext.mediaCaptureController.value;
  if (currentCapture == null) {
    return;
  }
  final result = await CamerawesomePlugin.stopRecordingVideo();
  if (result) {
    _mediaCapture = MediaCapture.success(
      captureRequest: currentCapture.captureRequest,
    );
    onVideo?.call(currentCapture.captureRequest);
  } else {
    _mediaCapture = MediaCapture.failure(
      captureRequest: currentCapture.captureRequest,
    );
    onVideoFailed?.call(Exception("Error while stop recording"));
  }
  await CamerawesomePlugin.setCaptureMode(CaptureMode.video);
  cameraContext.changeState(VideoCameraState.from(cameraContext));
}