@scr2em/capacitor-scanner 6.0.5 → 6.0.6
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.
|
@@ -79,19 +79,22 @@ public class CapacitorScannerPlugin: CAPPlugin, CAPBridgedPlugin, AVCaptureMetad
|
|
|
79
79
|
|
|
80
80
|
DispatchQueue.main.async {
|
|
81
81
|
let captureSession = AVCaptureSession()
|
|
82
|
-
|
|
83
|
-
if captureSession.canSetSessionPreset(.hd1920x1080) {
|
|
84
|
-
captureSession.sessionPreset = .hd1920x1080
|
|
85
|
-
} else {
|
|
86
|
-
captureSession.sessionPreset = .hd1280x720
|
|
87
|
-
}
|
|
88
|
-
|
|
89
82
|
let cameraDirection: AVCaptureDevice.Position = call.getString("cameraDirection", "BACK") == "BACK" ? .back : .front
|
|
90
|
-
|
|
91
83
|
guard let videoCaptureDevice = self.getCaptureDevice(position: cameraDirection) else {
|
|
92
84
|
print("No camera available")
|
|
93
85
|
return
|
|
94
86
|
}
|
|
87
|
+
|
|
88
|
+
// Check if the selected camera supports the desired preset
|
|
89
|
+
let desiredPreset = AVCaptureSession.Preset.hd1920x1080
|
|
90
|
+
if videoCaptureDevice.supportsSessionPreset(desiredPreset) && captureSession.canSetSessionPreset(desiredPreset) {
|
|
91
|
+
captureSession.sessionPreset = desiredPreset
|
|
92
|
+
} else if captureSession.canSetSessionPreset(.hd1280x720) {
|
|
93
|
+
captureSession.sessionPreset = .hd1280x720
|
|
94
|
+
} else {
|
|
95
|
+
captureSession.sessionPreset = .medium // Fallback to a lower resolution
|
|
96
|
+
}
|
|
97
|
+
|
|
95
98
|
guard let videoInput = try? AVCaptureDeviceInput(device: videoCaptureDevice) else {
|
|
96
99
|
print("Could not create video input")
|
|
97
100
|
return
|