diff --git a/Package.swift b/Package.swift index 736e4bd..f799181 100644 --- a/Package.swift +++ b/Package.swift @@ -24,7 +24,8 @@ let package = Package( // Targets can depend on other targets in this package, and on products in packages this package depends on. .target( name: "Camera-SwiftUI", - dependencies: []), + dependencies: [], + resources: [.copy("Resources/PrivacyInfo.xcprivacy")]), .testTarget( name: "Camera-SwiftUITests", dependencies: ["Camera-SwiftUI"]), diff --git a/Sources/Camera-SwiftUI/Resources/PrivacyInfo.xcprivacy b/Sources/Camera-SwiftUI/Resources/PrivacyInfo.xcprivacy new file mode 100644 index 0000000..2fcb82f --- /dev/null +++ b/Sources/Camera-SwiftUI/Resources/PrivacyInfo.xcprivacy @@ -0,0 +1,6 @@ + + + + NSPrivacyCollectedDataTypes + + diff --git a/Sources/Camera-SwiftUI/Service/CameraService.swift b/Sources/Camera-SwiftUI/Service/CameraService.swift index 3dca2eb..02a9f9c 100644 --- a/Sources/Camera-SwiftUI/Service/CameraService.swift +++ b/Sources/Camera-SwiftUI/Service/CameraService.swift @@ -462,7 +462,15 @@ public class CameraService: NSObject, Identifiable { } } } - + + public var minAvailableVideoZoomFactor: CGFloat { + videoDeviceInput.device.minAvailableVideoZoomFactor + } + + public var maxAvailableVideoZoomFactor: CGFloat { + videoDeviceInput.device.maxAvailableVideoZoomFactor + } + public func set(zoom: CGFloat){ let factor = zoom < 1 ? 1 : zoom let device = self.videoDeviceInput.device @@ -476,7 +484,21 @@ public class CameraService: NSObject, Identifiable { print(error.localizedDescription) } } - + + public func ramp(toZoom zoom: CGFloat, withRate rate: Float) { + let factor = zoom < 1 ? 1 : zoom + let device = self.videoDeviceInput.device + + do { + try device.lockForConfiguration() + device.ramp(toVideoZoomFactor: factor, withRate: rate) + device.unlockForConfiguration() + } + catch { + print(error.localizedDescription) + } + } + // MARK: Capture Photo /// - Tag: CapturePhoto diff --git a/Sources/Camera-SwiftUI/View/CameraPreview.swift b/Sources/Camera-SwiftUI/View/CameraPreview.swift index e9c0d55..f0c1588 100644 --- a/Sources/Camera-SwiftUI/View/CameraPreview.swift +++ b/Sources/Camera-SwiftUI/View/CameraPreview.swift @@ -64,9 +64,11 @@ public struct CameraPreview: UIViewRepresentable { } public let session: AVCaptureSession - - public init(session: AVCaptureSession) { + public let videoGravity: AVLayerVideoGravity + + public init(session: AVCaptureSession, videoGravity: AVLayerVideoGravity = .resizeAspect) { self.session = session + self.videoGravity = videoGravity } public func makeUIView(context: Context) -> VideoPreviewView { @@ -75,6 +77,7 @@ public struct CameraPreview: UIViewRepresentable { viewFinder.videoPreviewLayer.cornerRadius = 0 viewFinder.videoPreviewLayer.session = session viewFinder.videoPreviewLayer.connection?.videoOrientation = .portrait + viewFinder.videoPreviewLayer.videoGravity = videoGravity return viewFinder }