startVideoRecording method

  1. @override
Future<bool> startVideoRecording({
  1. double? maxVideoDuration,
  2. bool? enableAudio,
  3. String? url,
  4. dynamic onVideoRecordingFinished(
    1. CameraMacOSFile?,
    2. CameraMacOSException?
    )?,
})
override

Call this method to start a video recording.

Implementation

@override
Future<bool> startVideoRecording({
  /// Max video duration, expressed in seconds
  double? maxVideoDuration,

  /// Enable audio (this flag overrides the initializion parameter of the same name)
  bool? enableAudio,

  /// A URL location to save the video
  String? url,

  /// Called only when the video has reached the max duration pointed by maxVideoDuration
  Function(CameraMacOSFile?, CameraMacOSException?)? onVideoRecordingFinished,
}) async {
  try {
    registeredCallbacks["onVideoRecordingFinished"] =
        onVideoRecordingFinished;
    if (!methodCallHandlerSet) {
      methodChannel.setMethodCallHandler(_genericMethodCallHandler);
      methodCallHandlerSet = true;
    }
    final Map<String, dynamic>? result =
        await methodChannel.invokeMapMethod<String, dynamic>(
      'startRecording',
      {
        "maxVideoDuration": maxVideoDuration,
        "url": url,
        "enableAudio": enableAudio,
      },
    );
    if (result == null) {
      throw FlutterError("Invalid result");
    }
    if (result["error"] != null) {
      throw result["error"];
    } else {
      isRecording = true;
      return isRecording;
    }
  } catch (e) {
    isRecording = false;
    return Future.error(e);
  }
}