Skip to content

Commit

Permalink
fix(ios): check focus / exposure mode support
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelwolz committed Jun 26, 2024
1 parent f2d96d6 commit 9bd7af3
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions ios/Plugin/CameraController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,15 @@ class CameraController: NSObject {
do {
try self.currentCamera?.lockForConfiguration()
self.currentCamera?.videoZoomFactor = self.zoomFactor
self.currentCamera?.exposureMode = .continuousAutoExposure
self.currentCamera?.focusMode = .continuousAutoFocus

if (self.currentCamera?.isFocusModeSupported(.continuousAutoFocus) ?? false) {
self.currentCamera?.focusMode = .continuousAutoFocus
}

if (self.currentCamera?.isExposureModeSupported(.continuousAutoExposure) ?? false) {
self.currentCamera?.exposureMode = .continuousAutoExposure
}

self.currentCamera?.unlockForConfiguration()
completionHandler(nil)

Expand All @@ -116,6 +123,8 @@ class CameraController: NSObject {
*/
private func initializeCameraDevices(forPosition cameraPosition: CameraPosition) throws {
if let rearCamera = AVCaptureDevice.default(.builtInTripleCamera, for: .video, position: .back) {
// Note that zoomFactor 2 "equals" the regular 1x zoom factor of the native iphone camera app
// 0.5x is videoZoomFactor 1. We do not want to use ultra wide angle by default so we set it to 2
self.zoomFactor = 2
self.rearCamera = rearCamera
} else {
Expand Down

0 comments on commit 9bd7af3

Please sign in to comment.