From 5b50330d72dbe0d52fb39e65673421036302bcf9 Mon Sep 17 00:00:00 2001 From: Sami Samhuri Date: Thu, 26 Oct 2023 15:13:38 -0700 Subject: [PATCH] Support the dual-wide camera on recent non-Pro phones --- Source/SwiftyCamViewController.swift | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Source/SwiftyCamViewController.swift b/Source/SwiftyCamViewController.swift index 04c8dad..0d5416e 100644 --- a/Source/SwiftyCamViewController.swift +++ b/Source/SwiftyCamViewController.swift @@ -663,11 +663,13 @@ open class SwiftyCamViewController: UIViewController { videoDevice.automaticallyEnablesLowLightBoostWhenAvailable = true } - // Start out using the wide camera focal length when we have a triple cam. This - // must be done after adding the video device input to the session. + // Start out using the wide camera focal length when we have a triple or dual-wide cam. + // This must be done after adding the video device input to the session. let zoomBoundaries = videoDevice.virtualDeviceSwitchOverVideoZoomFactors if videoDevice.deviceType == .builtInTripleCamera, let zoom = zoomBoundaries.first?.doubleValue { videoDevice.videoZoomFactor = zoom + } else if videoDevice.deviceType == .builtInDualWideCamera, let zoom = zoomBoundaries.first?.doubleValue { + videoDevice.videoZoomFactor = zoom } videoDevice.unlockForConfiguration() @@ -764,6 +766,7 @@ open class SwiftyCamViewController: UIViewController { fileprivate class func defaultCaptureDevice(preferringPosition position: AVCaptureDevice.Position) -> AVCaptureDevice? { AVCaptureDevice.default(.builtInTripleCamera, for: .video, position: position) ?? AVCaptureDevice.default(.builtInDualCamera, for: .video, position: position) + ?? AVCaptureDevice.default(.builtInDualWideCamera, for: .video, position: position) ?? AVCaptureDevice.default(.builtInWideAngleCamera, for: .video, position: position) }