Video orientation change fixed
This commit is contained in:
parent
7388c0cc87
commit
d0d3434d87
|
|
@ -208,7 +208,7 @@
|
|||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
|
||||
MTL_ENABLE_DEBUG_INFO = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
PROVISIONING_PROFILE = "4d0a483e-6fa4-454e-a019-6ce6d8c6f307";
|
||||
|
|
@ -246,7 +246,7 @@
|
|||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
PROVISIONING_PROFILE = "4d0a483e-6fa4-454e-a019-6ce6d8c6f307";
|
||||
SDKROOT = iphoneos;
|
||||
|
|
@ -260,6 +260,7 @@
|
|||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
INFOPLIST_FILE = camera/Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
};
|
||||
|
|
@ -270,6 +271,7 @@
|
|||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
INFOPLIST_FILE = camera/Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
};
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -204,7 +204,8 @@ class CameraManager: NSObject, AVCaptureFileOutputRecordingDelegate {
|
|||
}
|
||||
}
|
||||
self.captureSession?.commitConfiguration()
|
||||
|
||||
self._orientationChanged()
|
||||
|
||||
self.currentCameraOutputMode = newCameraOutputMode
|
||||
}
|
||||
}
|
||||
|
|
@ -440,22 +441,42 @@ class CameraManager: NSObject, AVCaptureFileOutputRecordingDelegate {
|
|||
|
||||
@objc private func _orientationChanged()
|
||||
{
|
||||
var currentConnection: AVCaptureConnection?;
|
||||
switch self.cameraOutputMode {
|
||||
case .StillImage:
|
||||
currentConnection = self.stillImageOutput?.connectionWithMediaType(AVMediaTypeVideo)
|
||||
case .VideoOnly, .VideoWithMic:
|
||||
currentConnection = self.movieOutput?.connectionWithMediaType(AVMediaTypeVideo)
|
||||
}
|
||||
|
||||
if let validPreviewLayer = self.previewLayer? {
|
||||
if let validPreviewLayerConnection = validPreviewLayer.connection? {
|
||||
switch UIDevice.currentDevice().orientation {
|
||||
case .LandscapeLeft:
|
||||
validPreviewLayerConnection.videoOrientation = .LandscapeRight
|
||||
case .LandscapeRight:
|
||||
validPreviewLayerConnection.videoOrientation = .LandscapeLeft
|
||||
default:
|
||||
validPreviewLayerConnection.videoOrientation = .Portrait
|
||||
if validPreviewLayerConnection.supportsVideoOrientation {
|
||||
validPreviewLayerConnection.videoOrientation = self._currentVideoOrientation()
|
||||
}
|
||||
dispatch_async(dispatch_get_main_queue(), { () -> Void in
|
||||
if let validEmbedingView = self.embedingView? {
|
||||
validPreviewLayer.frame = validEmbedingView.bounds
|
||||
}
|
||||
})
|
||||
}
|
||||
if let validOutputLayerConnection = currentConnection? {
|
||||
if validOutputLayerConnection.supportsVideoOrientation {
|
||||
validOutputLayerConnection.videoOrientation = self._currentVideoOrientation()
|
||||
}
|
||||
}
|
||||
dispatch_async(dispatch_get_main_queue(), { () -> Void in
|
||||
if let validEmbedingView = self.embedingView? {
|
||||
validPreviewLayer.frame = validEmbedingView.bounds
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
private func _currentVideoOrientation() -> AVCaptureVideoOrientation
|
||||
{
|
||||
switch UIDevice.currentDevice().orientation {
|
||||
case .LandscapeLeft:
|
||||
return .LandscapeRight
|
||||
case .LandscapeRight:
|
||||
return .LandscapeLeft
|
||||
default:
|
||||
return .Portrait
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -46,7 +46,6 @@ class ViewController: UIViewController {
|
|||
self.cameraManager.stopCaptureSession()
|
||||
}
|
||||
|
||||
|
||||
// MARK: - @IBActions
|
||||
|
||||
@IBAction func changeFlashMode(sender: UIButton)
|
||||
|
|
|
|||
Loading…
Reference in New Issue