diff --git a/ios/CameraView+Orientation.swift b/ios/CameraView+Orientation.swift index 5c6db1f..38dea19 100644 --- a/ios/CameraView+Orientation.swift +++ b/ios/CameraView+Orientation.swift @@ -10,18 +10,9 @@ import Foundation import UIKit extension CameraView { - /// Returns the current _interface_ orientation of the main window - private var windowInterfaceOrientation: UIInterfaceOrientation { - if #available(iOS 13.0, *) { - return UIApplication.shared.windows.first?.windowScene?.interfaceOrientation ?? .unknown - } else { - return UIApplication.shared.statusBarOrientation - } - } - /// Orientation of the input connection (preview) private var inputOrientation: UIInterfaceOrientation { - return windowInterfaceOrientation + return .portrait } // Orientation of the output connections (photo, video, frame processor) @@ -37,25 +28,18 @@ extension CameraView { } internal func updateOrientation() { - // Updates the Orientation for all rotable connections (outputs) as well as for the preview layer - DispatchQueue.main.async { - // `windowInterfaceOrientation` and `videoPreviewLayer` should only be accessed from UI thread - let isMirrored = self.videoDeviceInput?.device.position == .front + // Updates the Orientation for all rotable + let isMirrored = self.videoDeviceInput?.device.position == .front - self.videoPreviewLayer.connection?.setInterfaceOrientation(self.inputOrientation) - - let connectionOrientation = self.outputOrientation - self.cameraQueue.async { - // Run those updates on cameraQueue since they can be blocking. - self.captureSession.outputs.forEach { output in - output.connections.forEach { connection in - if connection.isVideoMirroringSupported { - connection.automaticallyAdjustsVideoMirroring = false - connection.isVideoMirrored = isMirrored - } - connection.setInterfaceOrientation(connectionOrientation) - } + let connectionOrientation = self.outputOrientation + // Run those updates on cameraQueue since they can be blocking. + self.captureSession.outputs.forEach { output in + output.connections.forEach { connection in + if connection.isVideoMirroringSupported { + connection.automaticallyAdjustsVideoMirroring = false + connection.isVideoMirrored = isMirrored } + connection.setInterfaceOrientation(connectionOrientation) } } }