startVideoRecording method

  1. @override
Future<void> startVideoRecording({
  1. onLatestImageAvailable? onAvailable,
  2. bool imageStream = false,
})
override

Start a video recording.

You may optionally pass an onAvailable callback to also have the video frames streamed to this callback.

The video is returned as a XFile after calling stopVideoRecording. Throws a CameraException if the capture fails.

enablePersistentRecording parameter configures the recording to be a persistent recording. A persistent recording can only be stopped by explicitly calling stopVideoRecording and will ignore events that would normally cause recording to stop, such as lifecycle events or explicit calls to setDescription while recording is in progress. Currently a no-op on platforms other than Android.

Implementation

@override
Future<void> startVideoRecording({
  onLatestImageAvailable? onAvailable,
  bool imageStream = false,
}) async {
  if (value.isStreamingImages) {
    await stopImageStream();
  }

  if (!imageStream) {
    await super.startVideoRecording(onAvailable: onAvailable);
    return;
  }

  await super.startVideoRecording(
    onAvailable: (image) {
      onAvailable?.call(image);
      _processCameraImage(image);
    },
  );
}