Showing
1 changed file
with
21 additions
and
11 deletions
| @@ -213,18 +213,28 @@ public class MobileScanner: NSObject, AVCaptureVideoDataOutputSampleBufferDelega | @@ -213,18 +213,28 @@ public class MobileScanner: NSObject, AVCaptureVideoDataOutputSampleBufferDelega | ||
| 213 | } catch { | 213 | } catch { |
| 214 | print("Failed to reset zoom scale") | 214 | print("Failed to reset zoom scale") |
| 215 | } | 215 | } |
| 216 | - | ||
| 217 | - let dimensions = CMVideoFormatDescriptionGetDimensions(self.device.activeFormat.formatDescription) | ||
| 218 | - | ||
| 219 | - DispatchQueue.main.async { | ||
| 220 | - completion( | ||
| 221 | - MobileScannerStartParameters( | ||
| 222 | - width: Double(dimensions.height), | ||
| 223 | - height: Double(dimensions.width), | ||
| 224 | - hasTorch: self.device.hasTorch, | ||
| 225 | - textureId: self.textureId | 216 | + |
| 217 | + if let device = self.device { | ||
| 218 | + let dimensions = CMVideoFormatDescriptionGetDimensions( | ||
| 219 | + device.activeFormat.formatDescription) | ||
| 220 | + let hasTorch = device.hasTorch | ||
| 221 | + | ||
| 222 | + DispatchQueue.main.async { | ||
| 223 | + completion( | ||
| 224 | + MobileScannerStartParameters( | ||
| 225 | + width: Double(dimensions.height), | ||
| 226 | + height: Double(dimensions.width), | ||
| 227 | + hasTorch: hasTorch, | ||
| 228 | + textureId: self.textureId ?? 0 | ||
| 229 | + ) | ||
| 226 | ) | 230 | ) |
| 227 | - ) | 231 | + } |
| 232 | + | ||
| 233 | + return | ||
| 234 | + } | ||
| 235 | + | ||
| 236 | + DispatchQueue.main.async { | ||
| 237 | + completion(MobileScannerStartParameters()) | ||
| 228 | } | 238 | } |
| 229 | } | 239 | } |
| 230 | } | 240 | } |
-
Please register or login to post a comment