capacitor-camera-view 1.2.1 → 1.2.2
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
CHANGED
|
@@ -150,6 +150,9 @@ This plugin supports real-time barcode detection directly from the live camera f
|
|
|
150
150
|
* **Android:** Utilizes Google's [**ML Kit Barcode Scanning**](https://developers.google.com/ml-kit/vision/barcode-scanning).
|
|
151
151
|
* **Web:** Uses the [**Barcode Detection API**](https://developer.mozilla.org/en-US/docs/Web/API/Barcode_Detection_API) where available in the browser.
|
|
152
152
|
|
|
153
|
+
> [!NOTE]
|
|
154
|
+
> **Web Support:** The Barcode Detection API is not supported in all browsers (e.g., Windows browsers). For full browser compatibility, consider using a polyfill such as [`@undecaf/barcode-detector-polyfill`](https://www.npmjs.com/package/@undecaf/barcode-detector-polyfill) or [`barcode-detector`](https://www.npmjs.com/package/barcode-detector).
|
|
155
|
+
|
|
153
156
|
**Enabling Barcode Detection:**
|
|
154
157
|
To enable this feature, set the `enableBarcodeDetection` option to `true` when calling the `start()` method:
|
|
155
158
|
|
|
@@ -90,10 +90,20 @@ internal let SUPPORTED_CAMERA_DEVICE_TYPES: [AVCaptureDevice.DeviceType] = [
|
|
|
90
90
|
completion: { error in
|
|
91
91
|
if error != nil { completion(error) }
|
|
92
92
|
|
|
93
|
+
// Handle barcode detection after session is running
|
|
94
|
+
if configuration.enableBarcodeDetection {
|
|
95
|
+
do {
|
|
96
|
+
try self.enableBarcodeDetection()
|
|
97
|
+
} catch {
|
|
98
|
+
completion(error)
|
|
99
|
+
return
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
93
103
|
// Complete already because the camera is ready to be used
|
|
94
|
-
// We might asynchronously upgrade to a triple camera in the background if available and configured
|
|
95
104
|
completion(nil)
|
|
96
105
|
|
|
106
|
+
// We might asynchronously upgrade to a triple camera in the background if available and configured
|
|
97
107
|
if configuration.useTripleCameraIfAvailable {
|
|
98
108
|
Task {
|
|
99
109
|
await self.upgradeToTripleCameraIfAvailable()
|
|
@@ -359,10 +369,7 @@ internal let SUPPORTED_CAMERA_DEVICE_TYPES: [AVCaptureDevice.DeviceType] = [
|
|
|
359
369
|
// Set up the video data output for snapshots
|
|
360
370
|
try setupVideoDataOutput()
|
|
361
371
|
|
|
362
|
-
|
|
363
|
-
if configuration.enableBarcodeDetection {
|
|
364
|
-
try setupMetadataOutput()
|
|
365
|
-
} else {
|
|
372
|
+
if !configuration.enableBarcodeDetection {
|
|
366
373
|
// Remove the metadata output in case it already existed for the
|
|
367
374
|
// capture session
|
|
368
375
|
removeMetadataOutput()
|
|
@@ -405,6 +412,26 @@ internal let SUPPORTED_CAMERA_DEVICE_TYPES: [AVCaptureDevice.DeviceType] = [
|
|
|
405
412
|
}
|
|
406
413
|
}
|
|
407
414
|
|
|
415
|
+
|
|
416
|
+
/// Enables barcode detection by adding metadata output to the running session.
|
|
417
|
+
/// Somehow adding the metadata output with the session not being started yet
|
|
418
|
+
/// caused issues on some devices (iPad 7th Gen) where the session would just
|
|
419
|
+
/// not start at all without an error being thrown. I haven't been able to
|
|
420
|
+
/// figure out the root cause of this but it might generally be a good idea
|
|
421
|
+
/// to only add the metadata output when the session is already running.
|
|
422
|
+
///
|
|
423
|
+
/// - Throws: An error if the metadata output cannot be added.
|
|
424
|
+
private func enableBarcodeDetection() throws {
|
|
425
|
+
guard captureSession.isRunning else {
|
|
426
|
+
throw CameraError.sessionNotRunning
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
captureSession.beginConfiguration()
|
|
430
|
+
defer { captureSession.commitConfiguration() }
|
|
431
|
+
|
|
432
|
+
try setupMetadataOutput()
|
|
433
|
+
}
|
|
434
|
+
|
|
408
435
|
/// Retrieve a list of a available camera devices
|
|
409
436
|
///
|
|
410
437
|
/// - Returns: a list of all available camera devices.
|
package/package.json
CHANGED