Skip to content

Commit

Permalink
fix(IOS): file recording rotation
Browse files Browse the repository at this point in the history
  • Loading branch information
WcaleNieWolny committed Sep 3, 2024
1 parent 519e0b3 commit 1f64c46
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
17 changes: 17 additions & 0 deletions ios/Plugin/CameraController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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: "")
Expand Down
15 changes: 15 additions & 0 deletions ios/Plugin/Plugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down

0 comments on commit 1f64c46

Please sign in to comment.