@scr2em/capacitor-scanner 6.0.10 → 6.0.11
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.
|
@@ -52,8 +52,8 @@ public class CapacitorScannerPlugin: CAPPlugin, CAPBridgedPlugin, AVCaptureMetad
|
|
|
52
52
|
|
|
53
53
|
@objc func capturePhoto(_ call: CAPPluginCall) {
|
|
54
54
|
guard let photoOutput = self.photoOutput, captureSession?.isRunning == true else {
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
call.reject("Camera is not set up or running")
|
|
56
|
+
return
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
// Get quality ratio from options, default to 1.0, clamp between 0.0 and 1.0
|
|
@@ -67,18 +67,21 @@ public class CapacitorScannerPlugin: CAPPlugin, CAPBridgedPlugin, AVCaptureMetad
|
|
|
67
67
|
if photoOutput.supportedPhotoCodecTypes(for: .jpg).contains(.jpeg) {
|
|
68
68
|
// Create settings specific for JPEG with quality
|
|
69
69
|
photoSettings = AVCapturePhotoSettings(format: [AVVideoCodecKey: AVVideoCodecType.jpeg,
|
|
70
|
-
|
|
70
|
+
AVVideoCompressionPropertiesKey: [AVVideoQualityKey: qualityNumber]])
|
|
71
71
|
|
|
72
|
-
// Set photo quality prioritization based on the device's capabilities
|
|
73
|
-
// This ensures we never set a prioritization higher than what's supported
|
|
74
72
|
let maxPrioritization = photoOutput.maxPhotoQualityPrioritization
|
|
75
|
-
//
|
|
76
|
-
|
|
77
|
-
|
|
73
|
+
// Compare the raw values to determine which prioritization to use
|
|
74
|
+
if maxPrioritization.rawValue >= AVCapturePhotoOutput.QualityPrioritization.balanced.rawValue {
|
|
75
|
+
// Device supports .balanced prioritization
|
|
76
|
+
photoSettings.photoQualityPrioritization = .balanced
|
|
77
|
+
} else {
|
|
78
|
+
// Use the lowest prioritization (.speed)
|
|
79
|
+
photoSettings.photoQualityPrioritization = .speed
|
|
80
|
+
}
|
|
78
81
|
|
|
79
82
|
} else {
|
|
80
|
-
|
|
81
|
-
|
|
83
|
+
print("JPEG codec not supported for photo capture. Using default settings.")
|
|
84
|
+
// photoSettings remains the default initialized one
|
|
82
85
|
}
|
|
83
86
|
|
|
84
87
|
self.capturePhotoCall = call
|