2021-07-26 03:32:58 -06:00
|
|
|
//
|
|
|
|
// AVCaptureConnection+setInterfaceOrientation.swift
|
|
|
|
// VisionCamera
|
|
|
|
//
|
|
|
|
// Created by Marc Rousavy on 26.07.21.
|
|
|
|
// Copyright © 2021 mrousavy. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import AVFoundation
|
|
|
|
import Foundation
|
2023-10-13 10:33:20 -06:00
|
|
|
import UIKit
|
2021-07-26 03:32:58 -06:00
|
|
|
|
|
|
|
extension AVCaptureConnection {
|
|
|
|
/**
|
|
|
|
Sets the `videoOrientation` to the given `orientation` if video orientation setting is supported.
|
|
|
|
*/
|
|
|
|
func setInterfaceOrientation(_ orientation: UIInterfaceOrientation) {
|
|
|
|
if isVideoOrientationSupported {
|
|
|
|
switch orientation {
|
|
|
|
case .portrait:
|
|
|
|
videoOrientation = .portrait
|
|
|
|
case .portraitUpsideDown:
|
|
|
|
videoOrientation = .portraitUpsideDown
|
|
|
|
case .landscapeLeft:
|
|
|
|
videoOrientation = .landscapeLeft
|
|
|
|
case .landscapeRight:
|
|
|
|
videoOrientation = .landscapeRight
|
|
|
|
case .unknown:
|
|
|
|
fallthrough
|
|
|
|
@unknown default:
|
|
|
|
videoOrientation = .portrait
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|