### Example App Setup and Start Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/AGENTS.md Installs dependencies and starts the example application. This is used for local testing of the plugin. ```bash cd example-app bun install bun run start ``` -------------------------------- ### Install Capacitor Camera Preview Plugin (Yarn) Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Installs the @capgo/camera-preview plugin using Yarn. This is part of the manual setup process. ```bash yarn add @capgo/camera-preview ``` -------------------------------- ### Install Capacitor Camera Preview Plugin (NPM) Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Installs the @capgo/camera-preview plugin using NPM. This is part of the manual setup process. ```bash npm install @capgo/camera-preview ``` -------------------------------- ### start Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Starts the camera preview with specified options. Returns the dimensions and position of the preview. ```APIDOC ## start ### Description Starts the camera preview. ### Method start(options: CameraPreviewOptions) ### Parameters #### Path Parameters - **options** (CameraPreviewOptions) - Required - The configuration for the camera preview. ### Response #### Success Response (200) - **width** (number) - The width of the preview. - **height** (number) - The height of the preview. - **x** (number) - The x-coordinate of the preview. - **y** (number) - The y-coordinate of the preview. ### Request Example ```json { "camera": "front", "height": 200, "width": 200, "x": 0, "y": 0, "tapPhoto": true, "previewDrag": false, "toBack": false, "alpha": 1.0 } ``` ### Response Example ```json { "width": 1080, "height": 1920, "x": 0, "y": 0 } ``` ``` -------------------------------- ### Install Capacitor Skills for AI Setup Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Adds Capgo skills to your AI tool for assisted plugin installation. Use this command in conjunction with an AI prompt to install plugins. ```bash npx skills add https://github.com/cap-go/capacitor-skills --skill capacitor-plugins ``` -------------------------------- ### Record and Upload Video with Capacitor Camera Preview and Uploader Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md This example demonstrates how to record a video for 5 seconds, stop recording, get the file path, and then upload the video using the Capacitor Uploader plugin. It includes event listeners for upload progress and completion/failure. ```typescript import { CameraPreview } from '@capgo/camera-preview' import { Uploader } from '@capgo/capacitor-uploader'; async function record() { await CameraPreview.startRecordVideo({ storeToFile: true }) await new Promise(resolve => setTimeout(resolve, 5000)) const fileUrl = await CameraPreview.stopRecordVideo() console.log(fileUrl.videoFilePath) await uploadVideo(fileUrl.videoFilePath) } async function uploadVideo(filePath: string) { Uploader.addListener('events', (event) => { switch (event.name) { case 'uploading': console.log(`Upload progress: ${event.payload.percent}%`); break; case 'completed': console.log('Upload completed successfully'); console.log('Server response status code:', event.payload.statusCode); break; case 'failed': console.error('Upload failed:', event.payload.error); break; } }); try { const result = await Uploader.startUpload({ filePath, serverUrl: 'S#_PRESIGNED_URL', method: 'PUT', headers: { 'Content-Type': 'video/mp4', }, mimeType: 'video/mp4', }); console.log('Video uploaded successfully:', result.id); } catch (error) { console.error('Error uploading video:', error); throw error; } } ``` -------------------------------- ### Start Camera Preview Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Starts the camera preview with specified options. Returns the dimensions and position of the preview. Requires CameraPreviewOptions configuration. ```typescript start(options: CameraPreviewOptions) => Promise<{ width: number; height: number; x: number; y: number; }> ``` -------------------------------- ### Sync Capacitor Project Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Runs the Capacitor sync command to update native projects after plugin installation. This command is essential for the manual setup. ```bash npx cap sync ``` -------------------------------- ### Install Dependencies with Bun Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/AGENTS.md Installs project dependencies using Bun. Always use Bun and avoid npm or npx. ```bash bun install ``` -------------------------------- ### startRecordVideo Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Starts recording a video with the active camera. Supports various options to customize the recording. ```APIDOC ## startRecordVideo ### Description Starts recording a video. Supports `frameRate`, `videoCodec`, `videoStabilizationMode`, `maxDuration`, `maxFileSize`, and `disableAudio` on each call. ### Method ```typescript startRecordVideo(options: CameraPreviewOptions) => Promise ``` ### Parameters #### Path Parameters - **options** (CameraPreviewOptions) - Required - The options for video recording. ### Response #### Success Response (void) Indicates the video recording has started successfully. ### Since 0.0.1 ``` -------------------------------- ### getAvailableDevices Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Gets all available camera devices. ```APIDOC ## getAvailableDevices() ### Description Gets all available camera devices. ### Response #### Success Response (object) - **devices** (CameraDevice[]) - An array of available camera devices. ### Response Example { "devices": [ { "deviceId": "1", "name": "Back Camera" } ] } ``` -------------------------------- ### Sync Native Platforms with Bun Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/AGENTS.md Synchronizes native platforms for the example app. Use `bunx cap sync ` to update native projects after changes. ```bash bunx cap sync ``` -------------------------------- ### startBarcodeScanner Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Starts barcode scanning on the active camera preview. Emits 'barcodeScanned' events and reuses the current camera session. ```APIDOC ## startBarcodeScanner(...) ### Description Starts barcode scanning on the active camera preview. The scanner reuses the current camera session and emits `barcodeScanned` events. Call `stopBarcodeScanner()` when scanning is no longer needed. Android uses the lightweight Google Play Services ML Kit model. If the model is not installed yet, first scans may return no result until Google Play Services finishes downloading it. ### Method ```typescript startBarcodeScanner(options?: BarcodeScannerOptions | undefined) => Promise ``` ### Parameters #### Request Body - **options** (BarcodeScannerOptions) - Optional - The options for the barcode scanner. ``` -------------------------------- ### getAspectRatio Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Gets the current aspect ratio of the camera preview. ```APIDOC ## getAspectRatio() ### Description Gets the current aspect ratio of the camera preview. ### Method GET ### Endpoint /camera-preview/aspect-ratio ### Response #### Success Response (200) - **aspectRatio** (CameraPreviewAspectRatio) - The current aspect ratio of the camera preview. ### Response Example { "aspectRatio": "16:9" } ``` -------------------------------- ### Start Camera Preview with Barcode Scanning Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Initiates the camera preview with barcode scanning enabled. Configure specific barcode formats and detection intervals. The preview can be set to appear behind the web view. ```typescript import { CameraPreview } from '@capgo/camera-preview'; await CameraPreview.addListener('barcodeScanned', ({ barcodes }) => { console.log('Barcodes:', barcodes); }); await CameraPreview.start({ position: 'rear', toBack: true, barcodeScanner: { formats: ['qr_code'], detectionInterval: 500, }, }); ``` -------------------------------- ### Get Available Camera Devices Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Retrieves a list of all available camera devices on the system. Returns a promise that resolves with an object containing a `devices` array. ```typescript getAvailableDevices() => Promise<{ devices: CameraDevice[]; }> ``` -------------------------------- ### getPreviewSize Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Gets the current preview size and position of the camera feed. ```APIDOC ## getPreviewSize() ### Description Gets the current preview size and position. ### Response #### Success Response (object) - **x** (number) - The x-coordinate of the preview. - **y** (number) - The y-coordinate of the preview. - **width** (number) - The width of the preview. - **height** (number) - The height of the preview. ### Response Example { "x": 0, "y": 0, "width": 1920, "height": 1080 } ``` -------------------------------- ### Start Barcode Scanner with CameraPreview Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Starts barcode scanning on the active camera preview. This reuses the current camera session and emits 'barcodeScanned' events. Android uses Google Play Services ML Kit, which may require an initial download. ```typescript startBarcodeScanner(options?: BarcodeScannerOptions | undefined) => Promise ``` -------------------------------- ### Request Camera Permissions Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Requests camera and optional microphone permissions. If permissions are already granted or denied, the current status is returned. If `showSettingsAlert` is true and permissions are denied, a platform-specific alert will guide the user to app settings. Available since version 8.7.0. ```typescript requestPermissions(options?: PermissionRequestOptions | undefined) => Promise ``` -------------------------------- ### setVideoFrameRate Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Sets the target video frame rate for the active camera session. It's preferable to pass the frame rate to `startRecordVideo()` when starting a recording. Unsupported values will be rejected with a clear error. ```APIDOC ## setVideoFrameRate(...) ### Description Sets the target video frame rate for the active camera session. Prefer passing `frameRate` to `startRecordVideo()` when starting a recording. Rejects unsupported values with a clear error. ### Method Not specified (assumed to be a method call in a TypeScript/JavaScript context) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```typescript setVideoFrameRate({ frameRate: number }) ``` ### Response #### Success Response (void) This method returns a void promise, indicating success or failure through promise resolution or rejection. #### Response Example None explicitly provided. ``` -------------------------------- ### getGridMode Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Gets the current grid mode of the camera preview overlay. ```APIDOC ## getGridMode() ### Description Gets the current grid mode of the camera preview overlay. ### Method GET ### Endpoint /camera-preview/grid-mode ### Response #### Success Response (200) - **gridMode** (GridMode) - The current grid mode of the camera preview overlay. ### Response Example { "gridMode": "3x3" } ``` -------------------------------- ### Get Supported Picture Sizes Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Retrieves the supported picture sizes for all cameras. Available since version 7.4.0. ```typescript getSupportedPictureSizes() => Promise<{ supportedPictureSizes: SupportedPictureSizes[]; }> ``` -------------------------------- ### getSupportedPictureSizes Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Gets the supported picture sizes for all cameras. ```APIDOC ## getSupportedPictureSizes() ### Description Gets the supported picture sizes for all cameras. ### Method GET ### Endpoint /camera-preview/supported-picture-sizes ### Response #### Success Response (200) - **supportedPictureSizes** (SupportedPictureSizes[]) - An array of supported picture sizes. ### Response Example { "supportedPictureSizes": [ { "width": 1920, "height": 1080 }, { "width": 1280, "height": 720 } ] } ``` -------------------------------- ### Get Plugin Version Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Retrieves the native Capacitor plugin version. ```typescript getPluginVersion() => Promise<{ version: string; }> ``` -------------------------------- ### Get Preview Size and Position Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Retrieves the current dimensions (width and height) and position (x and y coordinates) of the camera preview display area. Returns a promise with these four values. ```typescript getPreviewSize() => Promise<{ x: number; y: number; width: number; height: number; }> ``` -------------------------------- ### Fast Base64 Conversion from File Path Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Use this method to convert captured image files to base64 entirely on the JS side, which is faster and avoids sending large strings over the Capacitor bridge. Ensure `storeToFile: true` is set when starting the camera. Optionally, clean up the temporary file using `CameraPreview.deleteFile`. ```typescript import { CameraPreview, getBase64FromFilePath } from '@capgo/camera-preview' await CameraPreview.start({ storeToFile: true }); // Take a picture and get a file path const { value: filePath } = await CameraPreview.capture({ quality: 85 }) // Convert the file to base64 entirely on the JS side (fast, no bridge) const base64 = await getBase64FromFilePath(filePath) // Optionally cleanup the temp file natively await CameraPreview.deleteFile({ path: filePath }) ``` -------------------------------- ### getVideoQuality Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Gets the current video recording quality setting. This helps in understanding the current quality level being used. ```APIDOC ## getVideoQuality ### Description Gets the current video recording quality. ### Method ```typescript getVideoQuality() => Promise<{ quality: VideoQuality; }> ``` ### Response #### Success Response - **quality** (VideoQuality) - The current video quality setting. ### Since 8.5.0 ``` -------------------------------- ### Get Supported Flash Modes with CameraPreview Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Retrieves a list of flash modes that are supported by the currently active camera. ```typescript getSupportedFlashModes() => Promise<{ result: CameraPreviewFlashMode[]; }> ``` -------------------------------- ### getZoom Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Gets the current zoom state, including minimum, maximum, and current zoom levels, along with lens information. ```APIDOC ## getZoom() ### Description Gets the current zoom state, including min/max and current lens info. ### Response #### Success Response (object) - **min** (number) - The minimum zoom level. - **max** (number) - The maximum zoom level. - **current** (number) - The current zoom level. - **lens** (LensInfo) - Information about the camera lens. ### Response Example { "min": 1, "max": 10, "current": 1, "lens": "wide" } ``` -------------------------------- ### getVideoCodec Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Gets the current video codec used for recording. Useful for verifying the active codec. ```APIDOC ## getVideoCodec ### Description Gets the current video codec used for recording. ### Method ```typescript getVideoCodec() => Promise<{ codec: VideoCodec; }> ``` ### Response #### Success Response - **codec** (VideoCodec) - The current video codec setting. ### Since 8.5.0 ``` -------------------------------- ### Set Video Frame Rate Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Sets the target video frame rate for the active camera session. It is preferable to pass `frameRate` to `startRecordVideo()` when starting a recording. Unsupported values will be rejected with a clear error. Available since version 8.6.0. ```typescript setVideoFrameRate(options: { frameRate: number; }) => Promise ``` -------------------------------- ### Get Camera Aspect Ratio Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Retrieves the current aspect ratio of the camera preview. Available since version 7.5.0. ```typescript getAspectRatio() => Promise<{ aspectRatio: CameraPreviewAspectRatio; }> ``` -------------------------------- ### Get Camera Grid Mode Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Retrieves the current grid mode of the camera preview overlay. Available since version 8.0.0. ```typescript getGridMode() => Promise<{ gridMode: GridMode; }> ``` -------------------------------- ### getSafeAreaInsets Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Gets the safe area insets for devices, accounting for the orientation-aware notch/camera cutout. This provides dimensions for areas that should be avoided for UI elements. ```APIDOC ## getSafeAreaInsets ### Description Gets 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. Android: Values returned in dp (logical pixels). iOS: Values returned in physical pixels, excluding status bar (only pure notch/cutout size). ### Method GET ### Endpoint /getSafeAreaInsets ### Returns - Promise - A promise that resolves with the safe area insets. ``` -------------------------------- ### getOrientation Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Gets the current device orientation in a cross-platform format. This is useful for adapting the UI or camera behavior based on how the device is held. ```APIDOC ## getOrientation ### Description Gets the current device orientation in a cross-platform format. ### Method GET ### Endpoint /getOrientation ### Returns - Promise<{ orientation: DeviceOrientation; }> - A promise that resolves with an object containing the device orientation. ### Since 7.5.0 ``` -------------------------------- ### Get Supported Video Frame Rates Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Lists the video frame rates supported by the active camera for the current format. Supported values depend on the selected camera, lens, and video quality. Available since version 8.6.0. ```typescript getSupportedVideoFrameRates() => Promise<{ frameRates: number[]; }> ``` -------------------------------- ### getFlashMode Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Gets the current flash mode of the camera. ```APIDOC ## getFlashMode() ### Description Gets the current flash mode. ### Response #### Success Response (object) - **flashMode** (FlashMode) - The current flash mode (e.g., 'auto', 'on', 'off'). ### Response Example { "flashMode": "on" } ``` -------------------------------- ### Build the Plugin with Bun Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/AGENTS.md Builds the plugin, including TypeScript compilation, documentation generation, and bundling with Rollup. This command is part of the standard development workflow. ```bash bun run build ``` -------------------------------- ### Set Transparent Background for Camera Preview Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Apply this CSS to make the camera preview transparent. Use a custom class for specific elements to avoid affecting the entire application. ```css :root { --ion-background-color: transparent !important; } ``` ```css .my-custom-camera-preview-content { --background: transparent; } ``` -------------------------------- ### getSupportedFlashModes Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Gets the flash modes supported by the active camera. ```APIDOC ## getSupportedFlashModes() ### Description Gets the flash modes supported by the active camera. ### Method ```typescript getSupportedFlashModes() => Promise<{ result: CameraPreviewFlashMode[]; }> ``` ### Response #### Success Response (200) - **result** (CameraPreviewFlashMode[]) - An array of supported flash modes. ### Returns ```typescript Promise<{ result: CameraPreviewFlashMode[]; }> ``` ``` -------------------------------- ### CameraPreviewOptions Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Configuration options for the camera preview. ```APIDOC ## CameraPreviewOptions ### Description Options to configure the camera preview. ### Properties - **`lockAndroidOrientation`** (boolean) - Optional - If true, locks the device orientation while the camera is active. Defaults to `false`. - **`enableOpacity`** (boolean) - Optional - If true, allows the camera preview's opacity to be changed. Defaults to `false`. - **`disableFocusIndicator`** (boolean) - Optional - If true, disables the visual focus indicator when tapping to focus. Defaults to `false`. - **`deviceId`** (string) - Optional - The `deviceId` of the camera to use. If provided, `position` is ignored. - **`enablePhysicalDeviceSelection`** (boolean) - Optional - On Android, attempts to bind a physical camera directly when `deviceId` refers to a physical lens. Disabled by default because OEM support is inconsistent; when false, Android keeps the current logical-camera fallback behavior. Defaults to `false`. - **`initialZoomLevel`** (number) - Optional - The initial zoom level when starting the camera preview. If the requested zoom level is not available, the native plugin will reject. Defaults to `1.0`. - **`positioning`** (CameraPositioning) - Optional - The vertical positioning of the camera preview. Defaults to `"center"`. - **`enableVideoMode`** (boolean) - Optional - If true, enables video capture capabilities when the camera starts. Defaults to `false`. - **`force`** (boolean) - Optional - If true, forces the camera to start/restart even if it's already running or busy. This will kill the current camera session and start a new one, ignoring all state checks. Defaults to `false`. - **`videoQuality`** (VideoQuality) - Optional - Sets the quality of video for recording. Options: 'low', 'medium', 'high', '2160p', '1080p', '720p', '480p', '4:3'. Defaults to `"high"`. - **`maxDuration`** (number) - Optional - Maximum recording duration in seconds. Recording stops automatically when reached. - **`maxFileSize`** (number) - Optional - Maximum recording file size in bytes. Recording stops automatically when reached. ``` -------------------------------- ### isRunning Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Checks if the camera preview is currently running. ```APIDOC ## isRunning() ### Description Checks if the camera preview is currently running. ### Response #### Success Response (object) - **isRunning** (boolean) - True if the camera preview is running, false otherwise. ### Response Example { "isRunning": true } ``` -------------------------------- ### Android Manifest Permissions for Camera Preview Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Add these permissions to `android/app/src/main/AndroidManifest.xml` to enable camera, audio recording, and storage access for the camera preview functionality. ```xml ``` -------------------------------- ### Full Plugin Verification with Bun Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/AGENTS.md Performs a full verification of the plugin across iOS, Android, and Web platforms. This should be run before submitting any work. ```bash bun run verify ``` -------------------------------- ### getVideoStabilizationMode Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Gets the current video stabilization mode. This helps in confirming the active stabilization setting. ```APIDOC ## getVideoStabilizationMode ### Description Gets the current video stabilization mode. ### Method ```typescript getVideoStabilizationMode() => Promise<{ mode: VideoStabilizationMode; }> ``` ### Response #### Success Response - **mode** (VideoStabilizationMode) - The current video stabilization mode. ### Since 8.5.2 ``` -------------------------------- ### getHorizontalFov Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Gets the horizontal field of view (FoV) for the active camera. Note: This can be an estimate on some devices. ```APIDOC ## getHorizontalFov() ### Description Gets the horizontal field of view (FoV) for the active camera. Note: This can be an estimate on some devices. ### Method GET ### Endpoint /camera-preview/horizontal-fov ### Response #### Success Response (200) - **result** (number) - The horizontal field of view in degrees. ### Response Example { "result": 65.5 } ``` -------------------------------- ### CameraSampleOptions Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Defines the options for capturing a sample frame from the camera preview. This includes settings like image quality. ```APIDOC ## CameraSampleOptions ### Description Defines the options for capturing a sample frame from the camera preview. ### Parameters #### Request Body - **`quality`** (number) - Required - The quality of the captured sample, from 0 to 100. ``` -------------------------------- ### Individual Platform Verification with Bun Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/AGENTS.md Runs verification specifically for iOS, Android, or Web platforms. Use these commands for targeted testing. ```bash bun run verify:ios ``` ```bash bun run verify:android ``` ```bash bun run verify:web ``` -------------------------------- ### Set Camera Preview Size and Position Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Use this method to define the dimensions and placement of the camera preview on the screen. Requires options with width and height, and optionally x and y coordinates. ```typescript setPreviewSize(options: { x?: number; y?: number; width: number; height: number; }) => Promise<{ width: number; height: number; x: number; y: number; }> ``` -------------------------------- ### requestPermissions Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Requests camera (and optional microphone) permissions. If permissions are already granted or denied, the current status is returned without prompting. ```APIDOC ## requestPermissions(...) ### Description Requests 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. ### Method POST ### Endpoint /camera-preview/permissions ### Parameters #### Request Body - **options** (PermissionRequestOptions) - Optional - Configuration for the permission request behaviour. - **disableAudio** (boolean) - Optional - Set `false` to also request microphone permission (defaults to `true`). - **showSettingsAlert** (boolean) - Optional - If `true`, an alert will be shown to guide the user to app settings if permissions are denied. ### Request Example { "options": { "disableAudio": false, "showSettingsAlert": true } } ### Response #### Success Response (200) - **status** (CameraPermissionStatus) - The current camera permission status. ### Response Example { "status": { "camera": "granted", "microphone": "granted" } } ``` -------------------------------- ### CameraOpacityOptions Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Defines the options for setting the camera preview's opacity. ```APIDOC ## CameraOpacityOptions ### Description Defines the options for setting the camera preview's opacity. ### Properties - **`opacity`** (number) - Required - The opacity percentage, from 0.0 (fully transparent) to 1.0 (fully opaque). Default: 1.0. ``` -------------------------------- ### getSupportedVideoQualities Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Returns a list of all video qualities supported by the active camera. Use this to determine available quality options. ```APIDOC ## getSupportedVideoQualities ### Description Returns the video qualities supported by the active camera. ### Method ```typescript getSupportedVideoQualities() => Promise<{ qualities: VideoQuality[]; }> ``` ### Response #### Success Response - **qualities** (VideoQuality[]) - An array of supported video quality settings. ### Since 8.5.0 ``` -------------------------------- ### Get Current Flash Mode Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Retrieves the current flash mode setting of the camera. Returns a promise that resolves with the active `flashMode`. ```typescript getFlashMode() => Promise<{ flashMode: FlashMode; }> ``` -------------------------------- ### Capture Sample Frame with CameraPreview Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Captures a single frame from the camera preview stream. The result is a base64 encoded string. ```typescript captureSample(options: CameraSampleOptions) => Promise<{ value: string; }> ``` -------------------------------- ### captureSample Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Captures a single frame from the camera preview stream. ```APIDOC ## captureSample(...) ### Description Captures a single frame from the camera preview stream. ### Method ```typescript captureSample(options: CameraSampleOptions) => Promise<{ value: string; }> ``` ### Parameters #### Request Body - **options** (CameraSampleOptions) - Required - The options for capturing the sample. ### Response #### Success Response (200) - **value** (string) - The captured frame data (base64 string). ### Returns ```typescript Promise<{ value: string; }> ``` ``` -------------------------------- ### Format Code with Bun Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/AGENTS.md Auto-formats code using ESLint, Prettier, and SwiftLint. This command helps maintain code quality and consistency. ```bash bun run fmt ``` -------------------------------- ### Set Camera Focus Point Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Configures the camera's focus to a specific point within the preview. The plugin does not handle tap-to-focus gestures natively; you must implement this in your UI and pass normalized coordinates. ```typescript setFocus(options: { x: number; y: number; }) => Promise ``` -------------------------------- ### setPreviewSize Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Sets the preview size and position of the camera. Allows for custom placement and dimensions of the camera preview. ```APIDOC ## setPreviewSize ### Description Sets the preview size and position. ### Method ```typescript setPreviewSize(options: { x?: number; y?: number; width: number; height: number; }): Promise<{ width: number; height: number; x: number; y: number; }> ``` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **options** (object) - Required - The new position and dimensions. * **x** (number) - Optional - The x-coordinate for the preview. * **y** (number) - Optional - The y-coordinate for the preview. * **width** (number) - Required - The width of the preview. * **height** (number) - Required - The height of the preview. ### Request Example ```json { "x": 0, "y": 0, "width": 300, "height": 400 } ``` ### Response #### Success Response (200) * **width** (number) - The set width of the preview. * **height** (number) - The set height of the preview. * **x** (number) - The set x-coordinate of the preview. * **y** (number) - The set y-coordinate of the preview. #### Response Example ```json { "width": 300, "height": 400, "x": 0, "y": 0 } ``` ``` -------------------------------- ### getDeviceId Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Gets the ID of the camera device that is currently bound. On Android, this may return the logical camera ID if a physical lens request falls back. ```APIDOC ## getDeviceId() ### Description Gets 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. ### Response #### Success Response (object) - **deviceId** (string) - The ID of the currently bound camera device. ### Response Example { "deviceId": "1" } ``` -------------------------------- ### Get Horizontal Field of View Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Retrieves the horizontal field of view (FoV) for the active camera. This may be an estimate on some devices. Available since version 0.0.1. ```typescript getHorizontalFov() => Promise<{ result: number; }> ``` -------------------------------- ### addListener('recordingFinished', ...) Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Adds a listener that is fired when a video recording finishes natively. This includes automatic stops, providing a way to react to the completion of video capture. ```APIDOC ## addListener 'recordingFinished' ### Description Adds a listener fired when a video recording finishes natively, including automatic stops. ### Method listener ### Parameters #### Event Parameters - **eventName** (string) - Must be 'recordingFinished'. - **listenerFunc** (function) - Callback function that receives `RecordingFinishedEvent` data. ### Returns - Promise - A promise that resolves with a PluginListenerHandle for managing the listener. ### Since 8.4.7 ``` -------------------------------- ### iOS Info.plist: Photo Library Usage Description Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Provides a description for accessing the photo library to save photos. This key is required when the `saveToGallery` option is enabled. ```xml NSPhotoLibraryUsageDescription To save photos to your gallery ``` -------------------------------- ### addListener('screenResize', ...) Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Adds a listener for screen resize events. This is triggered when the device's screen dimensions change. ```APIDOC ## addListener('screenResize', ...) ### Description Adds a listener for screen resize events. ### Method ```typescript addListener(eventName: 'screenResize', listenerFunc: (data: { width: number; height: number; x: number; y: number; }) => void): Promise ``` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **eventName** (string) - Required - The event name to listen for. Must be 'screenResize'. * **listenerFunc** (function) - Required - The function to call when the event is triggered. It receives an object with width, height, x, and y coordinates. ### Request Example ```javascript Camera.addListener('screenResize', (data) => { console.log('Screen resized:', data); }); ``` ### Response #### Success Response (200) * **PluginListenerHandle** - A handle to the listener that can be used to remove it. #### Response Example (Promise resolves with a PluginListenerHandle object) ``` -------------------------------- ### Get Zoom Button Values Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Returns an array of numerical values representing zoom levels suitable for quick switching via buttons. The available values differ between platforms (iOS/Android vs. Web). ```typescript getZoomButtonValues() => Promise<{ values: number[]; }> ``` -------------------------------- ### Get Current Zoom State Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Retrieves the current zoom state of the camera, including minimum, maximum, and current zoom levels, along with lens information. Returns a promise resolving with zoom and lens details. ```typescript getZoom() => Promise<{ min: number; max: number; current: number; lens: LensInfo; }> ``` -------------------------------- ### Get Current Camera Device ID Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Retrieves the unique identifier (`deviceId`) of the camera device currently in use. For Android, if a physical lens request falls back to a logical camera, this returns the logical camera ID. ```typescript getDeviceId() => Promise<{ deviceId: string; }> ``` -------------------------------- ### getSupportedVideoStabilizationModes Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Returns a list of all video stabilization modes supported by the active camera. Use this to know which stabilization options are available. ```APIDOC ## getSupportedVideoStabilizationModes ### Description Returns the video stabilization modes supported by the active camera. ### Method ```typescript getSupportedVideoStabilizationModes() => Promise<{ modes: VideoStabilizationMode[]; }> ``` ### Response #### Success Response - **modes** (VideoStabilizationMode[]) - An array of supported video stabilization modes. ### Since 8.5.2 ``` -------------------------------- ### iOS Info.plist: Location When In Use Description Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Provides a description for using location services when the app is in use. This key is required for including location data in EXIF metadata. ```xml NSLocationWhenInUseUsageDescription To add location data to your photos ``` -------------------------------- ### Get Video Frame Rate Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Returns the configured video frame rate for the active camera. On Android, the actual recording frame rate may vary in low light or under thermal pressure. Available since version 8.6.0. ```typescript getVideoFrameRate() => Promise<{ frameRate: number; }> ``` -------------------------------- ### setAspectRatio Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Set the aspect ratio of the camera preview, optionally specifying position. ```APIDOC ## setAspectRatio(...) ### Description Set the aspect ratio of the camera preview. ### Method ```typescript setAspectRatio(options: { aspectRatio: CameraPreviewAspectRatio; x?: number; y?: number; }) => Promise<{ width: number; height: number; x: number; y: number; }> ``` ### Parameters #### Request Body - **options** (object) - Required - The desired aspect ratio and optional position. - **aspectRatio** (CameraPreviewAspectRatio) - Required - The desired aspect ratio ('4:3', '16:9', or 'fill'). - **x** (number) - Optional - Optional x coordinate for positioning. If not provided, view will be auto-centered horizontally. - **y** (number) - Optional - Optional y coordinate for positioning. If not provided, view will be auto-centered vertically. ### Response #### Success Response (200) - **width** (number) - The width of the camera preview. - **height** (number) - The height of the camera preview. - **x** (number) - The x coordinate of the camera preview. - **y** (number) - The y coordinate of the camera preview. ### Returns ```typescript Promise<{ width: number; height: number; x: number; y: number; }> ``` ``` -------------------------------- ### PictureSize Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Defines a standard picture size with width and height. ```APIDOC ## PictureSize ### Description Defines a standard picture size with width and height. ### Properties - **`width`** (number) - Required - The width of the picture in pixels. - **`height`** (number) - Required - The height of the picture in pixels. ``` -------------------------------- ### setOpacity Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Sets the opacity of the camera preview. This method allows you to control the transparency of the camera feed displayed on the screen. ```APIDOC ## setOpacity ### Description Sets the opacity of the camera preview. ### Method ```typescript setOpacity(options: CameraOpacityOptions) => Promise ``` ### Parameters #### Path Parameters - **options** (CameraOpacityOptions) - Required - The opacity options. ### Response #### Success Response (void) Indicates the opacity was set successfully. ### Since 0.0.1 ``` -------------------------------- ### flip Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Toggles between the front and rear cameras. ```APIDOC ## flip() ### Description Toggles between the front and rear cameras. ### Method POST ### Endpoint /camera-preview/flip ### Response #### Success Response (200) void ``` -------------------------------- ### Capture Picture with CameraPreview Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Captures a picture from the camera. If storeToFile was true, returns a file path; otherwise, returns a base64 string. Use getBase64FromFilePath to convert file paths. ```typescript capture(options: CameraPreviewPictureOptions) => Promise<{ value: string; exif: ExifData; }> ``` -------------------------------- ### stop Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Stops the camera preview. Optionally allows forcing the stop. ```APIDOC ## stop ### Description Stops the camera preview. ### Method stop(options?: { force?: boolean | undefined; } | undefined) ### Parameters #### Path Parameters - **options** (object) - Optional - Configuration for stopping the camera. - **force** (boolean) - Optional - Whether to force stop the camera. ### Response #### Success Response (200) - (void) ### Request Example ```json { "force": true } ``` ``` -------------------------------- ### getSupportedVideoCodecs Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Returns a list of all video codecs supported by the active camera. This helps in selecting an appropriate codec for recording. ```APIDOC ## getSupportedVideoCodecs ### Description Returns the video codecs supported by the active camera. ### Method ```typescript getSupportedVideoCodecs() => Promise<{ codecs: VideoCodec[]; }> ``` ### Response #### Success Response - **codecs** (VideoCodec[]) - An array of supported video codec settings. ### Since 8.5.0 ``` -------------------------------- ### getPluginVersion Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Retrieves the native Capacitor plugin version. ```APIDOC ## getPluginVersion() ### Description Get the native Capacitor plugin version ### Method Not specified (assumed to be a method call in a TypeScript/JavaScript context) ### Endpoint None ### Parameters None ### Request Example ```typescript getPluginVersion() ``` ### Response #### Success Response - **version** (string) - The version of the native Capacitor plugin. #### Response Example ```json { "version": "1.2.3" } ``` ``` -------------------------------- ### Android Manifest: Audio Recording Permission Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Declares the necessary permission for audio recording in the AndroidManifest.xml file. Required when `disableAudio` is false. ```xml ``` -------------------------------- ### setGridMode Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Sets the grid mode of the camera preview overlay. ```APIDOC ## setGridMode(...) ### Description Sets the grid mode of the camera preview overlay. ### Method POST ### Endpoint /camera-preview/grid-mode ### Parameters #### Request Body - **options** (object) - Required - Configuration for the grid mode. - **gridMode** (GridMode) - Required - The desired grid mode ('none', '3x3', or '4x4'). ### Request Example { "options": { "gridMode": "3x3" } } ### Response #### Success Response (200) void ``` -------------------------------- ### iOS Info.plist: Microphone Usage Description Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Provides a description for microphone usage when recording audio with videos. This key is required for audio recording functionality on iOS. ```xml NSMicrophoneUsageDescription To record audio with videos ``` -------------------------------- ### Lint Code Without Fixing with Bun Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/AGENTS.md Checks code quality using ESLint, Prettier, and SwiftLint without modifying files. Useful for identifying potential issues before formatting. ```bash bun run lint ``` -------------------------------- ### Iterate and Display Media Items Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/example-app/src/app/pages/gallery/gallery.component.html Use this Angular template syntax to loop through media items and conditionally display content based on type. ```html @for (item of galleryService.mediaItems(); track $index) { @if (item.type === 'photo') { } @if (item.type === 'video') { } } ``` -------------------------------- ### getSupportedVideoFrameRates Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Lists the video frame rates supported by the active camera for the current format. Supported values depend on the selected camera, lens, and video quality. ```APIDOC ## getSupportedVideoFrameRates() ### Description Lists the video frame rates supported by the active camera for the current format. Supported values depend on the selected camera, lens, and video quality. ### Method Not specified (assumed to be a method call in a TypeScript/JavaScript context) ### Endpoint None ### Parameters None ### Request Example ```typescript getSupportedVideoFrameRates() ``` ### Response #### Success Response - **frameRates** (number[]) - An array of supported video frame rates. #### Response Example ```json { "frameRates": [ 30, 60 ] } ``` ``` -------------------------------- ### Set Aspect Ratio with CameraPreview Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Sets the aspect ratio for the camera preview. You can also specify optional x and y coordinates for positioning; otherwise, the view will be auto-centered. ```typescript setAspectRatio(options: { aspectRatio: CameraPreviewAspectRatio; x?: number; y?: number; }) => Promise<{ width: number; height: number; x: number; y: number; }> ``` -------------------------------- ### Check if Camera Preview is Running Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Checks if the camera preview is currently active. Returns a promise that resolves with an object containing the `isRunning` boolean. ```typescript isRunning() => Promise<{ isRunning: boolean; }> ``` -------------------------------- ### Listen for Screen Resize Events Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Adds a callback function that is executed whenever the screen's dimensions or position change. The listener receives an object containing the new width, height, x, and y coordinates. ```typescript addListener(eventName: 'screenResize', listenerFunc: (data: { width: number; height: number; x: number; y: number; }) => void) => Promise ``` -------------------------------- ### Set Camera Grid Mode Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Sets the grid mode overlay for the camera preview. Accepts 'none', '3x3', or '4x4'. Available since version 8.0.0. ```typescript setGridMode(options: { gridMode: GridMode; }) => Promise ``` -------------------------------- ### addListener('barcodeScanned', ...) Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Adds a listener for barcode scan results. This is triggered when a barcode is successfully detected by the camera. ```APIDOC ## addListener('barcodeScanned', ...) ### Description Adds a listener for barcode scan results. ### Method ```typescript addListener(eventName: 'barcodeScanned', listenerFunc: (data: BarcodeScannedEvent) => void): Promise ``` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **eventName** (string) - Required - The event name to listen for. Must be 'barcodeScanned'. * **listenerFunc** (function) - Required - The function to call when a barcode is scanned. It receives a BarcodeScannedEvent object. ### Request Example ```javascript Camera.addListener('barcodeScanned', (data) => { console.log('Barcode scanned:', data); }); ``` ### Response #### Success Response (200) * **PluginListenerHandle** - A handle to the listener that can be used to remove it. #### Response Example (Promise resolves with a PluginListenerHandle object) ``` -------------------------------- ### setVideoQuality Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Sets the video recording quality for the active camera session. Choose from predefined quality levels. ```APIDOC ## setVideoQuality ### Description Sets the video recording quality for the active camera session. ### Method ```typescript setVideoQuality(options: { quality: VideoQuality; }) => Promise ``` ### Parameters #### Path Parameters - **options** ({ quality: VideoQuality; }) - Required - The desired video quality. ### Response #### Success Response (void) Indicates the video quality has been set. ### Since 8.5.0 ``` -------------------------------- ### PR Template Structure Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/AGENTS.md A template for structuring pull request descriptions, covering the 'What', 'Why', 'How', 'Testing', and 'Not Tested' sections. ```markdown ## What - [Brief description of the change] ## Why - [Motivation for this change] ## How - [Implementation approach] ## Testing - [What was tested and how] ## Not Tested - [What still needs testing, if anything] ``` -------------------------------- ### Check Camera Permissions Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md Checks the current camera and optionally microphone permission status without showing a system dialog. Set `disableAudio` to `false` to include microphone status. Available since version 8.7.0. ```typescript checkPermissions(options?: Pick | undefined) => Promise ``` -------------------------------- ### Ensure Transparent Background in VueJS App Source: https://github.com/cap-go/capacitor-camera-preview/blob/main/README.md If the camera preview is not displaying correctly, ensure the root element of your VueJS application has a transparent background. ```html