capacitor-camera-view 2.2.0-rc.1 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/README.md +17 -202
  2. package/android/build.gradle +0 -1
  3. package/android/src/main/AndroidManifest.xml +0 -1
  4. package/android/src/main/java/com/michaelwolz/capacitorcameraview/CameraView.kt +4 -287
  5. package/android/src/main/java/com/michaelwolz/capacitorcameraview/CameraViewPlugin.kt +8 -112
  6. package/android/src/main/java/com/michaelwolz/capacitorcameraview/model/BarcodeDetectionResult.kt +1 -0
  7. package/android/src/main/java/com/michaelwolz/capacitorcameraview/utils.kt +1 -21
  8. package/dist/docs.json +21 -201
  9. package/dist/esm/definitions.d.ts +23 -85
  10. package/dist/esm/definitions.js.map +1 -1
  11. package/dist/esm/web.d.ts +4 -20
  12. package/dist/esm/web.js +16 -151
  13. package/dist/esm/web.js.map +1 -1
  14. package/dist/plugin.cjs.js +16 -151
  15. package/dist/plugin.cjs.js.map +1 -1
  16. package/dist/plugin.js +16 -151
  17. package/dist/plugin.js.map +1 -1
  18. package/ios/Sources/CameraViewPlugin/CameraError.swift +0 -28
  19. package/ios/Sources/CameraViewPlugin/CameraEvents.swift +27 -3
  20. package/ios/Sources/CameraViewPlugin/CameraSessionConfiguration.swift +8 -8
  21. package/ios/Sources/CameraViewPlugin/CameraViewManager+BarcodeScan.swift +34 -3
  22. package/ios/Sources/CameraViewPlugin/CameraViewManager+PhotoCapture.swift +14 -13
  23. package/ios/Sources/CameraViewPlugin/CameraViewManager.swift +150 -159
  24. package/ios/Sources/CameraViewPlugin/CameraViewPlugin.swift +15 -114
  25. package/ios/Sources/CameraViewPlugin/TempFileManager.swift +34 -68
  26. package/package.json +12 -12
  27. package/android/src/main/java/com/michaelwolz/capacitorcameraview/model/VideoRecordingQuality.kt +0 -10
  28. package/ios/Sources/CameraViewPlugin/CameraViewManager+VideoRecording.swift +0 -302
package/README.md CHANGED
@@ -29,7 +29,6 @@
29
29
 
30
30
  - 📹 Embed a **live camera feed** directly into your app.
31
31
  - 📸 Capture photos or frames from the camera preview.
32
- - 🎥 **Video recording** with optional audio support.
33
32
  - 🔍 **Barcode detection** support.
34
33
  - 📱 **Virtual device support** for automatic lens selection based on zoom level and focus (iOS only).
35
34
  - 🔦 Control **zoom**, **flash** and **torch** modes programmatically.
@@ -63,70 +62,12 @@ Add the following keys to your app's `Info.plist` file:
63
62
  <string>To capture photos and videos</string>
64
63
  ```
65
64
 
66
- If you plan to use `startRecording` with `enableAudio: true`, also add:
67
-
68
- ```xml
69
- <key>NSMicrophoneUsageDescription</key>
70
- <string>To record audio with video</string>
71
- ```
72
-
73
- > [!IMPORTANT]
74
- > The `NSMicrophoneUsageDescription` key must be present in `Info.plist` **before** microphone permission is ever requested — even if the request happens automatically when starting a recording with audio. Omitting it will cause your app to crash at runtime.
75
-
76
65
  #### Android
77
66
 
78
- The `CAMERA` permission is added to your app's `AndroidManifest.xml` automatically by the plugin. If you plan to use `startRecording` with `enableAudio: true`, the `RECORD_AUDIO` permission is also declared automatically by the plugin. You can verify these in your merged manifest:
67
+ The `CAMERA` permission is automatically added by Capacitor. Ensure your `AndroidManifest.xml` includes it if needed for specific configurations:
79
68
 
80
69
  ```xml
