diff --git a/ios/Plugin/CameraController.swift b/ios/Plugin/CameraController.swift index 2669aca9..25d95b70 100644 --- a/ios/Plugin/CameraController.swift +++ b/ios/Plugin/CameraController.swift @@ -442,6 +442,23 @@ extension CameraController { guard let fileVideoOutput = self.fileVideoOutput else { throw CameraControllerError.fileVideoOutputNotFound } + + // cpcp_video_A6C01203 - portrait + // + if let connection = fileVideoOutput.connection(with: .video) { + switch UIDevice.current.orientation { + case .landscapeRight: + connection.videoOrientation = .landscapeLeft + case .landscapeLeft: + connection.videoOrientation = .landscapeRight + case .portrait: + connection.videoOrientation = .portrait + case .portraitUpsideDown: + connection.videoOrientation = .portraitUpsideDown + default: + connection.videoOrientation = .portrait + } + } let identifier = UUID() let randomIdentifier = identifier.uuidString.replacingOccurrences(of: "-", with: "") diff --git a/ios/Plugin/Plugin.swift b/ios/Plugin/Plugin.swift index 8ce3cff0..bff535f5 100644 --- a/ios/Plugin/Plugin.swift +++ b/ios/Plugin/Plugin.swift @@ -63,6 +63,21 @@ public class CameraPreview: CAPPlugin { } self.cameraController.previewLayer?.frame = self.previewView.frame } + + if let connection = self.cameraController.fileVideoOutput?.connection(with: .video) { + switch UIDevice.current.orientation { + case .landscapeRight: + connection.videoOrientation = .landscapeLeft + case .landscapeLeft: + connection.videoOrientation = .landscapeRight + case .portrait: + connection.videoOrientation = .portrait + case .portraitUpsideDown: + connection.videoOrientation = .portraitUpsideDown + default: + connection.videoOrientation = .portrait + } + } cameraController.updateVideoOrientation() }