Support the dual-wide camera on recent non-Pro phones

This commit is contained in:
Sami Samhuri 2023-10-26 15:13:38 -07:00
parent 69f86a9c0a
commit 5b50330d72

View file

@ -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)
}