81
70
  <uses-permission android:name="android.permission.CAMERA" />
82
- <uses-permission android:name="android.permission.RECORD_AUDIO" />
83
- ```
84
-
85
- > [!IMPORTANT]
86
- > Declaring a permission in `AndroidManifest.xml` is required for the system to allow requesting it at runtime. The plugin handles this for you, but make sure you are not accidentally stripping the permission in your build configuration.
87
-
88
- ## 🔒 Permissions
89
-
90
- The plugin handles permissions for you automatically when a feature that requires them is used. However, you can also request permissions explicitly in advance.
91
-
92
- ### Requesting permissions explicitly
93
-
94
- By default, `requestPermissions()` only requests **camera** permission, preserving backward compatibility:
95
-
96
- ```typescript
97
- // Request camera permission only (default behavior)
98
- const status = await CameraView.requestPermissions();
99
- console.log(status.camera); // 'granted' | 'denied' | 'prompt'
100
- ```
101
-
102
- To also request **microphone** permission (needed for video recording with audio), pass the `permissions` option:
103
-
104
- ```typescript
105
- // Request both camera and microphone permissions
106
- const status = await CameraView.requestPermissions({
107
- permissions: ['camera', 'microphone'],
108
- });
109
- console.log(status.camera); // 'granted' | 'denied' | 'prompt'
110
- console.log(status.microphone); // 'granted' | 'denied' | 'prompt'
111
- ```
112
-
113
- ### Automatic permission requests
114
-
115
- You do not need to call `requestPermissions()` manually. The plugin will automatically request the required permissions when a feature is first used:
116
-
117
- - **Camera** permission is requested automatically when `start()` is called.
118
- - **Microphone** permission is requested automatically when `startRecording({ enableAudio: true })` is called.
119
-
120
- Regardless of whether you request permissions manually or rely on the automatic flow, the corresponding entries **must** be declared in your app's platform configuration (`Info.plist` on iOS, `AndroidManifest.xml` on Android) as described above.
121
-
122
- ### Checking permission status
123
-
124
- Use `checkPermissions()` to query the current permission state without triggering a system prompt:
125
-
126
- ```typescript
127
- const status = await CameraView.checkPermissions();
128
- console.log(status.camera); // 'granted' | 'denied' | 'prompt'
129
- console.log(status.microphone); // 'granted' | 'denied' | 'prompt'
130
71
  ```
131
72
 
132
73
  ## ▶️ Basic Usage
@@ -233,54 +174,6 @@ CameraView.addListener('barcodeDetected', (data) => {
233
174
 
234
175
  See the [`BarcodeDetectionData`](#barcodedetectiondata) interface for details on the event payload.
235
176
 
236
- ## 🎥 Video Recording
237
-
238
- This plugin supports recording video directly from the live camera feed.
239
-
240
- **How it works:**
241
- * **iOS:** Uses `AVCaptureMovieFileOutput` on top of the existing `AVCaptureSession`. Output is saved as `.mp4`.
242
- * **Android:** Uses the CameraX `VideoCapture` use case via `LifecycleCameraController`. Output is saved as `.mp4`.
243
- * **Web:** Uses the browser `MediaRecorder` API on the existing `MediaStream`. Output is a `.webm` blob URL (MP4 is not broadly supported by browsers).
244
-
245
- **Basic usage:**
246
-
247
- ```typescript
248
- import { CameraView } from 'capacitor-camera-view';
249
-
250
- // Start recording (camera must already be running)
251
- await CameraView.startRecording({ enableAudio: false });
252
-
253
- // Stop recording and get the result
254
- const result = await CameraView.stopRecording();
255
- console.log('Video saved to:', result.webPath);
256
- ```
257
-
258
- **Playing back the recorded video:**
259
-
260
- ```html
261
- <video [src]="videoPath" controls></video>
262
- ```
263
-
264
- **Recording with audio:**
265
-
266
- ```typescript
267
- await CameraView.startRecording({ enableAudio: true });
268
- ```
269
-
270
- **Recording with explicit quality preset (native):**
271
-
272
- ```typescript
273
- await CameraView.startRecording({
274
- enableAudio: true,
275
- videoQuality: 'fhd', // lowest | sd | hd | fhd | uhd | highest
276
- });
277
- ```
278
-
279
- > [!NOTE]
280
- > When `enableAudio: true` is used, the plugin automatically requests microphone permission from the user if it has not been granted yet. The permission declaration must still be present in your platform configuration — see the [Permissions](#-permissions) section for details.
281
-
282
- See the [`VideoRecordingOptions`](#videorecordingoptions) and [`VideoRecordingResponse`](#videorecordingresponse) interfaces in the API section for the full set of options.
283
-
284
177
  ## 🧪 Example App
285
178
 
286
179
  To see the plugin in action, check out the example app in the `example-app` folder. The app demonstrates how to integrate and use the Capacitor Camera View plugin in an Ionic Angular project.
@@ -313,8 +206,6 @@ chore: update dependencies
313
206
  * [`isRunning()`](#isrunning)
314
207
  * [`capture(...)`](#capture)
315
208
  * [`captureSample(...)`](#capturesample)
316
- * [`startRecording(...)`](#startrecording)
317
- * [`stopRecording()`](#stoprecording)
318
209
  * [`flipCamera()`](#flipcamera)
319
210
  * [`getAvailableDevices()`](#getavailabledevices)
320
211
  * [`getZoom()`](#getzoom)
@@ -326,7 +217,7 @@ chore: update dependencies
326
217
  * [`getTorchMode()`](#gettorchmode)
327
218
  * [`setTorchMode(...)`](#settorchmode)
328
219
  * [`checkPermissions()`](#checkpermissions)
329
- * [`requestPermissions(...)`](#requestpermissions)
220
+ * [`requestPermissions()`](#requestpermissions)
330
221
  * [`addListener('barcodeDetected', ...)`](#addlistenerbarcodedetected-)
331
222
  * [`removeAllListeners(...)`](#removealllisteners)
332
223
  * [Interfaces](#interfaces)
@@ -430,40 +321,6 @@ not yet well supported on the web.
430
321
  --------------------
431
322
 
432
323
 
433
- ### startRecording(...)
434
-
435
- ```typescript
436
- startRecording(options?: VideoRecordingOptions | undefined) => Promise<void>
437
- ```
438
-
439
- Start recording video from the current camera.
440
- Camera must be running. Throws if already recording.
441
-
442
- | Param | Type | Description |
443
- | ------------- | ----------------------------------------------------------------------- | ---------------------------------- |
444
- | **`options`** | <code><a href="#videorecordingoptions">VideoRecordingOptions</a></code> | - Optional recording configuration |
445
-
446
- **Since:** 2.2.0
447
-
448
- --------------------
449
-
450
-
451
- ### stopRecording()
452
-
453
- ```typescript
454
- stopRecording() => Promise<VideoRecordingResponse>
455
- ```
456
-
457
- Stop the current video recording and return the result.
458
- Throws if no recording is in progress.
459
-
460
- **Returns:** <code>Promise&lt;<a href="#videorecordingresponse">VideoRecordingResponse</a>&gt;</code>
461
-
462
- **Since:** 2.2.0
463
-
464
- --------------------
465
-
466
-
467
324
  ### flipCamera()
468
325
 
469
326
  ```typescript
