Skip to content
Open
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"]),
Expand Down
6 changes: 6 additions & 0 deletions Sources/Camera-SwiftUI/Resources/PrivacyInfo.xcprivacy
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict><key>NSPrivacyCollectedDataTypes</key><array></array>
</dict>
</plist>
26 changes: 24 additions & 2 deletions Sources/Camera-SwiftUI/Service/CameraService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
7 changes: 5 additions & 2 deletions Sources/Camera-SwiftUI/View/CameraPreview.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
}

Expand Down