Skip to content

Commit 2bb264f

Browse files
authored
feat: default to ultra wide camera if available (#28)
1 parent 44d768b commit 2bb264f

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

ios/ScannerViewController.m

+16
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,22 @@ - (void)toggleTorch
9595
- (void)initCapture
9696
{
9797
self.device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
98+
99+
if (@available(iOS 13.0, *)) {
100+
AVCaptureDeviceDiscoverySession *captureDeviceDiscoverySession = [AVCaptureDeviceDiscoverySession discoverySessionWithDeviceTypes:@[AVCaptureDeviceTypeBuiltInUltraWideCamera]
101+
mediaType:AVMediaTypeVideo
102+
position:AVCaptureDevicePositionBack];
103+
104+
NSArray *captureDevices = [captureDeviceDiscoverySession devices];
105+
106+
if (captureDevices.count > 0) {
107+
NSLog(@"Supports ultrawide camera");
108+
109+
self.device = captureDevices[0];
110+
}
111+
}
112+
113+
98114
AVCaptureDeviceInput *captureInput = [AVCaptureDeviceInput deviceInputWithDevice:self.device error:nil];
99115
AVCaptureVideoDataOutput *captureOutput = [[AVCaptureVideoDataOutput alloc] init];
100116
captureOutput.alwaysDiscardsLateVideoFrames = YES;

0 commit comments

Comments
 (0)