@@ -624,7 +481,7 @@ Set the torch (flashlight) mode and intensity.
624
481
  checkPermissions() => Promise<PermissionStatus>
625
482
  ```
626
483
 
627
- Check camera and microphone permission status without requesting permissions.
484
+ Check camera permission status without requesting permissions.
628
485
 
629
486
  **Returns:** <code>Promise&lt;<a href="#permissionstatus">PermissionStatus</a>&gt;</code>
630
487
 
@@ -633,20 +490,13 @@ Check camera and microphone permission status without requesting permissions.
633
490
  --------------------
634
491
 
635
492
 
636
- ### requestPermissions(...)
493
+ ### requestPermissions()
637
494
 
638
495
  ```typescript
639
- requestPermissions(options?: { permissions?: CameraPermissionType[] | undefined; } | undefined) => Promise<PermissionStatus>
496
+ requestPermissions() => Promise<PermissionStatus>
640
497
  ```
641
498
 
642
- Request camera and/or microphone permissions from the user.
643
-
644
- By default, only camera permission is requested. To also request microphone
645
- permission (needed for video recording with audio), pass `{ permissions: ['camera', 'microphone'] }`.
646
-
647
- | Param | Type | Description |
648
- | ------------- | ------------------------------------------------------ | --------------------------------------------------------- |
649
- | **`options`** | <code>{ permissions?: CameraPermissionType[]; }</code> | - Optional object specifying which permissions to request |
499
+ Request camera permission from the user.
650
500
 
651
501
  **Returns:** <code>Promise&lt;<a href="#permissionstatus">PermissionStatus</a>&gt;</code>
652
502
 
@@ -731,25 +581,6 @@ Configuration options for capturing photos and samples.
731
581
  | **`saveToFile`** | <code>boolean</code> | If true, saves to a temporary file and returns the web path instead of base64. The web path can be used to set the src attribute of an image for efficient loading and rendering. This reduces the data that needs to be transferred over the bridge, which can improve performance especially for high-resolution images. | <code>false</code> | 1.1.0 |
732
582
 
733
583
 
734
- #### VideoRecordingOptions
735
-
736
- Configuration options for video recording.
737
-
738
- | Prop | Type | Description | Default | Since |
739
- | ------------------ | ----------------------------------------------------------------------- | ------------------------------------------------------------------------------------ | ---------------------- | ----- |
740
- | **`enableAudio`** | <code>boolean</code> | Whether to record audio with the video. Requires microphone permission. | <code>false</code> | 2.2.0 |
741
- | **`videoQuality`** | <code><a href="#videorecordingquality">VideoRecordingQuality</a></code> | Video recording quality preset. Native platforms only (iOS/Android). Ignored on web. | <code>'highest'</code> | 2.2.0 |
742
-
743
-
744
- #### VideoRecordingResponse
745
-
746
- Response from stopping a video recording.
747
-
748
- | Prop | Type | Description | Since |
749
- | ------------- | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ----- |
750
- | **`webPath`** | <code>string</code> | Web-accessible path to the recorded video file. On web, this is a blob URL. On iOS/Android, this is a path accessible via Capacitor's filesystem. | 2.2.0 |
751
-
752
-
753
584
  #### GetAvailableDevicesResponse
754
585
 
755
586
  Response for getting available camera devices.
@@ -821,12 +652,11 @@ Response for getting the current torch mode.
821
652
 
822
653
  #### PermissionStatus
823
654
 
824
- Response for the camera and microphone permission status.
655
+ Response for the camera permission status.
825
656
 
826
- | Prop | Type | Description |
827
- | ---------------- | ----------------------------------------------------------- | -------------------------------------- |
828
- | **`camera`** | <code><a href="#permissionstate">PermissionState</a></code> | The state of the camera permission |
829
- | **`microphone`** | <code><a href="#permissionstate">PermissionState</a></code> | The state of the microphone permission |
657
+ | Prop | Type | Description |
658
+ | ------------ | ----------------------------------------------------------- | ---------------------------------- |
659
+ | **`camera`** | <code><a href="#permissionstate">PermissionState</a></code> | The state of the camera permission |
830
660
 
831
661
 
832
662
  #### PluginListenerHandle
@@ -840,12 +670,13 @@ Response for the camera and microphone permission status.
840
670
 
841
671
  Data for a detected barcode.
842
672
 
843
- | Prop | Type | Description |
844
- | ------------------ | ----------------------------------------------------- | ---------------------------------------------------------------- |
845
- | **`value`** | <code>string</code> | The decoded string value of the barcode |
846
- | **`displayValue`** | <code>string</code> | The display value of the barcode (may differ from the raw value) |
847
- | **`type`** | <code>string</code> | The type/format of the barcode (e.g., 'qr', 'code128', etc.) |
848
- | **`boundingRect`** | <code><a href="#boundingrect">BoundingRect</a></code> | The bounding rectangle of the barcode in the camera frame. |
673
+ | Prop | Type | Description | Since |
674
+ | ------------------ | ----------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----- |
675
+ | **`value`** | <code>string</code> | The decoded string value of the barcode | |
676
+ | **`rawBytes`** | <code>number[]</code> | Raw bytes as they were encoded in the barcode. On Android, this is forwarded from ML Kit. On iOS, this is available for descriptor-backed formats such as QR, Aztec, PDF417, and Data Matrix. On web, this is not available because the Barcode Detection API only exposes the decoded string value. | 2.2.0 |
677
+ | **`displayValue`** | <code>string</code> | The display value of the barcode on Android. This is forwarded from ML Kit and may contain a formatted, human-readable representation that differs from the raw decoded value. iOS and web do not expose a separate display value, so this property is only emitted on Android. | |
678
+ | **`type`** | <code>string</code> | The type/format of the barcode (e.g., 'qr', 'code128', etc.) | |
679
+ | **`boundingRect`** | <code><a href="#boundingrect">BoundingRect</a></code> | The bounding rectangle of the barcode in the camera frame. | |
849
680
 
850
681
 
851
682
  #### BoundingRect
@@ -899,13 +730,6 @@ depending on the `saveToFile` option in the <a href="#captureoptions">CaptureOpt
899
730
  <code>T['saveToFile'] extends true ? { /** The web path to the captured photo that can be used to set the src attribute of an image for efficient loading and rendering (when saveToFile is true) */ webPath: string; } : { /** The base64 encoded string of the captured photo (when saveToFile is false or undefined) */ photo: string; }</code>
900
731
 
901
732
 
902
- #### VideoRecordingQuality
903
-
904
- Video recording quality presets.
905
-
906
- <code>'lowest' | 'sd' | 'hd' | 'fhd' | 'uhd' | 'highest'</code>
907
-
908
-
909
733
  #### FlashMode
910
734
 
911
735
  Flash mode options for the camera.
@@ -920,13 +744,4 @@ Flash mode options for the camera.
920
744
 
921
745
  <code>'prompt' | 'prompt-with-rationale' | 'granted' | 'denied'</code>
922
746
 
923
-
924
- #### CameraPermissionType
925
-
926
- Permission types that can be requested.
927
- - 'camera': Camera access permission
928
- - 'microphone': Microphone access permission (needed for video recording with audio)
929
-
930
- <code>'camera' | 'microphone'</code>
931
-
932
747
  </docgen-api>
@@ -78,7 +78,6 @@ dependencies {
78
78
  implementation "androidx.camera:camera-lifecycle:${camerax_version}"
79
79
  implementation "androidx.camera:camera-view:${camerax_version}"
80
80
  implementation "androidx.camera:camera-mlkit-vision:${camerax_version}"
81
- implementation "androidx.camera:camera-video:${camerax_version}"
82
81
 
83
82
  // ML Kit for barcode scanning
84
83
  implementation "com.google.mlkit:barcode-scanning:17.3.0"
@@ -1,3 +1,2 @@
1
1
  <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
- <uses-permission android:name="android.permission.RECORD_AUDIO" />
3
2
  </manifest>