startVideoRecording method
Future<bool>
startVideoRecording({})
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);
}
}