startVideoCapturing method

  1. @override
Future<void> startVideoCapturing(
  1. VideoCaptureOptions options
)

Starts a video recording and/or streaming session.

Please see VideoCaptureOptions for documentation on the configuration options.

Implementation

@override
Future<void> startVideoCapturing(VideoCaptureOptions options) {
  if (options.streamCallback != null || options.streamOptions != null) {
    throw UnimplementedError('Streaming is not currently supported on web');
  }

  try {
    final Camera camera = getCamera(options.cameraId);

    // Add camera's video recording errors to the camera events stream.
    // The error event fires when the video recording is not allowed or an unsupported
    // codec is used.
    _cameraVideoRecordingErrorSubscriptions[options.cameraId] =
        camera.onVideoRecordingError.listen((html.ErrorEvent errorEvent) {
      cameraEventStreamController.add(
        CameraErrorEvent(
          options.cameraId,
          'Error code: ${errorEvent.type}, error message: ${errorEvent.message}.',
        ),
      );
    });

    return camera.startVideoRecording(maxVideoDuration: options.maxDuration);
  } on html.DomException catch (e) {
    throw PlatformException(code: e.name, message: e.message);
  } on CameraWebException catch (e) {
    _addCameraErrorEvent(e);
    throw PlatformException(code: e.code.toString(), message: e.description);
  }
}