Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions Sources/CameraManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ public enum CameraOutputMode {
case stillImage, videoWithMic, videoOnly
}

public enum CameraPreviewMode {
case resizeAspect, resizeAspectFill
}

public enum CaptureResult {
case success(content: CaptureContent)
case failure(Error)
Expand Down Expand Up @@ -296,6 +300,8 @@ open class CameraManager: NSObject, AVCaptureFileOutputRecordingDelegate, UIGest
}
}
}

open var cameraPreviewMode: CameraPreviewMode = .resizeAspectFill

/// Property to check video recording duration when in progress.
open var recordedDuration: CMTime { return movieOutput?.recordedDuration ?? CMTime.zero }
Expand Down Expand Up @@ -1465,7 +1471,7 @@ open class CameraManager: NSObject, AVCaptureFileOutputRecordingDelegate, UIGest
self._updateCameraDevice(self.cameraDevice)
self._setupOutputs()
self._setupOutputMode(self.cameraOutputMode, oldCameraOutputMode: nil)
self._setupPreviewLayer()
self._setupPreviewLayer(self.cameraPreviewMode)
validCaptureSession.commitConfiguration()
self._updateIlluminationMode(self.flashMode)
self._updateCameraQualityMode(self.cameraOutputQuality)
Expand Down Expand Up @@ -1630,10 +1636,10 @@ open class CameraManager: NSObject, AVCaptureFileOutputRecordingDelegate, UIGest
}
}

fileprivate func _setupPreviewLayer() {
fileprivate func _setupPreviewLayer(_ layerVideoGravity: CameraPreviewMode) {
if let validCaptureSession = captureSession {
previewLayer = AVCaptureVideoPreviewLayer(session: validCaptureSession)
previewLayer?.videoGravity = AVLayerVideoGravity.resizeAspectFill
previewLayer?.videoGravity = layerVideoGravity == .resizeAspect ? AVLayerVideoGravity.resizeAspect : AVLayerVideoGravity.resizeAspectFill

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use enum by apple - AVLayerVideoGravity?

}
}

Expand Down