@capgo/camera-preview 3.6.23 → 4.0.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/README.md +67 -405
- package/android/build.gradle +8 -7
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +1 -1
- package/android/gradle.properties +1 -1
- package/android/gradlew +2 -2
- package/android/src/androidTest/java/com/getcapacitor/android/ExampleInstrumentedTest.java +6 -6
- package/android/src/main/AndroidManifest.xml +1 -1
- package/android/src/main/java/com/ahm/capacitor/camera/preview/CameraActivity.java +1105 -854
- package/android/src/main/java/com/ahm/capacitor/camera/preview/CameraPreview.java +543 -428
- package/android/src/main/java/com/ahm/capacitor/camera/preview/CustomSurfaceView.java +15 -10
- package/android/src/main/java/com/ahm/capacitor/camera/preview/CustomTextureView.java +31 -21
- package/android/src/main/java/com/ahm/capacitor/camera/preview/Preview.java +386 -332
- package/android/src/main/java/com/ahm/capacitor/camera/preview/TapGestureDetector.java +13 -13
- package/android/src/test/java/com/getcapacitor/ExampleUnitTest.java +4 -4
- package/dist/docs.json +208 -37
- package/dist/esm/definitions.d.ts +76 -3
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.js +4 -4
- package/dist/esm/web.d.ts +2 -2
- package/dist/esm/web.js +39 -36
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +39 -36
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +39 -36
- package/dist/plugin.js.map +1 -1
- package/ios/Plugin/CameraController.swift +1 -1
- package/ios/Plugin/Plugin.swift +1 -1
- package/ios/Podfile.lock +3 -3
- package/package.json +22 -22
- package/android/.gradle/7.6/checksums/checksums.lock +0 -0
- package/android/.gradle/7.6/checksums/md5-checksums.bin +0 -0
- package/android/.gradle/7.6/checksums/sha1-checksums.bin +0 -0
- package/android/.gradle/7.6/dependencies-accessors/dependencies-accessors.lock +0 -0
- package/android/.gradle/7.6/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/7.6/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/7.6/fileChanges/last-build.bin +0 -0
- package/android/.gradle/7.6/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/7.6/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +0 -2
- package/android/.gradle/vcs-1/gc.properties +0 -0
package/README.md
CHANGED
|
@@ -67,389 +67,7 @@ You will need to add two permissions to `Info.plist`. Follow the [Capacitor docs
|
|
|
67
67
|
|
|
68
68
|
Add `import '@capgo/camera-preview'` to you entry script in ionic on `app.module.ts`, so capacitor can register the web platform from the plugin
|
|
69
69
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
### start(options)
|
|
73
|
-
|
|
74
|
-
Starts the camera preview instance.
|
|
75
|
-
<br>
|
|
76
|
-
|
|
77
|
-
| Option | values | descriptions |
|
|
78
|
-
| ---------------------------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
79
|
-
| position | front \| rear | Show front or rear camera when start the preview. Defaults to front |
|
|
80
|
-
| width | number | (optional) The preview width in pixels, default window.screen.width (applicable to the android and ios platforms only) |
|
|
81
|
-
| height | number | (optional) The preview height in pixels, default window.screen.height (applicable to the android and ios platforms only) |
|
|
82
|
-
| x | number | (optional) The x origin, default 0 (applicable to the android and ios platforms only) |
|
|
83
|
-
| y | number | (optional) The y origin, default 0 (applicable to the android and ios platforms only) |
|
|
84
|
-
| toBack | boolean | (optional) Brings your html in front of your preview, default false (applicable to the android and ios platforms only) |
|
|
85
|
-
| paddingBottom | number | (optional) The preview bottom padding in pixes. Useful to keep the appropriate preview sizes when orientation changes (applicable to the android and ios platforms only) |
|
|
86
|
-
| rotateWhenOrientationChanged | boolean | (optional) Rotate preview when orientation changes (applicable to the ios platforms only; default value is true) |
|
|
87
|
-
| storeToFile | boolean | (optional) Capture images to a file and return back the file path instead of returning base64 encoded data, default false. |
|
|
88
|
-
| disableExifHeaderStripping | boolean | (optional) Disable automatic rotation of the image, and let the browser deal with it, default true (applicable to the android and ios platforms only) |
|
|
89
|
-
| enableHighResolution | boolean | (optional) Defaults to false - iOS only - Activate high resolution image capture so that output images are from the highest resolution possible on the device |
|
|
90
|
-
| disableAudio | boolean | (optional) Disables audio stream to prevent permission requests, default false. (applicable to web and iOS only) |
|
|
91
|
-
| lockAndroidOrientation | boolean | (optional) Locks device orientation when camera is showing, default false. (applicable to Android only) |
|
|
92
|
-
| enableOpacity | boolean | (optional) Make the camera preview see-through. Ideal for augmented reality uses. Default false (applicable to Android and web only) |
|
|
93
|
-
| enableZoom | boolean | (optional) Set if you can pinch to zoom. Default false (applicable to the android and ios platforms only) |
|
|
94
|
-
|
|
95
|
-
<!-- <strong>Options:</strong>
|
|
96
|
-
All options stated are optional and will default to values here
|
|
97
|
-
|
|
98
|
-
* `x` - Defaults to 0
|
|
99
|
-
* `y` - Defaults to 0
|
|
100
|
-
* `width` - Defaults to window.screen.width
|
|
101
|
-
* `height` - Defaults to window.screen.height
|
|
102
|
-
* `camera` - See <code>[CAMERA_DIRECTION](#camera_Settings.CameraDirection)</code> - Defaults to front camera
|
|
103
|
-
* `toBack` - Defaults to false - Set to true if you want your html in front of your preview
|
|
104
|
-
* `tapPhoto` - Defaults to true - Does not work if toBack is set to false in which case you use the takePicture method
|
|
105
|
-
* `tapFocus` - Defaults to false - Allows the user to tap to focus, when the view is in the foreground
|
|
106
|
-
* `previewDrag` - Defaults to false - Does not work if toBack is set to false
|
|
107
|
-
* `storeToFile` - Defaults to false - Capture images to a file and return back the file path instead of returning base64 encoded data.
|
|
108
|
-
* `disableExifHeaderStripping` - Defaults to false - **Android Only** - Disable automatic rotation of the image, and let the browser deal with it (keep reading on how to achieve it) -->
|
|
109
|
-
|
|
110
|
-
```javascript
|
|
111
|
-
import { CameraPreview, CameraPreviewOptions } from '@capgo/camera-preview';
|
|
112
|
-
|
|
113
|
-
const cameraPreviewOptions: CameraPreviewOptions = {
|
|
114
|
-
position: 'rear',
|
|
115
|
-
height: 1920,
|
|
116
|
-
width: 1080,
|
|
117
|
-
};
|
|
118
|
-
CameraPreview.start(cameraPreviewOptions);
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
Remember to add the style below on your app's HTML or body element:
|
|
122
|
-
|
|
123
|
-
```css
|
|
124
|
-
ion-content {
|
|
125
|
-
--background: transparent;
|
|
126
|
-
}
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
Take into account that this will make transparent all ion-content on application, if you want to show camera preview only in one page, just add a custom class to your ion-content and make it transparent:
|
|
130
|
-
|
|
131
|
-
```css
|
|
132
|
-
.my-custom-camera-preview-content {
|
|
133
|
-
--background: transparent;
|
|
134
|
-
}
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
If the camera preview is not displaying after applying the above styles, apply transparent background color to the root div element of the parent component
|
|
138
|
-
Ex: VueJS >> App.vue component
|
|
139
|
-
|
|
140
|
-
```html
|
|
141
|
-
<template>
|
|
142
|
-
<ion-app id="app">
|
|
143
|
-
<ion-router-outlet />
|
|
144
|
-
</ion-app>
|
|
145
|
-
</template>
|
|
146
|
-
|
|
147
|
-
<style>
|
|
148
|
-
#app {
|
|
149
|
-
background-color: transparent !important;
|
|
150
|
-
}
|
|
151
|
-
<style>
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
### stop()
|
|
155
|
-
|
|
156
|
-
<info>Stops the camera preview instance.</info><br/>
|
|
157
|
-
|
|
158
|
-
```javascript
|
|
159
|
-
CameraPreview.stop();
|
|
160
|
-
```
|
|
161
|
-
|
|
162
|
-
### flip()
|
|
163
|
-
|
|
164
|
-
<info>Switch between rear and front camera only for android and ios, web is not supported</info>
|
|
165
|
-
|
|
166
|
-
```javascript
|
|
167
|
-
CameraPreview.flip();
|
|
168
|
-
```
|
|
169
|
-
|
|
170
|
-
<!-- ### switchCamera([successCallback, errorCallback])
|
|
171
|
-
|
|
172
|
-
<info>Switch between the rear camera and front camera, if available.</info><br/>
|
|
173
|
-
|
|
174
|
-
```javascript
|
|
175
|
-
CameraPreview.switchCamera();
|
|
176
|
-
```
|
|
177
|
-
|
|
178
|
-
### show([successCallback, errorCallback])
|
|
179
|
-
|
|
180
|
-
<info>Show the camera preview box.</info><br/>
|
|
181
|
-
|
|
182
|
-
```javascript
|
|
183
|
-
CameraPreview.show();
|
|
184
|
-
```
|
|
185
|
-
|
|
186
|
-
### hide([successCallback, errorCallback])
|
|
187
|
-
|
|
188
|
-
<info>Hide the camera preview box.</info><br/>
|
|
189
|
-
|
|
190
|
-
```javascript
|
|
191
|
-
CameraPreview.hide();
|
|
192
|
-
``` -->
|
|
193
|
-
|
|
194
|
-
### capture(options)
|
|
195
|
-
|
|
196
|
-
| Option | values | descriptions |
|
|
197
|
-
| ------- | ------ | --------------------------------------------------------- |
|
|
198
|
-
| quality | number | (optional) The picture quality, 0 - 100, default 85 |
|
|
199
|
-
| width | number | (optional) The picture width, default 0 (Device default) |
|
|
200
|
-
| height | number | (optional) The picture height, default 0 (Device default) |
|
|
201
|
-
|
|
202
|
-
<!-- <info>Take the picture. If width and height are not specified or are 0 it will use the defaults. If width and height are specified, it will choose a supported photo size that is closest to width and height specified and has closest aspect ratio to the preview. The argument `quality` defaults to `85` and specifies the quality/compression value: `0=max compression`, `100=max quality`.</info><br/> -->
|
|
203
|
-
|
|
204
|
-
```javascript
|
|
205
|
-
import { CameraPreviewPictureOptions } from '@capgo/camera-preview';
|
|
206
|
-
|
|
207
|
-
const cameraPreviewPictureOptions: CameraPreviewPictureOptions = {
|
|
208
|
-
quality: 50,
|
|
209
|
-
};
|
|
210
|
-
|
|
211
|
-
const result = await CameraPreview.capture(cameraPreviewPictureOptions);
|
|
212
|
-
const base64PictureData = result.value;
|
|
213
|
-
|
|
214
|
-
// do sometime with base64PictureData
|
|
215
|
-
```
|
|
216
|
-
|
|
217
|
-
### captureSample(options)
|
|
218
|
-
|
|
219
|
-
| Option | values | descriptions |
|
|
220
|
-
| ------- | ------ | --------------------------------------------------- |
|
|
221
|
-
| quality | number | (optional) The picture quality, 0 - 100, default 85 |
|
|
222
|
-
|
|
223
|
-
<info>Captures a sample image from the video stream. Only for Android and iOS, web implementation falls back to `capture` method. This can be used to perform real-time analysis on the current frame in the video. The argument `quality` defaults to `85` and specifies the quality/compression value: `0=max compression`, `100=max quality`.</info><br/>
|
|
224
|
-
|
|
225
|
-
```javascript
|
|
226
|
-
import { CameraSampleOptions } from '@capgo/camera-preview';
|
|
227
|
-
|
|
228
|
-
const cameraSampleOptions: CameraSampleOptions = {
|
|
229
|
-
quality: 50,
|
|
230
|
-
};
|
|
231
|
-
|
|
232
|
-
const result = await CameraPreview.captureSample(cameraSampleOptions);
|
|
233
|
-
const base64PictureData = result.value;
|
|
234
|
-
|
|
235
|
-
// do something with base64PictureData
|
|
236
|
-
```
|
|
237
|
-
|
|
238
|
-
### getSupportedFlashModes()
|
|
239
|
-
|
|
240
|
-
<info>Get the flash modes supported by the camera device currently started. Returns an array containing supported flash modes. See <code>[FLASH_MODE](#camera_Settings.FlashMode)</code> for possible values that can be returned</info><br/>
|
|
241
|
-
|
|
242
|
-
```javascript
|
|
243
|
-
import { CameraPreviewFlashMode } from '@capgo/camera-preview';
|
|
244
|
-
|
|
245
|
-
const flashModes = await CameraPreview.getSupportedFlashModes();
|
|
246
|
-
const supportedFlashModes: CameraPreviewFlashMode[] = flashModes.result;
|
|
247
|
-
```
|
|
248
|
-
|
|
249
|
-
### getHorizontalFov()
|
|
250
|
-
|
|
251
|
-
<info>Get the horizontal FOV of camera the camera device currently started. Returns a float <br/>
|
|
252
|
-
|
|
253
|
-
Please note that camera should be already started to get this value.
|
|
254
|
-
|
|
255
|
-
```javascript
|
|
256
|
-
const cameraFovRequest = await CameraPreview.getHorizontalFov();
|
|
257
|
-
const cameraFovRequest = cameraFovRequest.result;
|
|
258
|
-
```
|
|
259
|
-
|
|
260
|
-
### setFlashMode(options)
|
|
261
|
-
|
|
262
|
-
<info>Set the flash mode. See <code>[FLASH_MODE](#camera_Settings.FlashMode)</code> for details about the possible values for flashMode.</info><br/>
|
|
263
|
-
|
|
264
|
-
```javascript
|
|
265
|
-
const CameraPreviewFlashMode: CameraPreviewFlashMode = 'torch';
|
|
266
|
-
|
|
267
|
-
CameraPreview.setFlashMode(cameraPreviewFlashMode);
|
|
268
|
-
```
|
|
269
|
-
|
|
270
|
-
### startRecordVideo(options)
|
|
271
|
-
|
|
272
|
-
<info>Start capturing video</info><br/>
|
|
273
|
-
|
|
274
|
-
```javascript
|
|
275
|
-
const cameraPreviewOptions: CameraPreviewOptions = {
|
|
276
|
-
position: 'front',
|
|
277
|
-
width: window.screen.width,
|
|
278
|
-
height: window.screen.height,
|
|
279
|
-
};
|
|
280
|
-
|
|
281
|
-
CameraPreview.startRecordVideo(cameraPreviewOptions);
|
|
282
|
-
```
|
|
283
|
-
|
|
284
|
-
### stopRecordVideo()
|
|
285
|
-
|
|
286
|
-
<info>Finish capturing a video. The captured video will be returned as a file path and the video format is .mp4</info><br/>
|
|
287
|
-
|
|
288
|
-
```javascript
|
|
289
|
-
const resultRecordVideo = await CameraPreview.stopRecordVideo();
|
|
290
|
-
this.stopCamera();
|
|
291
|
-
```
|
|
292
|
-
|
|
293
|
-
### setOpacity(options: CameraOpacityOptions): Promise<{}>; ---- ANDROID only
|
|
294
|
-
|
|
295
|
-
<info>Set the opacity for the camera preview</info><br/>
|
|
296
|
-
|
|
297
|
-
```javascript
|
|
298
|
-
const myCamera = CameraPreview.start({ enableOpacity: true });
|
|
299
|
-
myCamera.setOpacity({ opacity: 0.4 });
|
|
300
|
-
```
|
|
301
|
-
|
|
302
|
-
# Settings
|
|
303
|
-
|
|
304
|
-
<a name="camera_Settings.FlashMode"></a>
|
|
305
|
-
|
|
306
|
-
### FLASH_MODE
|
|
307
|
-
|
|
308
|
-
<info>Flash mode settings:</info><br/>
|
|
309
|
-
|
|
310
|
-
| Name | Type | Default | Note |
|
|
311
|
-
| ------- | ------ | ------- | ------------ |
|
|
312
|
-
| OFF | string | off | |
|
|
313
|
-
| ON | string | on | |
|
|
314
|
-
| AUTO | string | auto | |
|
|
315
|
-
| RED_EYE | string | red-eye | Android Only |
|
|
316
|
-
| TORCH | string | torch | |
|
|
317
|
-
|
|
318
|
-
<!--
|
|
319
|
-
|
|
320
|
-
# Settings
|
|
321
|
-
|
|
322
|
-
<a name="camera_Settings.FocusMode"></a>
|
|
323
|
-
|
|
324
|
-
### FOCUS_MODE
|
|
325
|
-
|
|
326
|
-
<info>Focus mode settings:</info><br/>
|
|
327
|
-
|
|
328
|
-
| Name | Type | Default | Note |
|
|
329
|
-
| --- | --- | --- | --- |
|
|
330
|
-
| FIXED | string | fixed | |
|
|
331
|
-
| AUTO | string | auto | |
|
|
332
|
-
| CONTINUOUS | string | continuous | IOS Only |
|
|
333
|
-
| CONTINUOUS_PICTURE | string | continuous-picture | Android Only |
|
|
334
|
-
| CONTINUOUS_VIDEO | string | continuous-video | Android Only |
|
|
335
|
-
| EDOF | string | edof | Android Only |
|
|
336
|
-
| INFINITY | string | infinity | Android Only |
|
|
337
|
-
| MACRO | string | macro | Android Only |
|
|
338
|
-
|
|
339
|
-
<a name="camera_Settings.FlashMode"></a>
|
|
340
|
-
|
|
341
|
-
### FLASH_MODE
|
|
342
|
-
|
|
343
|
-
<info>Flash mode settings:</info><br/>
|
|
344
|
-
|
|
345
|
-
| Name | Type | Default | Note |
|
|
346
|
-
| --- | --- | --- | --- |
|
|
347
|
-
| OFF | string | off | |
|
|
348
|
-
| ON | string | on | |
|
|
349
|
-
| AUTO | string | auto | |
|
|
350
|
-
| RED_EYE | string | red-eye | Android Only |
|
|
351
|
-
| TORCH | string | torch | |
|
|
352
|
-
|
|
353
|
-
<a name="camera_Settings.CameraDirection"></a>
|
|
354
|
-
|
|
355
|
-
### CAMERA_DIRECTION
|
|
356
|
-
|
|
357
|
-
<info>Camera direction settings:</info><br/>
|
|
358
|
-
|
|
359
|
-
| Name | Type | Default |
|
|
360
|
-
| --- | --- | --- |
|
|
361
|
-
| BACK | string | back |
|
|
362
|
-
| FRONT | string | front |
|
|
363
|
-
|
|
364
|
-
<a name="camera_Settings.ColorEffect"></a>
|
|
365
|
-
|
|
366
|
-
### COLOR_EFFECT
|
|
367
|
-
|
|
368
|
-
<info>Color effect settings:</info><br/>
|
|
369
|
-
|
|
370
|
-
| Name | Type | Default | Note |
|
|
371
|
-
| --- | --- | --- | --- |
|
|
372
|
-
| AQUA | string | aqua | Android Only |
|
|
373
|
-
| BLACKBOARD | string | blackboard | Android Only |
|
|
374
|
-
| MONO | string | mono | |
|
|
375
|
-
| NEGATIVE | string | negative | |
|
|
376
|
-
| NONE | string | none | |
|
|
377
|
-
| POSTERIZE | string | posterize | |
|
|
378
|
-
| SEPIA | string | sepia | |
|
|
379
|
-
| SOLARIZE | string | solarize | Android Only |
|
|
380
|
-
| WHITEBOARD | string | whiteboard | Android Only |
|
|
381
|
-
|
|
382
|
-
<a name="camera_Settings.ExposureMode"></a>
|
|
383
|
-
|
|
384
|
-
### EXPOSURE_MODE
|
|
385
|
-
|
|
386
|
-
<info>Exposure mode settings:</info><br/>
|
|
387
|
-
|
|
388
|
-
| Name | Type | Default | Note |
|
|
389
|
-
| --- | --- | --- | --- |
|
|
390
|
-
| AUTO | string | auto | IOS Only |
|
|
391
|
-
| CONTINUOUS | string | continuous | |
|
|
392
|
-
| CUSTOM | string | custom | |
|
|
393
|
-
| LOCK | string | lock | IOS Only |
|
|
394
|
-
|
|
395
|
-
Note: Use AUTO to allow the device automatically adjusts the exposure once and then changes the exposure mode to LOCK.
|
|
396
|
-
|
|
397
|
-
<a name="camera_Settings.WhiteBalanceMode"></a>
|
|
398
|
-
|
|
399
|
-
### WHITE_BALANCE_MODE
|
|
400
|
-
|
|
401
|
-
<info>White balance mode settings:</info><br/>
|
|
402
|
-
|
|
403
|
-
| Name | Type | Default | Note |
|
|
404
|
-
| --- | --- | --- | --- |
|
|
405
|
-
| LOCK | string | lock | |
|
|
406
|
-
| AUTO | string | auto | |
|
|
407
|
-
| CONTINUOUS | string | continuous | IOS Only |
|
|
408
|
-
| INCANDESCENT | string | incandescent | |
|
|
409
|
-
| CLOUDY_DAYLIGHT | string | cloudy-daylight | |
|
|
410
|
-
| DAYLIGHT | string | daylight | |
|
|
411
|
-
| FLUORESCENT | string | fluorescent | |
|
|
412
|
-
| SHADE | string | shade | |
|
|
413
|
-
| TWILIGHT | string | twilight | |
|
|
414
|
-
| WARM_FLUORESCENT | string | warm-fluorescent | |
|
|
415
|
-
|
|
416
|
-
# IOS Quirks
|
|
417
|
-
It is not possible to use your computers webcam during testing in the simulator, you must device test.
|
|
418
|
-
|
|
419
|
-
# Customize Android Support Library versions (Android only)
|
|
420
|
-
The default `ANDROID_SUPPORT_LIBRARY_VERSION` is set to `26+`.
|
|
421
|
-
If you need a different version, add argument `--variable ANDROID_SUPPORT_LIBRARY_VERSION="{version}"`.
|
|
422
|
-
|
|
423
|
-
Or edit `config.xml` with following,
|
|
424
|
-
|
|
425
|
-
```xml
|
|
426
|
-
<plugin name="cordova-plugin-camera-preview" spec="X.X.X">
|
|
427
|
-
<variable name="ANDROID_SUPPORT_LIBRARY_VERSION" value="26+" />
|
|
428
|
-
</plugin>
|
|
429
|
-
```
|
|
430
|
-
|
|
431
|
-
# Sample App
|
|
432
|
-
|
|
433
|
-
<a href="https://github.com/cordova-plugin-camera-preview/cordova-plugin-camera-preview-sample-app">cordova-plugin-camera-preview-sample-app</a> for a complete working Cordova example for Android and iOS platforms.
|
|
434
|
-
|
|
435
|
-
# Screenshots
|
|
436
|
-
|
|
437
|
-
<img src="https://raw.githubusercontent.com/cordova-plugin-camera-preview/cordova-plugin-camera-preview/master/img/android-1.png"/> <img hspace="20" src="https://raw.githubusercontent.com/cordova-plugin-camera-preview/cordova-plugin-camera-preview/master/img/android-2.png"/>
|
|
438
|
-
|
|
439
|
-
# Credits
|
|
440
|
-
|
|
441
|
-
Maintained by [Weston Ganger](https://westonganger.com) - [@westonganger](https://github.com/westonganger)
|
|
442
|
-
|
|
443
|
-
Created by Marcel Barbosa Pinto [@mbppower](https://github.com/mbppower)
|
|
444
|
-
 -->
|
|
445
|
-
|
|
446
|
-
# Demo
|
|
447
|
-
|
|
448
|
-
A working example can be found at [Demo](https://github.com/capacitor-community/camera-preview/tree/master/demo)
|
|
449
|
-
|
|
450
|
-
To run the demo on your local network and access media devices, a secure context is needed. Add an `.env` file at the root of the demo folder with `HTTPS=true` to start react with HTTPS.
|
|
451
|
-
|
|
452
|
-
## API
|
|
70
|
+
### API
|
|
453
71
|
|
|
454
72
|
<docgen-index>
|
|
455
73
|
|
|
@@ -478,12 +96,16 @@ To run the demo on your local network and access media devices, a secure context
|
|
|
478
96
|
start(options: CameraPreviewOptions) => any
|
|
479
97
|
```
|
|
480
98
|
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
|
99
|
+
Start the camera preview instance.
|
|
100
|
+
|
|
101
|
+
| Param | Type | Description |
|
|
102
|
+
| ------------- | --------------------------------------------------------------------- | -------------------------------------------- |
|
|
103
|
+
| **`options`** | <code><a href="#camerapreviewoptions">CameraPreviewOptions</a></code> | the options to start the camera preview with |
|
|
484
104
|
|
|
485
105
|
**Returns:** <code>any</code>
|
|
486
106
|
|
|
107
|
+
**Since:** 0.0.1
|
|
108
|
+
|
|
487
109
|
--------------------
|
|
488
110
|
|
|
489
111
|
|
|
@@ -493,8 +115,12 @@ start(options: CameraPreviewOptions) => any
|
|
|
493
115
|
stop() => any
|
|
494
116
|
```
|
|
495
117
|
|
|
118
|
+
Stop the camera preview instance.
|
|
119
|
+
|
|
496
120
|
**Returns:** <code>any</code>
|
|
497
121
|
|
|
122
|
+
**Since:** 0.0.1
|
|
123
|
+
|
|
498
124
|
--------------------
|
|
499
125
|
|
|
500
126
|
|
|
@@ -504,12 +130,16 @@ stop() => any
|
|
|
504
130
|
capture(options: CameraPreviewPictureOptions) => any
|
|
505
131
|
```
|
|
506
132
|
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
|
133
|
+
Switch camera.
|
|
134
|
+
|
|
135
|
+
| Param | Type | Description |
|
|
136
|
+
| ------------- | ----------------------------------------------------------------------------------- | ------------------------------------- |
|
|
137
|
+
| **`options`** | <code><a href="#camerapreviewpictureoptions">CameraPreviewPictureOptions</a></code> | the options to switch the camera with |
|
|
510
138
|
|
|
511
139
|
**Returns:** <code>any</code>
|
|
512
140
|
|
|
141
|
+
**Since:** 0.0.1
|
|
142
|
+
|
|
513
143
|
--------------------
|
|
514
144
|
|
|
515
145
|
|
|
@@ -519,12 +149,16 @@ capture(options: CameraPreviewPictureOptions) => any
|
|
|
519
149
|
captureSample(options: CameraSampleOptions) => any
|
|
520
150
|
```
|
|
521
151
|
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
|
152
|
+
Capture a sample image.
|
|
153
|
+
|
|
154
|
+
| Param | Type | Description |
|
|
155
|
+
| ------------- | ------------------------------------------------------------------- | -------------------------------------------- |
|
|
156
|
+
| **`options`** | <code><a href="#camerasampleoptions">CameraSampleOptions</a></code> | the options to capture the sample image with |
|
|
525
157
|
|
|
526
158
|
**Returns:** <code>any</code>
|
|
527
159
|
|
|
160
|
+
**Since:** 0.0.1
|
|
161
|
+
|
|
528
162
|
--------------------
|
|
529
163
|
|
|
530
164
|
|
|
@@ -534,8 +168,12 @@ captureSample(options: CameraSampleOptions) => any
|
|
|
534
168
|
getSupportedFlashModes() => any
|
|
535
169
|
```
|
|
536
170
|
|
|
171
|
+
Get supported flash modes.
|
|
172
|
+
|
|
537
173
|
**Returns:** <code>any</code>
|
|
538
174
|
|
|
175
|
+
**Since:** 0.0.1
|
|
176
|
+
|
|
539
177
|
--------------------
|
|
540
178
|
|
|
541
179
|
|
|
@@ -545,8 +183,12 @@ getSupportedFlashModes() => any
|
|
|
545
183
|
getHorizontalFov() => any
|
|
546
184
|
```
|
|
547
185
|
|
|
186
|
+
Get horizontal field of view.
|
|
187
|
+
|
|
548
188
|
**Returns:** <code>any</code>
|
|
549
189
|
|
|
190
|
+
**Since:** 0.0.1
|
|
191
|
+
|
|
550
192
|
--------------------
|
|
551
193
|
|
|
552
194
|
|
|
@@ -556,12 +198,16 @@ getHorizontalFov() => any
|
|
|
556
198
|
setFlashMode(options: { flashMode: CameraPreviewFlashMode | string; }) => any
|
|
557
199
|
```
|
|
558
200
|
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
|
201
|
+
Set flash mode.
|
|
202
|
+
|
|
203
|
+
| Param | Type | Description |
|
|
204
|
+
| ------------- | ----------------------------------- | -------------------------------------- |
|
|
205
|
+
| **`options`** | <code>{ flashMode: string; }</code> | the options to set the flash mode with |
|
|
562
206
|
|
|
563
207
|
**Returns:** <code>any</code>
|
|
564
208
|
|
|
209
|
+
**Since:** 0.0.1
|
|
210
|
+
|
|
565
211
|
--------------------
|
|
566
212
|
|
|
567
213
|
|
|
@@ -571,8 +217,12 @@ setFlashMode(options: { flashMode: CameraPreviewFlashMode | string; }) => any
|
|
|
571
217
|
flip() => any
|
|
572
218
|
```
|
|
573
219
|
|
|
220
|
+
Flip camera.
|
|
221
|
+
|
|
574
222
|
**Returns:** <code>any</code>
|
|
575
223
|
|
|
224
|
+
**Since:** 0.0.1
|
|
225
|
+
|
|
576
226
|
--------------------
|
|
577
227
|
|
|
578
228
|
|
|
@@ -582,12 +232,16 @@ flip() => any
|
|
|
582
232
|
setOpacity(options: CameraOpacityOptions) => any
|
|
583
233
|
```
|
|
584
234
|
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
|
235
|
+
Set opacity.
|
|
236
|
+
|
|
237
|
+
| Param | Type | Description |
|
|
238
|
+
| ------------- | --------------------------------------------------------------------- | ------------------------------------------ |
|
|
239
|
+
| **`options`** | <code><a href="#cameraopacityoptions">CameraOpacityOptions</a></code> | the options to set the camera opacity with |
|
|
588
240
|
|
|
589
241
|
**Returns:** <code>any</code>
|
|
590
242
|
|
|
243
|
+
**Since:** 0.0.1
|
|
244
|
+
|
|
591
245
|
--------------------
|
|
592
246
|
|
|
593
247
|
|
|
@@ -597,8 +251,12 @@ setOpacity(options: CameraOpacityOptions) => any
|
|
|
597
251
|
stopRecordVideo() => any
|
|
598
252
|
```
|
|
599
253
|
|
|
254
|
+
Stop recording video.
|
|
255
|
+
|
|
600
256
|
**Returns:** <code>any</code>
|
|
601
257
|
|
|
258
|
+
**Since:** 0.0.1
|
|
259
|
+
|
|
602
260
|
--------------------
|
|
603
261
|
|
|
604
262
|
|
|
@@ -608,12 +266,16 @@ stopRecordVideo() => any
|
|
|
608
266
|
startRecordVideo(options: CameraPreviewOptions) => any
|
|
609
267
|
```
|
|
610
268
|
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
|
269
|
+
Start recording video.
|
|
270
|
+
|
|
271
|
+
| Param | Type | Description |
|
|
272
|
+
| ------------- | --------------------------------------------------------------------- | ----------------------------------------- |
|
|
273
|
+
| **`options`** | <code><a href="#camerapreviewoptions">CameraPreviewOptions</a></code> | the options to start recording video with |
|
|
614
274
|
|
|
615
275
|
**Returns:** <code>any</code>
|
|
616
276
|
|
|
277
|
+
**Since:** 0.0.1
|
|
278
|
+
|
|
617
279
|
--------------------
|
|
618
280
|
|
|
619
281
|
|
|
@@ -672,16 +334,16 @@ startRecordVideo(options: CameraPreviewOptions) => any
|
|
|
672
334
|
|
|
673
335
|
#### CameraPosition
|
|
674
336
|
|
|
675
|
-
<code>
|
|
337
|
+
<code>"rear" | "front"</code>
|
|
676
338
|
|
|
677
339
|
|
|
678
340
|
#### PictureFormat
|
|
679
341
|
|
|
680
|
-
<code>
|
|
342
|
+
<code>"jpeg" | "png"</code>
|
|
681
343
|
|
|
682
344
|
|
|
683
345
|
#### CameraPreviewFlashMode
|
|
684
346
|
|
|
685
|
-
<code>
|
|
347
|
+
<code>"off" | "on" | "auto" | "red-eye" | "torch"</code>
|
|
686
348
|
|
|
687
|
-
</docgen-api>
|
|
349
|
+
</docgen-api>
|
package/android/build.gradle
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
ext {
|
|
2
2
|
junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
|
|
3
|
-
androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.
|
|
4
|
-
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.
|
|
5
|
-
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.
|
|
3
|
+
androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.6.1'
|
|
4
|
+
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.5'
|
|
5
|
+
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.5.1'
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
buildscript {
|
|
@@ -11,17 +11,18 @@ buildscript {
|
|
|
11
11
|
google()
|
|
12
12
|
}
|
|
13
13
|
dependencies {
|
|
14
|
-
classpath 'com.android.tools.build:gradle:
|
|
14
|
+
classpath 'com.android.tools.build:gradle:8.0.0'
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
apply plugin: 'com.android.library'
|
|
19
19
|
|
|
20
20
|
android {
|
|
21
|
-
|
|
21
|
+
namespace "com.ahm.capacitor.camera.preview.capacitorcamerapreview"
|
|
22
|
+
compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 33
|
|
22
23
|
defaultConfig {
|
|
23
24
|
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 22
|
|
24
|
-
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion :
|
|
25
|
+
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 33
|
|
25
26
|
versionCode 1
|
|
26
27
|
versionName "1.0"
|
|
27
28
|
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
|
@@ -47,7 +48,7 @@ dependencies {
|
|
|
47
48
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
|
48
49
|
implementation project(':capacitor-android')
|
|
49
50
|
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
|
|
50
|
-
implementation 'androidx.exifinterface:exifinterface:1.3.
|
|
51
|
+
implementation 'androidx.exifinterface:exifinterface:1.3.6'
|
|
51
52
|
testImplementation "junit:junit:$junitVersion"
|
|
52
53
|
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
|
|
53
54
|
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
|
|
Binary file
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
distributionBase=GRADLE_USER_HOME
|
|
2
2
|
distributionPath=wrapper/dists
|
|
3
|
-
distributionUrl=https\://services.gradle.org/distributions/gradle-
|
|
3
|
+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-all.zip
|
|
4
4
|
networkTimeout=10000
|
|
5
5
|
zipStoreBase=GRADLE_USER_HOME
|
|
6
6
|
zipStorePath=wrapper/dists
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
# The setting is particularly useful for tweaking memory settings.
|
|
12
12
|
org.gradle.jvmargs=-Xmx1536m
|
|
13
13
|
android.useAndroidX=true
|
|
14
|
-
android.enableJetifier=true
|
|
15
14
|
# When configured, Gradle will run in incubating parallel mode.
|
|
16
15
|
# This option should only be used with decoupled projects. More details, visit
|
|
17
16
|
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
|
18
17
|
# org.gradle.parallel=true
|
|
18
|
+
|
package/android/gradlew
CHANGED
|
@@ -144,7 +144,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
|
|
144
144
|
case $MAX_FD in #(
|
|
145
145
|
max*)
|
|
146
146
|
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
|
147
|
-
# shellcheck disable=SC3045
|
|
147
|
+
# shellcheck disable=SC3045
|
|
148
148
|
MAX_FD=$( ulimit -H -n ) ||
|
|
149
149
|
warn "Could not query maximum file descriptor limit"
|
|
150
150
|
esac
|
|
@@ -152,7 +152,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
|
|
152
152
|
'' | soft) :;; #(
|
|
153
153
|
*)
|
|
154
154
|
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
|
155
|
-
# shellcheck disable=SC3045
|
|
155
|
+
# shellcheck disable=SC3045
|
|
156
156
|
ulimit -n "$MAX_FD" ||
|
|
157
157
|
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
|
158
158
|
esac
|