@capgo/camera-preview 7.3.12 → 7.4.0-alpha.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.
- package/CapgoCameraPreview.podspec +16 -13
- package/README.md +492 -73
- package/android/build.gradle +11 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +1 -1
- package/android/src/main/AndroidManifest.xml +5 -3
- package/android/src/main/java/com/ahm/capacitor/camera/preview/CameraPreview.java +968 -505
- package/android/src/main/java/com/ahm/capacitor/camera/preview/CameraXView.java +3017 -0
- package/android/src/main/java/com/ahm/capacitor/camera/preview/GridOverlayView.java +119 -0
- package/android/src/main/java/com/ahm/capacitor/camera/preview/model/CameraDevice.java +63 -0
- package/android/src/main/java/com/ahm/capacitor/camera/preview/model/CameraLens.java +79 -0
- package/android/src/main/java/com/ahm/capacitor/camera/preview/model/CameraSessionConfiguration.java +167 -0
- package/android/src/main/java/com/ahm/capacitor/camera/preview/model/LensInfo.java +40 -0
- package/android/src/main/java/com/ahm/capacitor/camera/preview/model/ZoomFactors.java +35 -0
- package/dist/docs.json +1041 -161
- package/dist/esm/definitions.d.ts +484 -84
- package/dist/esm/definitions.js +10 -1
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/web.d.ts +78 -3
- package/dist/esm/web.js +813 -68
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +819 -68
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +819 -68
- package/dist/plugin.js.map +1 -1
- package/ios/Sources/CapgoCameraPreviewPlugin/CameraController.swift +1663 -0
- package/ios/Sources/CapgoCameraPreviewPlugin/GridOverlayView.swift +65 -0
- package/ios/Sources/CapgoCameraPreviewPlugin/Plugin.swift +1550 -0
- package/ios/Tests/CameraPreviewPluginTests/CameraPreviewPluginTests.swift +15 -0
- package/package.json +2 -2
- package/android/src/main/java/com/ahm/capacitor/camera/preview/CameraActivity.java +0 -1279
- package/android/src/main/java/com/ahm/capacitor/camera/preview/CustomSurfaceView.java +0 -29
- package/android/src/main/java/com/ahm/capacitor/camera/preview/CustomTextureView.java +0 -39
- package/android/src/main/java/com/ahm/capacitor/camera/preview/Preview.java +0 -461
- package/android/src/main/java/com/ahm/capacitor/camera/preview/TapGestureDetector.java +0 -24
- package/ios/Plugin/CameraController.swift +0 -809
- package/ios/Plugin/Info.plist +0 -24
- package/ios/Plugin/Plugin.h +0 -10
- package/ios/Plugin/Plugin.m +0 -18
- package/ios/Plugin/Plugin.swift +0 -511
- package/ios/Plugin.xcodeproj/project.pbxproj +0 -593
- package/ios/Plugin.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
- package/ios/Plugin.xcworkspace/contents.xcworkspacedata +0 -10
- package/ios/Plugin.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
- package/ios/PluginTests/Info.plist +0 -22
- package/ios/PluginTests/PluginTests.swift +0 -83
- package/ios/Podfile +0 -13
- package/ios/Podfile.lock +0 -23
package/README.md
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
<a href="https://capgo.app/"><img src='https://raw.githubusercontent.com/Cap-go/capgo/main/assets/capgo_banner.png' alt='Capgo - Instant updates for capacitor'/></a>
|
|
4
4
|
|
|
5
5
|
<div align="center">
|
|
6
|
-
<h2><a href="https://capgo.app/?ref=plugin"> ➡️ Get Instant updates for your App with Capgo
|
|
7
|
-
<h2><a href="https://capgo.app/consulting/?ref=plugin">
|
|
6
|
+
<h2><a href="https://capgo.app/?ref=plugin"> ➡️ Get Instant updates for your App with Capgo 🚀</a></h2>
|
|
7
|
+
<h2><a href="https://capgo.app/consulting/?ref=plugin"> Fix your annoying bug now, Hire a Capacitor expert 💪</a></h2>
|
|
8
8
|
</div>
|
|
9
9
|
|
|
10
10
|
<p>
|
|
@@ -92,6 +92,52 @@ Then run
|
|
|
92
92
|
npx cap sync
|
|
93
93
|
```
|
|
94
94
|
|
|
95
|
+
## Optional Configuration
|
|
96
|
+
|
|
97
|
+
To use certain features of this plugin, you will need to add the following permissions/keys to your native project configurations.
|
|
98
|
+
|
|
99
|
+
### Android
|
|
100
|
+
|
|
101
|
+
In your `android/app/src/main/AndroidManifest.xml`:
|
|
102
|
+
|
|
103
|
+
- **Audio Recording** (`disableAudio: false`):
|
|
104
|
+
```xml
|
|
105
|
+
<uses-permission android:name="android.permission.RECORD_AUDIO" />
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
- **Saving to Gallery** (`saveToGallery: true`):
|
|
109
|
+
```xml
|
|
110
|
+
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
- **Location in EXIF Data** (`withExifLocation: true`):
|
|
114
|
+
```xml
|
|
115
|
+
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
|
116
|
+
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### iOS
|
|
120
|
+
|
|
121
|
+
In your `ios/App/App/Info.plist`, you must provide descriptions for the permissions your app requires. The keys are added automatically, but you need to provide the `string` values.
|
|
122
|
+
|
|
123
|
+
- **Audio Recording** (`disableAudio: false`):
|
|
124
|
+
```xml
|
|
125
|
+
<key>NSMicrophoneUsageDescription</key>
|
|
126
|
+
<string>To record audio with videos</string>
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
- **Saving to Gallery** (`saveToGallery: true`):
|
|
130
|
+
```xml
|
|
131
|
+
<key>NSPhotoLibraryUsageDescription</key>
|
|
132
|
+
<string>To save photos to your gallery</string>
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
- **Location in EXIF Data** (`withExifLocation: true`):
|
|
136
|
+
```xml
|
|
137
|
+
<key>NSLocationWhenInUseUsageDescription</key>
|
|
138
|
+
<string>To add location data to your photos</string>
|
|
139
|
+
```
|
|
140
|
+
|
|
95
141
|
## Extra Android installation steps
|
|
96
142
|
|
|
97
143
|
**Important** `camera-preview` 3+ requires Gradle 7.
|
|
@@ -174,6 +220,10 @@ Documentation for the [uploader](https://github.com/Cap-go/capacitor-uploader)
|
|
|
174
220
|
* [`capture(...)`](#capture)
|
|
175
221
|
* [`captureSample(...)`](#capturesample)
|
|
176
222
|
* [`getSupportedFlashModes()`](#getsupportedflashmodes)
|
|
223
|
+
* [`setAspectRatio(...)`](#setaspectratio)
|
|
224
|
+
* [`getAspectRatio()`](#getaspectratio)
|
|
225
|
+
* [`setGridMode(...)`](#setgridmode)
|
|
226
|
+
* [`getGridMode()`](#getgridmode)
|
|
177
227
|
* [`getHorizontalFov()`](#gethorizontalfov)
|
|
178
228
|
* [`getSupportedPictureSizes()`](#getsupportedpicturesizes)
|
|
179
229
|
* [`setFlashMode(...)`](#setflashmode)
|
|
@@ -181,25 +231,41 @@ Documentation for the [uploader](https://github.com/Cap-go/capacitor-uploader)
|
|
|
181
231
|
* [`setOpacity(...)`](#setopacity)
|
|
182
232
|
* [`stopRecordVideo()`](#stoprecordvideo)
|
|
183
233
|
* [`startRecordVideo(...)`](#startrecordvideo)
|
|
234
|
+
* [`isRunning()`](#isrunning)
|
|
235
|
+
* [`getAvailableDevices()`](#getavailabledevices)
|
|
236
|
+
* [`getZoom()`](#getzoom)
|
|
237
|
+
* [`setZoom(...)`](#setzoom)
|
|
238
|
+
* [`getFlashMode()`](#getflashmode)
|
|
239
|
+
* [`removeAllListeners()`](#removealllisteners)
|
|
240
|
+
* [`setDeviceId(...)`](#setdeviceid)
|
|
241
|
+
* [`getDeviceId()`](#getdeviceid)
|
|
242
|
+
* [`getPreviewSize()`](#getpreviewsize)
|
|
243
|
+
* [`setPreviewSize(...)`](#setpreviewsize)
|
|
244
|
+
* [`setFocus(...)`](#setfocus)
|
|
184
245
|
* [Interfaces](#interfaces)
|
|
185
246
|
* [Type Aliases](#type-aliases)
|
|
247
|
+
* [Enums](#enums)
|
|
186
248
|
|
|
187
249
|
</docgen-index>
|
|
188
250
|
|
|
189
251
|
<docgen-api>
|
|
190
252
|
<!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
|
|
191
253
|
|
|
254
|
+
The main interface for the CameraPreview plugin.
|
|
255
|
+
|
|
192
256
|
### start(...)
|
|
193
257
|
|
|
194
258
|
```typescript
|
|
195
|
-
start(options: CameraPreviewOptions) => Promise<
|
|
259
|
+
start(options: CameraPreviewOptions) => Promise<{ width: number; height: number; x: number; y: number; }>
|
|
196
260
|
```
|
|
197
261
|
|
|
198
|
-
|
|
262
|
+
Starts the camera preview.
|
|
199
263
|
|
|
200
|
-
| Param | Type | Description
|
|
201
|
-
| ------------- | --------------------------------------------------------------------- |
|
|
202
|
-
| **`options`** | <code><a href="#camerapreviewoptions">CameraPreviewOptions</a></code> |
|
|
264
|
+
| Param | Type | Description |
|
|
265
|
+
| ------------- | --------------------------------------------------------------------- | ------------------------------------------- |
|
|
266
|
+
| **`options`** | <code><a href="#camerapreviewoptions">CameraPreviewOptions</a></code> | - The configuration for the camera preview. |
|
|
267
|
+
|
|
268
|
+
**Returns:** <code>Promise<{ width: number; height: number; x: number; y: number; }></code>
|
|
203
269
|
|
|
204
270
|
**Since:** 0.0.1
|
|
205
271
|
|
|
@@ -212,7 +278,7 @@ Start the camera preview instance.
|
|
|
212
278
|
stop() => Promise<void>
|
|
213
279
|
```
|
|
214
280
|
|
|
215
|
-
|
|
281
|
+
Stops the camera preview.
|
|
216
282
|
|
|
217
283
|
**Since:** 0.0.1
|
|
218
284
|
|
|
@@ -222,16 +288,16 @@ Stop the camera preview instance.
|
|
|
222
288
|
### capture(...)
|
|
223
289
|
|
|
224
290
|
```typescript
|
|
225
|
-
capture(options: CameraPreviewPictureOptions) => Promise<{ value: string; }>
|
|
291
|
+
capture(options: CameraPreviewPictureOptions) => Promise<{ value: string; exif: ExifData; }>
|
|
226
292
|
```
|
|
227
293
|
|
|
228
|
-
|
|
294
|
+
Captures a picture from the camera.
|
|
229
295
|
|
|
230
|
-
| Param | Type | Description
|
|
231
|
-
| ------------- | ----------------------------------------------------------------------------------- |
|
|
232
|
-
| **`options`** | <code><a href="#camerapreviewpictureoptions">CameraPreviewPictureOptions</a></code> |
|
|
296
|
+
| Param | Type | Description |
|
|
297
|
+
| ------------- | ----------------------------------------------------------------------------------- | ---------------------------------------- |
|
|
298
|
+
| **`options`** | <code><a href="#camerapreviewpictureoptions">CameraPreviewPictureOptions</a></code> | - The options for capturing the picture. |
|
|
233
299
|
|
|
234
|
-
**Returns:** <code>Promise<{ value: string; }></code>
|
|
300
|
+
**Returns:** <code>Promise<{ value: string; exif: <a href="#exifdata">ExifData</a>; }></code>
|
|
235
301
|
|
|
236
302
|
**Since:** 0.0.1
|
|
237
303
|
|
|
@@ -244,11 +310,11 @@ Switch camera.
|
|
|
244
310
|
captureSample(options: CameraSampleOptions) => Promise<{ value: string; }>
|
|
245
311
|
```
|
|
246
312
|
|
|
247
|
-
|
|
313
|
+
Captures a single frame from the camera preview stream.
|
|
248
314
|
|
|
249
|
-
| Param | Type | Description
|
|
250
|
-
| ------------- | ------------------------------------------------------------------- |
|
|
251
|
-
| **`options`** | <code><a href="#camerasampleoptions">CameraSampleOptions</a></code> |
|
|
315
|
+
| Param | Type | Description |
|
|
316
|
+
| ------------- | ------------------------------------------------------------------- | --------------------------------------- |
|
|
317
|
+
| **`options`** | <code><a href="#camerasampleoptions">CameraSampleOptions</a></code> | - The options for capturing the sample. |
|
|
252
318
|
|
|
253
319
|
**Returns:** <code>Promise<{ value: string; }></code>
|
|
254
320
|
|
|
@@ -263,7 +329,7 @@ Capture a sample image.
|
|
|
263
329
|
getSupportedFlashModes() => Promise<{ result: CameraPreviewFlashMode[]; }>
|
|
264
330
|
```
|
|
265
331
|
|
|
266
|
-
|
|
332
|
+
Gets the flash modes supported by the active camera.
|
|
267
333
|
|
|
268
334
|
**Returns:** <code>Promise<{ result: CameraPreviewFlashMode[]; }></code>
|
|
269
335
|
|
|
@@ -272,15 +338,82 @@ Get supported flash modes.
|
|
|
272
338
|
--------------------
|
|
273
339
|
|
|
274
340
|
|
|
341
|
+
### setAspectRatio(...)
|
|
342
|
+
|
|
343
|
+
```typescript
|
|
344
|
+
setAspectRatio(options: { aspectRatio: "4:3" | "16:9"; x?: number; y?: number; }) => Promise<{ width: number; height: number; x: number; y: number; }>
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
Set the aspect ratio of the camera preview.
|
|
348
|
+
|
|
349
|
+
| Param | Type | Description |
|
|
350
|
+
| ------------- | ---------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
351
|
+
| **`options`** | <code>{ aspectRatio: '4:3' \| '16:9'; x?: number; y?: number; }</code> | - The desired aspect ratio and optional position. - aspectRatio: The desired aspect ratio ('4:3' or '16:9') - x: Optional x coordinate for positioning. If not provided, view will be auto-centered horizontally. - y: Optional y coordinate for positioning. If not provided, view will be auto-centered vertically. |
|
|
352
|
+
|
|
353
|
+
**Returns:** <code>Promise<{ width: number; height: number; x: number; y: number; }></code>
|
|
354
|
+
|
|
355
|
+
**Since:** 7.4.0
|
|
356
|
+
|
|
357
|
+
--------------------
|
|
358
|
+
|
|
359
|
+
|
|
360
|
+
### getAspectRatio()
|
|
361
|
+
|
|
362
|
+
```typescript
|
|
363
|
+
getAspectRatio() => Promise<{ aspectRatio: "4:3" | "16:9"; }>
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
Gets the current aspect ratio of the camera preview.
|
|
367
|
+
|
|
368
|
+
**Returns:** <code>Promise<{ aspectRatio: '4:3' | '16:9'; }></code>
|
|
369
|
+
|
|
370
|
+
**Since:** 7.4.0
|
|
371
|
+
|
|
372
|
+
--------------------
|
|
373
|
+
|
|
374
|
+
|
|
375
|
+
### setGridMode(...)
|
|
376
|
+
|
|
377
|
+
```typescript
|
|
378
|
+
setGridMode(options: { gridMode: GridMode; }) => Promise<void>
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
Sets the grid mode of the camera preview overlay.
|
|
382
|
+
|
|
383
|
+
| Param | Type | Description |
|
|
384
|
+
| ------------- | ------------------------------------------------------------ | -------------------------------------------------- |
|
|
385
|
+
| **`options`** | <code>{ gridMode: <a href="#gridmode">GridMode</a>; }</code> | - The desired grid mode ('none', '3x3', or '4x4'). |
|
|
386
|
+
|
|
387
|
+
**Since:** 8.0.0
|
|
388
|
+
|
|
389
|
+
--------------------
|
|
390
|
+
|
|
391
|
+
|
|
392
|
+
### getGridMode()
|
|
393
|
+
|
|
394
|
+
```typescript
|
|
395
|
+
getGridMode() => Promise<{ gridMode: GridMode; }>
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
Gets the current grid mode of the camera preview overlay.
|
|
399
|
+
|
|
400
|
+
**Returns:** <code>Promise<{ gridMode: <a href="#gridmode">GridMode</a>; }></code>
|
|
401
|
+
|
|
402
|
+
**Since:** 8.0.0
|
|
403
|
+
|
|
404
|
+
--------------------
|
|
405
|
+
|
|
406
|
+
|
|
275
407
|
### getHorizontalFov()
|
|
276
408
|
|
|
277
409
|
```typescript
|
|
278
|
-
getHorizontalFov() => Promise<{ result:
|
|
410
|
+
getHorizontalFov() => Promise<{ result: number; }>
|
|
279
411
|
```
|
|
280
412
|
|
|
281
|
-
|
|
413
|
+
Gets the horizontal field of view (FoV) for the active camera.
|
|
414
|
+
Note: This can be an estimate on some devices.
|
|
282
415
|
|
|
283
|
-
**Returns:** <code>Promise<{ result:
|
|
416
|
+
**Returns:** <code>Promise<{ result: number; }></code>
|
|
284
417
|
|
|
285
418
|
**Since:** 0.0.1
|
|
286
419
|
|
|
@@ -290,12 +423,14 @@ Get horizontal field of view.
|
|
|
290
423
|
### getSupportedPictureSizes()
|
|
291
424
|
|
|
292
425
|
```typescript
|
|
293
|
-
getSupportedPictureSizes() => Promise<{ supportedPictureSizes:
|
|
426
|
+
getSupportedPictureSizes() => Promise<{ supportedPictureSizes: SupportedPictureSizes[]; }>
|
|
294
427
|
```
|
|
295
428
|
|
|
296
|
-
Gets the supported picture sizes for
|
|
429
|
+
Gets the supported picture sizes for all cameras.
|
|
430
|
+
|
|
431
|
+
**Returns:** <code>Promise<{ supportedPictureSizes: SupportedPictureSizes[]; }></code>
|
|
297
432
|
|
|
298
|
-
**
|
|
433
|
+
**Since:** 7.4.0
|
|
299
434
|
|
|
300
435
|
--------------------
|
|
301
436
|
|
|
@@ -306,11 +441,11 @@ Gets the supported picture sizes for a given device.
|
|
|
306
441
|
setFlashMode(options: { flashMode: CameraPreviewFlashMode | string; }) => Promise<void>
|
|
307
442
|
```
|
|
308
443
|
|
|
309
|
-
|
|
444
|
+
Sets the flash mode for the active camera.
|
|
310
445
|
|
|
311
|
-
| Param | Type | Description
|
|
312
|
-
| ------------- | ----------------------------------- |
|
|
313
|
-
| **`options`** | <code>{ flashMode: string; }</code> |
|
|
446
|
+
| Param | Type | Description |
|
|
447
|
+
| ------------- | ----------------------------------- | ------------------------- |
|
|
448
|
+
| **`options`** | <code>{ flashMode: string; }</code> | - The desired flash mode. |
|
|
314
449
|
|
|
315
450
|
**Since:** 0.0.1
|
|
316
451
|
|
|
@@ -323,7 +458,7 @@ Set flash mode.
|
|
|
323
458
|
flip() => Promise<void>
|
|
324
459
|
```
|
|
325
460
|
|
|
326
|
-
|
|
461
|
+
Toggles between the front and rear cameras.
|
|
327
462
|
|
|
328
463
|
**Since:** 0.0.1
|
|
329
464
|
|
|
@@ -336,11 +471,11 @@ Flip camera.
|
|
|
336
471
|
setOpacity(options: CameraOpacityOptions) => Promise<void>
|
|
337
472
|
```
|
|
338
473
|
|
|
339
|
-
|
|
474
|
+
Sets the opacity of the camera preview.
|
|
340
475
|
|
|
341
|
-
| Param | Type | Description
|
|
342
|
-
| ------------- | --------------------------------------------------------------------- |
|
|
343
|
-
| **`options`** | <code><a href="#cameraopacityoptions">CameraOpacityOptions</a></code> |
|
|
476
|
+
| Param | Type | Description |
|
|
477
|
+
| ------------- | --------------------------------------------------------------------- | ---------------------- |
|
|
478
|
+
| **`options`** | <code><a href="#cameraopacityoptions">CameraOpacityOptions</a></code> | - The opacity options. |
|
|
344
479
|
|
|
345
480
|
**Since:** 0.0.1
|
|
346
481
|
|
|
@@ -353,7 +488,7 @@ Set opacity.
|
|
|
353
488
|
stopRecordVideo() => Promise<{ videoFilePath: string; }>
|
|
354
489
|
```
|
|
355
490
|
|
|
356
|
-
|
|
491
|
+
Stops an ongoing video recording.
|
|
357
492
|
|
|
358
493
|
**Returns:** <code>Promise<{ videoFilePath: string; }></code>
|
|
359
494
|
|
|
@@ -368,77 +503,337 @@ Stop recording video.
|
|
|
368
503
|
startRecordVideo(options: CameraPreviewOptions) => Promise<void>
|
|
369
504
|
```
|
|
370
505
|
|
|
371
|
-
|
|
506
|
+
Starts recording a video.
|
|
372
507
|
|
|
373
|
-
| Param | Type | Description
|
|
374
|
-
| ------------- | --------------------------------------------------------------------- |
|
|
375
|
-
| **`options`** | <code><a href="#camerapreviewoptions">CameraPreviewOptions</a></code> |
|
|
508
|
+
| Param | Type | Description |
|
|
509
|
+
| ------------- | --------------------------------------------------------------------- | ---------------------------------- |
|
|
510
|
+
| **`options`** | <code><a href="#camerapreviewoptions">CameraPreviewOptions</a></code> | - The options for video recording. |
|
|
376
511
|
|
|
377
512
|
**Since:** 0.0.1
|
|
378
513
|
|
|
379
514
|
--------------------
|
|
380
515
|
|
|
381
516
|
|
|
517
|
+
### isRunning()
|
|
518
|
+
|
|
519
|
+
```typescript
|
|
520
|
+
isRunning() => Promise<{ isRunning: boolean; }>
|
|
521
|
+
```
|
|
522
|
+
|
|
523
|
+
Checks if the camera preview is currently running.
|
|
524
|
+
|
|
525
|
+
**Returns:** <code>Promise<{ isRunning: boolean; }></code>
|
|
526
|
+
|
|
527
|
+
**Since:** 7.4.0
|
|
528
|
+
|
|
529
|
+
--------------------
|
|
530
|
+
|
|
531
|
+
|
|
532
|
+
### getAvailableDevices()
|
|
533
|
+
|
|
534
|
+
```typescript
|
|
535
|
+
getAvailableDevices() => Promise<{ devices: CameraDevice[]; }>
|
|
536
|
+
```
|
|
537
|
+
|
|
538
|
+
Gets all available camera devices.
|
|
539
|
+
|
|
540
|
+
**Returns:** <code>Promise<{ devices: CameraDevice[]; }></code>
|
|
541
|
+
|
|
542
|
+
**Since:** 7.4.0
|
|
543
|
+
|
|
544
|
+
--------------------
|
|
545
|
+
|
|
546
|
+
|
|
547
|
+
### getZoom()
|
|
548
|
+
|
|
549
|
+
```typescript
|
|
550
|
+
getZoom() => Promise<{ min: number; max: number; current: number; lens: LensInfo; }>
|
|
551
|
+
```
|
|
552
|
+
|
|
553
|
+
Gets the current zoom state, including min/max and current lens info.
|
|
554
|
+
|
|
555
|
+
**Returns:** <code>Promise<{ min: number; max: number; current: number; lens: <a href="#lensinfo">LensInfo</a>; }></code>
|
|
556
|
+
|
|
557
|
+
**Since:** 7.4.0
|
|
558
|
+
|
|
559
|
+
--------------------
|
|
560
|
+
|
|
561
|
+
|
|
562
|
+
### setZoom(...)
|
|
563
|
+
|
|
564
|
+
```typescript
|
|
565
|
+
setZoom(options: { level: number; ramp?: boolean; autoFocus?: boolean; }) => Promise<void>
|
|
566
|
+
```
|
|
567
|
+
|
|
568
|
+
Sets the zoom level of the camera.
|
|
569
|
+
|
|
570
|
+
| Param | Type | Description |
|
|
571
|
+
| ------------- | -------------------------------------------------------------------- | ----------------------------------------------------------------------------------- |
|
|
572
|
+
| **`options`** | <code>{ level: number; ramp?: boolean; autoFocus?: boolean; }</code> | - The desired zoom level. `ramp` is currently unused. `autoFocus` defaults to true. |
|
|
573
|
+
|
|
574
|
+
**Since:** 7.4.0
|
|
575
|
+
|
|
576
|
+
--------------------
|
|
577
|
+
|
|
578
|
+
|
|
579
|
+
### getFlashMode()
|
|
580
|
+
|
|
581
|
+
```typescript
|
|
582
|
+
getFlashMode() => Promise<{ flashMode: FlashMode; }>
|
|
583
|
+
```
|
|
584
|
+
|
|
585
|
+
Gets the current flash mode.
|
|
586
|
+
|
|
587
|
+
**Returns:** <code>Promise<{ flashMode: <a href="#camerapreviewflashmode">CameraPreviewFlashMode</a>; }></code>
|
|
588
|
+
|
|
589
|
+
**Since:** 7.4.0
|
|
590
|
+
|
|
591
|
+
--------------------
|
|
592
|
+
|
|
593
|
+
|
|
594
|
+
### removeAllListeners()
|
|
595
|
+
|
|
596
|
+
```typescript
|
|
597
|
+
removeAllListeners() => Promise<void>
|
|
598
|
+
```
|
|
599
|
+
|
|
600
|
+
Removes all registered listeners.
|
|
601
|
+
|
|
602
|
+
**Since:** 7.4.0
|
|
603
|
+
|
|
604
|
+
--------------------
|
|
605
|
+
|
|
606
|
+
|
|
607
|
+
### setDeviceId(...)
|
|
608
|
+
|
|
609
|
+
```typescript
|
|
610
|
+
setDeviceId(options: { deviceId: string; }) => Promise<void>
|
|
611
|
+
```
|
|
612
|
+
|
|
613
|
+
Switches the active camera to the one with the specified `deviceId`.
|
|
614
|
+
|
|
615
|
+
| Param | Type | Description |
|
|
616
|
+
| ------------- | ---------------------------------- | ------------------------------------ |
|
|
617
|
+
| **`options`** | <code>{ deviceId: string; }</code> | - The ID of the device to switch to. |
|
|
618
|
+
|
|
619
|
+
**Since:** 7.4.0
|
|
620
|
+
|
|
621
|
+
--------------------
|
|
622
|
+
|
|
623
|
+
|
|
624
|
+
### getDeviceId()
|
|
625
|
+
|
|
626
|
+
```typescript
|
|
627
|
+
getDeviceId() => Promise<{ deviceId: string; }>
|
|
628
|
+
```
|
|
629
|
+
|
|
630
|
+
Gets the ID of the currently active camera device.
|
|
631
|
+
|
|
632
|
+
**Returns:** <code>Promise<{ deviceId: string; }></code>
|
|
633
|
+
|
|
634
|
+
**Since:** 7.4.0
|
|
635
|
+
|
|
636
|
+
--------------------
|
|
637
|
+
|
|
638
|
+
|
|
639
|
+
### getPreviewSize()
|
|
640
|
+
|
|
641
|
+
```typescript
|
|
642
|
+
getPreviewSize() => Promise<{ x: number; y: number; width: number; height: number; }>
|
|
643
|
+
```
|
|
644
|
+
|
|
645
|
+
Gets the current preview size and position.
|
|
646
|
+
|
|
647
|
+
**Returns:** <code>Promise<{ x: number; y: number; width: number; height: number; }></code>
|
|
648
|
+
|
|
649
|
+
--------------------
|
|
650
|
+
|
|
651
|
+
|
|
652
|
+
### setPreviewSize(...)
|
|
653
|
+
|
|
654
|
+
```typescript
|
|
655
|
+
setPreviewSize(options: { x?: number; y?: number; width: number; height: number; }) => Promise<{ width: number; height: number; x: number; y: number; }>
|
|
656
|
+
```
|
|
657
|
+
|
|
658
|
+
Sets the preview size and position.
|
|
659
|
+
|
|
660
|
+
| Param | Type | Description |
|
|
661
|
+
| ------------- | ----------------------------------------------------------------------- | -------------------------------- |
|
|
662
|
+
| **`options`** | <code>{ x?: number; y?: number; width: number; height: number; }</code> | The new position and dimensions. |
|
|
663
|
+
|
|
664
|
+
**Returns:** <code>Promise<{ width: number; height: number; x: number; y: number; }></code>
|
|
665
|
+
|
|
666
|
+
--------------------
|
|
667
|
+
|
|
668
|
+
|
|
669
|
+
### setFocus(...)
|
|
670
|
+
|
|
671
|
+
```typescript
|
|
672
|
+
setFocus(options: { x: number; y: number; }) => Promise<void>
|
|
673
|
+
```
|
|
674
|
+
|
|
675
|
+
Sets the camera focus to a specific point in the preview.
|
|
676
|
+
|
|
677
|
+
| Param | Type | Description |
|
|
678
|
+
| ------------- | -------------------------------------- | -------------------- |
|
|
679
|
+
| **`options`** | <code>{ x: number; y: number; }</code> | - The focus options. |
|
|
680
|
+
|
|
681
|
+
**Since:** 8.1.0
|
|
682
|
+
|
|
683
|
+
--------------------
|
|
684
|
+
|
|
685
|
+
|
|
382
686
|
### Interfaces
|
|
383
687
|
|
|
384
688
|
|
|
385
689
|
#### CameraPreviewOptions
|
|
386
690
|
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
|
390
|
-
|
|
|
391
|
-
| **`
|
|
392
|
-
| **`
|
|
393
|
-
| **`
|
|
394
|
-
| **`
|
|
395
|
-
| **`
|
|
396
|
-
| **`
|
|
397
|
-
| **`
|
|
398
|
-
| **`
|
|
399
|
-
| **`
|
|
400
|
-
| **`
|
|
401
|
-
| **`
|
|
402
|
-
| **`
|
|
403
|
-
| **`
|
|
404
|
-
| **`
|
|
405
|
-
| **`
|
|
406
|
-
| **`
|
|
407
|
-
| **`
|
|
691
|
+
Defines the configuration options for starting the camera preview.
|
|
692
|
+
|
|
693
|
+
| Prop | Type | Description | Default | Since |
|
|
694
|
+
| ---------------------------------- | --------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------- | ----- |
|
|
695
|
+
| **`parent`** | <code>string</code> | The parent element to attach the video preview to. | | |
|
|
696
|
+
| **`className`** | <code>string</code> | A CSS class name to add to the preview element. | | |
|
|
697
|
+
| **`width`** | <code>number</code> | The width of the preview in pixels. Defaults to the screen width. | | |
|
|
698
|
+
| **`height`** | <code>number</code> | The height of the preview in pixels. Defaults to the screen height. | | |
|
|
699
|
+
| **`x`** | <code>number</code> | The horizontal origin of the preview, in pixels. | | |
|
|
700
|
+
| **`y`** | <code>number</code> | The vertical origin of the preview, in pixels. | | |
|
|
701
|
+
| **`aspectRatio`** | <code>'4:3' \| '16:9'</code> | The aspect ratio of the camera preview, '4:3' or '16:9' or 'fill'. Cannot be set if width or height is provided, otherwise the call will be rejected. Use setPreviewSize to adjust size after starting. | | 2.0.0 |
|
|
702
|
+
| **`gridMode`** | <code><a href="#gridmode">GridMode</a></code> | The grid overlay to display on the camera preview. | <code>"none"</code> | 2.1.0 |
|
|
703
|
+
| **`includeSafeAreaInsets`** | <code>boolean</code> | Adjusts the y-position to account for safe areas (e.g., notches). | <code>false</code> | |
|
|
704
|
+
| **`toBack`** | <code>boolean</code> | If true, places the preview behind the webview. | <code>true</code> | |
|
|
705
|
+
| **`paddingBottom`** | <code>number</code> | Bottom padding for the preview, in pixels. | | |
|
|
706
|
+
| **`rotateWhenOrientationChanged`** | <code>boolean</code> | Whether to rotate the preview when the device orientation changes. | <code>true</code> | |
|
|
707
|
+
| **`position`** | <code>string</code> | The camera to use. | <code>"rear"</code> | |
|
|
708
|
+
| **`storeToFile`** | <code>boolean</code> | If true, saves the captured image to a file and returns the file path. If false, returns a base64 encoded string. | <code>false</code> | |
|
|
709
|
+
| **`disableExifHeaderStripping`** | <code>boolean</code> | If true, prevents the plugin from rotating the image based on EXIF data. | <code>false</code> | |
|
|
710
|
+
| **`disableAudio`** | <code>boolean</code> | If true, disables the audio stream, preventing audio permission requests. | <code>true</code> | |
|
|
711
|
+
| **`lockAndroidOrientation`** | <code>boolean</code> | If true, locks the device orientation while the camera is active. | <code>false</code> | |
|
|
712
|
+
| **`enableOpacity`** | <code>boolean</code> | If true, allows the camera preview's opacity to be changed. | <code>false</code> | |
|
|
713
|
+
| **`enableZoom`** | <code>boolean</code> | If true, enables pinch-to-zoom functionality on the preview. | <code>false</code> | |
|
|
714
|
+
| **`enableVideoMode`** | <code>boolean</code> | If true, uses the video-optimized preset for the camera session. | <code>false</code> | |
|
|
715
|
+
| **`deviceId`** | <code>string</code> | The `deviceId` of the camera to use. If provided, `position` is ignored. | | |
|
|
716
|
+
| **`initialZoomLevel`** | <code>number</code> | The initial zoom level when starting the camera preview. If the requested zoom level is not available, the native plugin will reject. | <code>1.0</code> | 2.2.0 |
|
|
717
|
+
| **`positioning`** | <code><a href="#camerapositioning">CameraPositioning</a></code> | The vertical positioning of the camera preview. | <code>"center"</code> | 2.3.0 |
|
|
718
|
+
|
|
719
|
+
|
|
720
|
+
#### ExifData
|
|
721
|
+
|
|
722
|
+
Represents EXIF data extracted from an image.
|
|
408
723
|
|
|
409
724
|
|
|
410
725
|
#### CameraPreviewPictureOptions
|
|
411
726
|
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
|
415
|
-
|
|
|
416
|
-
| **`
|
|
417
|
-
| **`
|
|
727
|
+
Defines the options for capturing a picture.
|
|
728
|
+
|
|
729
|
+
| Prop | Type | Description | Default | Since |
|
|
730
|
+
| ---------------------- | ------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ | ------------------- | ----- |
|
|
731
|
+
| **`height`** | <code>number</code> | | | |
|
|
732
|
+
| **`width`** | <code>number</code> | | | |
|
|
733
|
+
| **`aspectRatio`** | <code>string</code> | | | 7.7.0 |
|
|
734
|
+
| **`quality`** | <code>number</code> | The quality of the captured image, from 0 to 100. Does not apply to `png` format. | <code>85</code> | |
|
|
735
|
+
| **`format`** | <code><a href="#pictureformat">PictureFormat</a></code> | The format of the captured image. | <code>"jpeg"</code> | |
|
|
736
|
+
| **`saveToGallery`** | <code>boolean</code> | If true, the captured image will be saved to the user's gallery. | <code>false</code> | 7.5.0 |
|
|
737
|
+
| **`withExifLocation`** | <code>boolean</code> | If true, the plugin will attempt to add GPS location data to the image's EXIF metadata. This may prompt the user for location permissions. | <code>false</code> | 7.6.0 |
|
|
418
738
|
|
|
419
739
|
|
|
420
740
|
#### CameraSampleOptions
|
|
421
741
|
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
|
742
|
+
Defines the options for capturing a sample frame from the camera preview.
|
|
743
|
+
|
|
744
|
+
| Prop | Type | Description | Default |
|
|
745
|
+
| ------------- | ------------------- | -------------------------------------------------- | --------------- |
|
|
746
|
+
| **`quality`** | <code>number</code> | The quality of the captured sample, from 0 to 100. | <code>85</code> |
|
|
747
|
+
|
|
748
|
+
|
|
749
|
+
#### SupportedPictureSizes
|
|
750
|
+
|
|
751
|
+
Represents the supported picture sizes for a camera facing a certain direction.
|
|
752
|
+
|
|
753
|
+
| Prop | Type | Description |
|
|
754
|
+
| --------------------------- | -------------------------- | -------------------------------------------------- |
|
|
755
|
+
| **`facing`** | <code>string</code> | The camera direction ("front" or "rear"). |
|
|
756
|
+
| **`supportedPictureSizes`** | <code>PictureSize[]</code> | A list of supported picture sizes for this camera. |
|
|
757
|
+
|
|
758
|
+
|
|
759
|
+
#### PictureSize
|
|
760
|
+
|
|
761
|
+
Defines a standard picture size with width and height.
|
|
762
|
+
|
|
763
|
+
| Prop | Type | Description |
|
|
764
|
+
| ------------ | ------------------- | ------------------------------------ |
|
|
765
|
+
| **`width`** | <code>number</code> | The width of the picture in pixels. |
|
|
766
|
+
| **`height`** | <code>number</code> | The height of the picture in pixels. |
|
|
425
767
|
|
|
426
768
|
|
|
427
769
|
#### CameraOpacityOptions
|
|
428
770
|
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
|
771
|
+
Defines the options for setting the camera preview's opacity.
|
|
772
|
+
|
|
773
|
+
| Prop | Type | Description | Default |
|
|
774
|
+
| ------------- | ------------------- | --------------------------------------------------------------------------- | ---------------- |
|
|
775
|
+
| **`opacity`** | <code>number</code> | The opacity percentage, from 0.0 (fully transparent) to 1.0 (fully opaque). | <code>1.0</code> |
|
|
776
|
+
|
|
777
|
+
|
|
778
|
+
#### CameraDevice
|
|
779
|
+
|
|
780
|
+
Represents a physical camera on the device (e.g., the front-facing camera).
|
|
781
|
+
|
|
782
|
+
| Prop | Type | Description |
|
|
783
|
+
| --------------- | --------------------------------------------------------- | ----------------------------------------------------------------------------------------- |
|
|
784
|
+
| **`deviceId`** | <code>string</code> | A unique identifier for the camera device. |
|
|
785
|
+
| **`label`** | <code>string</code> | A human-readable name for the camera device. |
|
|
786
|
+
| **`position`** | <code><a href="#cameraposition">CameraPosition</a></code> | The physical position of the camera on the device. |
|
|
787
|
+
| **`lenses`** | <code>CameraLens[]</code> | A list of all available lenses for this camera device. |
|
|
788
|
+
| **`minZoom`** | <code>number</code> | The overall minimum zoom factor available across all lenses on this device. |
|
|
789
|
+
| **`maxZoom`** | <code>number</code> | The overall maximum zoom factor available across all lenses on this device. |
|
|
790
|
+
| **`isLogical`** | <code>boolean</code> | Identifies whether the device is a logical camera (composed of multiple physical lenses). |
|
|
791
|
+
|
|
792
|
+
|
|
793
|
+
#### CameraLens
|
|
794
|
+
|
|
795
|
+
Represents a single camera lens on a device. A {@link <a href="#cameradevice">CameraDevice</a>} can have multiple lenses.
|
|
796
|
+
|
|
797
|
+
| Prop | Type | Description |
|
|
798
|
+
| ------------------- | ------------------------------------------------- | ---------------------------------------------------------------------------- |
|
|
799
|
+
| **`label`** | <code>string</code> | A human-readable name for the lens, e.g., "Ultra-Wide". |
|
|
800
|
+
| **`deviceType`** | <code><a href="#devicetype">DeviceType</a></code> | The type of the camera lens. |
|
|
801
|
+
| **`focalLength`** | <code>number</code> | The focal length of the lens in millimeters. |
|
|
802
|
+
| **`baseZoomRatio`** | <code>number</code> | The base zoom factor for this lens (e.g., 0.5 for ultra-wide, 1.0 for wide). |
|
|
803
|
+
| **`minZoom`** | <code>number</code> | The minimum zoom factor supported by this specific lens. |
|
|
804
|
+
| **`maxZoom`** | <code>number</code> | The maximum zoom factor supported by this specific lens. |
|
|
805
|
+
|
|
806
|
+
|
|
807
|
+
#### LensInfo
|
|
808
|
+
|
|
809
|
+
Represents the detailed information of the currently active lens.
|
|
810
|
+
|
|
811
|
+
| Prop | Type | Description |
|
|
812
|
+
| ------------------- | ------------------------------------------------- | ---------------------------------------------------------------- |
|
|
813
|
+
| **`focalLength`** | <code>number</code> | The focal length of the active lens in millimeters. |
|
|
814
|
+
| **`deviceType`** | <code><a href="#devicetype">DeviceType</a></code> | The device type of the active lens. |
|
|
815
|
+
| **`baseZoomRatio`** | <code>number</code> | The base zoom ratio of the active lens (e.g., 0.5x, 1.0x). |
|
|
816
|
+
| **`digitalZoom`** | <code>number</code> | The current digital zoom factor applied on top of the base zoom. |
|
|
432
817
|
|
|
433
818
|
|
|
434
819
|
### Type Aliases
|
|
435
820
|
|
|
436
821
|
|
|
822
|
+
#### GridMode
|
|
823
|
+
|
|
824
|
+
<code>"none" | "3x3" | "4x4"</code>
|
|
825
|
+
|
|
826
|
+
|
|
437
827
|
#### CameraPosition
|
|
438
828
|
|
|
439
829
|
<code>"rear" | "front"</code>
|
|
440
830
|
|
|
441
831
|
|
|
832
|
+
#### CameraPositioning
|
|
833
|
+
|
|
834
|
+
<code>"center" | "top" | "bottom"</code>
|
|
835
|
+
|
|
836
|
+
|
|
442
837
|
#### PictureFormat
|
|
443
838
|
|
|
444
839
|
<code>"jpeg" | "png"</code>
|
|
@@ -446,6 +841,30 @@ Start recording video.
|
|
|
446
841
|
|
|
447
842
|
#### CameraPreviewFlashMode
|
|
448
843
|
|
|
449
|
-
|
|
844
|
+
The available flash modes for the camera.
|
|
845
|
+
'torch' is a continuous light mode.
|
|
846
|
+
|
|
847
|
+
<code>"off" | "on" | "auto" | "torch"</code>
|
|
848
|
+
|
|
849
|
+
|
|
850
|
+
#### FlashMode
|
|
851
|
+
|
|
852
|
+
<code><a href="#camerapreviewflashmode">CameraPreviewFlashMode</a></code>
|
|
853
|
+
|
|
854
|
+
|
|
855
|
+
### Enums
|
|
856
|
+
|
|
857
|
+
|
|
858
|
+
#### DeviceType
|
|
859
|
+
|
|
860
|
+
| Members | Value |
|
|
861
|
+
| ---------------- | ------------------------ |
|
|
862
|
+
| **`ULTRA_WIDE`** | <code>"ultraWide"</code> |
|
|
863
|
+
| **`WIDE_ANGLE`** | <code>"wideAngle"</code> |
|
|
864
|
+
| **`TELEPHOTO`** | <code>"telephoto"</code> |
|
|
865
|
+
| **`TRUE_DEPTH`** | <code>"trueDepth"</code> |
|
|
866
|
+
| **`DUAL`** | <code>"dual"</code> |
|
|
867
|
+
| **`DUAL_WIDE`** | <code>"dualWide"</code> |
|
|
868
|
+
| **`TRIPLE`** | <code>"triple"</code> |
|
|
450
869
|
|
|
451
870
|
</docgen-api>
|