startRecordingToOutputFileURL method Null safety

Future<void> startRecordingToOutputFileURL(
  1. String outputFileURL,
  2. CaptureFileOutputRecordingDelegate delegate

Starts recording media to the specified output URL.

outputFileURL: This method throws aa PlatformException if the argument isn’t a valid file URL.

delegate: A delegate object that’s notified of changes to the recording state.

A failure occurs if you attempt to record to a URL where a file exists. To overwrite the content, delete the old file before calling this method.

In macOS, calling this method from within the captureOutput:didOutputSampleBuffer:fromConnection: method guarantees that the first samples written to the new file are those passed to the delegate method.

When you stop recording by calling stopRecording, by changing files using this method, or because of an error, the framework writes any remaining file data in the background. Therefore, for the system to notify you upon completion, you must adopt the captureOutput:didFinishRecordingToOutputFileAtURL:fromConnections:error: delegate method. The recording delegate can also optionally implement methods that inform it when the output object starts writing data, when it pauses or resumes recording, and when it’s about to finish recording.

In macOS, you don’t need to call stopRecording before calling this method while another recording is in progress. If you call this method while the output object is recording, the framework preserves media samples between the old file and the new file. In iOS, to avoid any errors, you must call stopRecording before calling this method again.


Future<void> startRecordingToOutputFileURL(
  String outputFileURL,
  CaptureFileOutputRecordingDelegate delegate,
) {
  return _channel.$startRecordingToOutputFileURL(