capacitor-camera-module 0.0.67 → 0.0.68
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.
|
@@ -246,32 +246,49 @@ public class CameraModulePlugin: CAPPlugin,CAPBridgedPlugin,AVCaptureVideoDataOu
|
|
|
246
246
|
|
|
247
247
|
@objc func stopPreview(_ call: CAPPluginCall) {
|
|
248
248
|
DispatchQueue.main.async {
|
|
249
|
-
|
|
249
|
+
|
|
250
|
+
if self.isScanning {
|
|
251
|
+
self.isScanning = false
|
|
252
|
+
self.scanCall?.keepAlive = false
|
|
253
|
+
self.scanCall = nil
|
|
254
|
+
self.barcodeRequest = nil
|
|
255
|
+
self.lastScannedValue = nil
|
|
256
|
+
self.lastScanTime = nil
|
|
257
|
+
|
|
258
|
+
if let output = self.videoDataOutput,
|
|
259
|
+
let session = self.captureSession {
|
|
260
|
+
session.removeOutput(output)
|
|
261
|
+
}
|
|
262
|
+
self.videoDataOutput = nil
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// 🛑 Detener cámara
|
|
250
266
|
self.captureSession?.stopRunning()
|
|
251
267
|
self.captureSession = nil
|
|
252
268
|
|
|
253
|
-
//
|
|
269
|
+
// 🧹 Limpiar preview
|
|
254
270
|
self.videoPreviewLayer?.removeFromSuperlayer()
|
|
255
271
|
self.previewView?.removeFromSuperview()
|
|
256
272
|
self.videoPreviewLayer?.session = nil
|
|
257
273
|
self.videoPreviewLayer = nil
|
|
258
274
|
self.previewView = nil
|
|
259
275
|
|
|
260
|
-
// Restaurar
|
|
276
|
+
// 🔁 Restaurar WebView
|
|
261
277
|
if let webView = self.bridge?.webView as? WKWebView {
|
|
262
278
|
webView.isOpaque = true
|
|
263
|
-
webView.backgroundColor = .white
|
|
279
|
+
webView.backgroundColor = .white
|
|
264
280
|
webView.scrollView.backgroundColor = .white
|
|
265
281
|
webView.scrollView.isOpaque = true
|
|
266
282
|
}
|
|
267
283
|
|
|
268
|
-
print("
|
|
284
|
+
print("Preview y escaneo detenidos correctamente")
|
|
269
285
|
call.resolve()
|
|
270
286
|
}
|
|
271
287
|
}
|
|
272
288
|
|
|
273
289
|
|
|
274
290
|
|
|
291
|
+
|
|
275
292
|
// MARK: - Flash
|
|
276
293
|
|
|
277
294
|
@objc func toggleFlash(_ call: CAPPluginCall) {
|
|
@@ -398,12 +415,19 @@ public class CameraModulePlugin: CAPPlugin,CAPBridgedPlugin,AVCaptureVideoDataOu
|
|
|
398
415
|
self.lastScanTime = now
|
|
399
416
|
self.isScanning = false
|
|
400
417
|
|
|
418
|
+
if let output = self.videoDataOutput,
|
|
419
|
+
let session = self.captureSession {
|
|
420
|
+
session.removeOutput(output)
|
|
421
|
+
}
|
|
422
|
+
self.videoDataOutput = nil
|
|
423
|
+
|
|
401
424
|
self.scanCall?.resolve([
|
|
402
425
|
"rawValue": value,
|
|
403
426
|
"format": barcode.symbology.rawValue
|
|
404
427
|
])
|
|
405
428
|
self.scanCall?.keepAlive = false
|
|
406
429
|
self.scanCall = nil
|
|
430
|
+
|
|
407
431
|
}
|
|
408
432
|
|
|
409
433
|
if videoDataOutput == nil {
|
|
@@ -438,20 +462,22 @@ public class CameraModulePlugin: CAPPlugin,CAPBridgedPlugin,AVCaptureVideoDataOu
|
|
|
438
462
|
public func captureOutput(_ output: AVCaptureOutput,
|
|
439
463
|
didOutput sampleBuffer: CMSampleBuffer,
|
|
440
464
|
from connection: AVCaptureConnection) {
|
|
465
|
+
|
|
441
466
|
guard isScanning,
|
|
467
|
+
captureSession?.isRunning == true,
|
|
442
468
|
let request = barcodeRequest,
|
|
443
|
-
let pixelBuffer = CMSampleBufferGetImageBuffer(sampleBuffer)
|
|
469
|
+
let pixelBuffer = CMSampleBufferGetImageBuffer(sampleBuffer)
|
|
470
|
+
else { return }
|
|
444
471
|
|
|
445
472
|
let handler = VNImageRequestHandler(
|
|
446
473
|
cvPixelBuffer: pixelBuffer,
|
|
447
|
-
orientation:
|
|
448
|
-
,
|
|
474
|
+
orientation: .right,
|
|
449
475
|
options: [:]
|
|
450
476
|
)
|
|
451
477
|
|
|
452
478
|
try? handler.perform([request])
|
|
453
479
|
}
|
|
454
|
-
|
|
480
|
+
|
|
455
481
|
|
|
456
482
|
// MARK: - UIImagePicker Delegate
|
|
457
483
|
|