Skip to content

@capgo/camera-preview

The main interface for the CameraPreview plugin.

The main interface for the CameraPreview plugin.

  • start - Starts the camera preview.
  • stop - Stops the camera preview.
  • capture - Captures a picture from the camera.
  • captureSample - Captures a single frame from the camera preview stream.
MethodDescription
startStarts the camera preview.
stopStops the camera preview.
captureCaptures a picture from the camera.
captureSampleCaptures a single frame from the camera preview stream.
getSupportedFlashModesGets the flash modes supported by the active camera.
setAspectRatioSet the aspect ratio of the camera preview.
getAspectRatioGets the current aspect ratio of the camera preview.
setGridModeSets the grid mode of the camera preview overlay.
getGridModeGets the current grid mode of the camera preview overlay.
checkPermissionsChecks the current camera (and optionally microphone) permission status without prompting the system dialog.
requestPermissionsRequests camera (and optional microphone) permissions. If permissions are already granted or denied, the current status is returned without prompting. When showSettingsAlert is true and permissions are denied, a platform-specific alert guiding the user to the app settings will be presented.
getHorizontalFovGets the horizontal field of view for the active camera. Note: This can be an estimate on some devices.
getSupportedPictureSizesGets the supported picture sizes for all cameras.
setFlashModeSets the flash mode for the active camera.
flipToggles between the front and rear cameras.
setOpacitySets the opacity of the camera preview.
stopRecordVideoStops an ongoing video recording.
startRecordVideoStarts recording a video.
isRunningChecks if the camera preview is currently running.
getAvailableDevicesGets all available camera devices.
getZoomGets the current zoom state, including min/max and current lens info.
getZoomButtonValuesReturns zoom button values for quick switching. - iOS/Android: includes 0.5 if ultra-wide available; 1 and 2 if wide available; 3 if telephoto available - Web: unsupported.
setZoomSets the zoom level of the camera.
getFlashModeGets the current flash mode.
removeAllListenersRemoves all registered listeners.
setDeviceIdSwitches the active camera to the one with the specified deviceId.
getDeviceIdGets the ID of the camera device that is currently bound. On Android, if a physical-lens request falls back to a logical camera, this returns the bound logical camera ID.
getPreviewSizeGets the current preview size and position.
setPreviewSizeSets the preview size and position.
setFocusSets the camera focus to a specific point in the preview.
addListenerAdds a listener for screen resize events.
addListenerAdds a listener for orientation change events.
deleteFileDeletes a file at the given absolute path on the device. Use this to quickly clean up temporary images created with storeToFile. On web, this is not supported and will throw.
getSafeAreaInsetsGets the safe area insets for devices. Returns the orientation-aware notch/camera cutout inset and the current orientation. In portrait mode: returns top inset (notch at top). In landscape mode: returns left inset (notch moved to side). This specifically targets the cutout area (notch, punch hole, etc.) that all modern phones have.
getOrientationGets the current device orientation in a cross-platform format.
getExposureModesReturns the exposure modes supported by the active camera. Modes can include: ‘locked’, ‘auto’, ‘continuous’, ‘custom’.
getExposureModeReturns the current exposure mode.
setExposureModeSets the exposure mode.
getExposureCompensationRangeReturns the exposure compensation (EV bias) supported range.
getExposureCompensationReturns the current exposure compensation (EV bias).
setExposureCompensationSets the exposure compensation (EV bias). Value will be clamped to range.
getPluginVersionGet the native Capacitor plugin version.

This reference is synced from src/definitions.ts in capacitor-camera-preview.