mirror of
https://github.com/samsonjs/SwiftyCam.git
synced 2026-04-27 15:07:43 +00:00
Added support for capture in landscape orientation
This commit is contained in:
parent
474b1b53a8
commit
5caeaa73fb
1 changed files with 20 additions and 0 deletions
|
|
@ -288,6 +288,12 @@ open class SwiftyCamViewController: UIViewController {
|
||||||
// Begin Session
|
// Begin Session
|
||||||
self.session.startRunning()
|
self.session.startRunning()
|
||||||
self.isSessionRunning = self.session.isRunning
|
self.isSessionRunning = self.session.isRunning
|
||||||
|
|
||||||
|
// Preview layer video orientation can be set only after the connection is created
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
self.previewLayer.videoPreviewLayer.connection?.videoOrientation = self.getPreviewLayerOrientation()
|
||||||
|
}
|
||||||
|
|
||||||
case .notAuthorized:
|
case .notAuthorized:
|
||||||
// Prompt to App Settings
|
// Prompt to App Settings
|
||||||
self.promptToAppSettings()
|
self.promptToAppSettings()
|
||||||
|
|
@ -677,6 +683,20 @@ open class SwiftyCamViewController: UIViewController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fileprivate func getPreviewLayerOrientation() -> AVCaptureVideoOrientation {
|
||||||
|
// Depends on layout orientation, not device orientation
|
||||||
|
switch UIApplication.shared.statusBarOrientation {
|
||||||
|
case .portrait, .unknown:
|
||||||
|
return AVCaptureVideoOrientation.portrait
|
||||||
|
case .landscapeLeft:
|
||||||
|
return AVCaptureVideoOrientation.landscapeLeft
|
||||||
|
case .landscapeRight:
|
||||||
|
return AVCaptureVideoOrientation.landscapeRight
|
||||||
|
case .portraitUpsideDown:
|
||||||
|
return AVCaptureVideoOrientation.portraitUpsideDown
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fileprivate func getVideoOrientation() -> AVCaptureVideoOrientation {
|
fileprivate func getVideoOrientation() -> AVCaptureVideoOrientation {
|
||||||
guard shouldUseDeviceOrientation, let deviceOrientation = self.deviceOrientation else { return previewLayer!.videoPreviewLayer.connection.videoOrientation }
|
guard shouldUseDeviceOrientation, let deviceOrientation = self.deviceOrientation else { return previewLayer!.videoPreviewLayer.connection.videoOrientation }
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue