处理手机硬件锁屏时,通过coremotion监听屏幕旋转变化

This commit is contained in:
bluesea 2024-03-22 21:07:22 +08:00
parent d5fcf1d37c
commit b834ecf8dd
3 changed files with 121 additions and 283 deletions

View File

@ -11,6 +11,7 @@
005580782B9F1525004B9567 /* ZZHHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 005580772B9F1525004B9567 /* ZZHHelper.swift */; }; 005580782B9F1525004B9567 /* ZZHHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 005580772B9F1525004B9567 /* ZZHHelper.swift */; };
009661F82BAD6C7100FCA65F /* CCSpaceAlbumFilterPopView2.swift in Sources */ = {isa = PBXBuildFile; fileRef = 009661F72BAD6C7100FCA65F /* CCSpaceAlbumFilterPopView2.swift */; }; 009661F82BAD6C7100FCA65F /* CCSpaceAlbumFilterPopView2.swift in Sources */ = {isa = PBXBuildFile; fileRef = 009661F72BAD6C7100FCA65F /* CCSpaceAlbumFilterPopView2.swift */; };
009661FA2BAD876200FCA65F /* PhotosUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 009661F92BAD876200FCA65F /* PhotosUI.framework */; }; 009661FA2BAD876200FCA65F /* PhotosUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 009661F92BAD876200FCA65F /* PhotosUI.framework */; };
009661FC2BADB20D00FCA65F /* CoreMotion.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 009661FB2BADB20D00FCA65F /* CoreMotion.framework */; };
00B946232B67B26D00DA668F /* ddd_video.mp4 in Resources */ = {isa = PBXBuildFile; fileRef = 00B946222B67B26D00DA668F /* ddd_video.mp4 */; }; 00B946232B67B26D00DA668F /* ddd_video.mp4 in Resources */ = {isa = PBXBuildFile; fileRef = 00B946222B67B26D00DA668F /* ddd_video.mp4 */; };
00B946252B67B7DE00DA668F /* CCSpatialPlayView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 00B946242B67B7DE00DA668F /* CCSpatialPlayView.swift */; }; 00B946252B67B7DE00DA668F /* CCSpatialPlayView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 00B946242B67B7DE00DA668F /* CCSpatialPlayView.swift */; };
00C665732BAA81F900C309C3 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 00C665722BAA81F900C309C3 /* GoogleService-Info.plist */; }; 00C665732BAA81F900C309C3 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 00C665722BAA81F900C309C3 /* GoogleService-Info.plist */; };
@ -101,6 +102,7 @@
005580772B9F1525004B9567 /* ZZHHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ZZHHelper.swift; sourceTree = "<group>"; }; 005580772B9F1525004B9567 /* ZZHHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ZZHHelper.swift; sourceTree = "<group>"; };
009661F72BAD6C7100FCA65F /* CCSpaceAlbumFilterPopView2.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CCSpaceAlbumFilterPopView2.swift; sourceTree = "<group>"; }; 009661F72BAD6C7100FCA65F /* CCSpaceAlbumFilterPopView2.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CCSpaceAlbumFilterPopView2.swift; sourceTree = "<group>"; };
009661F92BAD876200FCA65F /* PhotosUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = PhotosUI.framework; path = System/Library/Frameworks/PhotosUI.framework; sourceTree = SDKROOT; }; 009661F92BAD876200FCA65F /* PhotosUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = PhotosUI.framework; path = System/Library/Frameworks/PhotosUI.framework; sourceTree = SDKROOT; };
009661FB2BADB20D00FCA65F /* CoreMotion.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreMotion.framework; path = System/Library/Frameworks/CoreMotion.framework; sourceTree = SDKROOT; };
00B946222B67B26D00DA668F /* ddd_video.mp4 */ = {isa = PBXFileReference; lastKnownFileType = file; path = ddd_video.mp4; sourceTree = "<group>"; }; 00B946222B67B26D00DA668F /* ddd_video.mp4 */ = {isa = PBXFileReference; lastKnownFileType = file; path = ddd_video.mp4; sourceTree = "<group>"; };
00B946242B67B7DE00DA668F /* CCSpatialPlayView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CCSpatialPlayView.swift; sourceTree = "<group>"; }; 00B946242B67B7DE00DA668F /* CCSpatialPlayView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CCSpatialPlayView.swift; sourceTree = "<group>"; };
00C665722BAA81F900C309C3 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; }; 00C665722BAA81F900C309C3 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
@ -203,6 +205,7 @@
AF2120D42B4E99FA00400B7F /* MobileCoreServices.framework in Frameworks */, AF2120D42B4E99FA00400B7F /* MobileCoreServices.framework in Frameworks */,
009661FA2BAD876200FCA65F /* PhotosUI.framework in Frameworks */, 009661FA2BAD876200FCA65F /* PhotosUI.framework in Frameworks */,
AF2120D62B4E9A0100400B7F /* Photos.framework in Frameworks */, AF2120D62B4E9A0100400B7F /* Photos.framework in Frameworks */,
009661FC2BADB20D00FCA65F /* CoreMotion.framework in Frameworks */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
@ -317,6 +320,7 @@
4D8F3A411661D600CD07B39B /* Frameworks */ = { 4D8F3A411661D600CD07B39B /* Frameworks */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
009661FB2BADB20D00FCA65F /* CoreMotion.framework */,
009661F92BAD876200FCA65F /* PhotosUI.framework */, 009661F92BAD876200FCA65F /* PhotosUI.framework */,
00EB2D042BA2D59000924D84 /* MessageUI.framework */, 00EB2D042BA2D59000924D84 /* MessageUI.framework */,
AF478B022B577D51005C35A5 /* AVFoundation.framework */, AF478B022B577D51005C35A5 /* AVFoundation.framework */,

View File

@ -217,84 +217,6 @@
stopOnStyle = "0"> stopOnStyle = "0">
</BreakpointContent> </BreakpointContent>
</BreakpointProxy> </BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "97D73D5E-52DA-4635-81F8-B4BED96FB19E"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "SwiftProject/Project/Controller/RecordingVideo/CCSpatialShootController.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "420"
endingLineNumber = "420"
landmarkName = "configureSession()"
landmarkType = "7">
<Locations>
<Location
uuid = "97D73D5E-52DA-4635-81F8-B4BED96FB19E - 928cb49c86da05db"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "SwiftProject.CCSpatialShootController.configureSession() -&gt; ()"
moduleName = "SwiftProject"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/aaa/Documents/IOS%20Dev/VR/SwiftProject/SwiftProject/Project/Controller/RecordingVideo/CCSpatialShootController.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "406"
endingLineNumber = "406"
offsetFromSymbolStart = "6184">
</Location>
<Location
uuid = "97D73D5E-52DA-4635-81F8-B4BED96FB19E - 928cb49c86da05f8"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "SwiftProject.CCSpatialShootController.configureSession() -&gt; ()"
moduleName = "SwiftProject"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/aaa/Documents/IOS%20Dev/VR/SwiftProject/SwiftProject/Project/Controller/RecordingVideo/CCSpatialShootController.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "407"
endingLineNumber = "407"
offsetFromSymbolStart = "5852">
</Location>
<Location
uuid = "97D73D5E-52DA-4635-81F8-B4BED96FB19E - 928cb49c86da04c2"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "SwiftProject.CCSpatialShootController.configureSession() -&gt; ()"
moduleName = "SwiftProject"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/aaa/Documents/IOS%20Dev/VR/SwiftProject/SwiftProject/Project/Controller/RecordingVideo/CCSpatialShootController.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "413"
endingLineNumber = "413"
offsetFromSymbolStart = "6472">
</Location>
<Location
uuid = "97D73D5E-52DA-4635-81F8-B4BED96FB19E - 928cb49c86d9fbad"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "SwiftProject.CCSpatialShootController.configureSession() -&gt; ()"
moduleName = "SwiftProject"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/aaa/Documents/IOS%20Dev/VR/SwiftProject/SwiftProject/Project/Controller/RecordingVideo/CCSpatialShootController.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "420"
endingLineNumber = "420"
offsetFromSymbolStart = "6472">
</Location>
</Locations>
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy <BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent <BreakpointContent
@ -589,162 +511,6 @@
</Locations> </Locations>
</BreakpointContent> </BreakpointContent>
</BreakpointProxy> </BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "679B28C9-4889-4546-A3C6-246F045B6896"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "SwiftProject/Project/Util/SpatialVideoWriter.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "85"
endingLineNumber = "85"
landmarkName = "writeSpatialVideo(leftEyeVideoURL:rightEyeVideoURL:outputVideoURL:completion:)"
landmarkType = "7">
<Locations>
<Location
uuid = "679B28C9-4889-4546-A3C6-246F045B6896 - ad91d10e3e2f72cf"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "SwiftProject.SpatialVideoWriter.writeSpatialVideo(leftEyeVideoURL: Foundation.URL, rightEyeVideoURL: Foundation.URL, outputVideoURL: Foundation.URL, completion: (Swift.Bool, Swift.Optional&lt;Swift.Error&gt;) -&gt; ()) -&gt; ()"
moduleName = "SwiftProject"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/aaa/Documents/IOS%20Dev/VR/SwiftProject/SwiftProject/Project/Util/SpatialVideoWriter.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "92"
endingLineNumber = "92"
offsetFromSymbolStart = "4848">
</Location>
<Location
uuid = "679B28C9-4889-4546-A3C6-246F045B6896 - ad91d10e3e2f73d7"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "SwiftProject.SpatialVideoWriter.writeSpatialVideo(leftEyeVideoURL: Foundation.URL, rightEyeVideoURL: Foundation.URL, outputVideoURL: Foundation.URL, completion: (Swift.Bool, Swift.Optional&lt;Swift.Error&gt;) -&gt; ()) -&gt; ()"
moduleName = "SwiftProject"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/aaa/Documents/IOS%20Dev/VR/SwiftProject/SwiftProject/Project/Util/SpatialVideoWriter.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "84"
endingLineNumber = "84"
offsetFromSymbolStart = "4544">
</Location>
<Location
uuid = "679B28C9-4889-4546-A3C6-246F045B6896 - ad91d10e3e2f73f4"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "SwiftProject.SpatialVideoWriter.writeSpatialVideo(leftEyeVideoURL: Foundation.URL, rightEyeVideoURL: Foundation.URL, outputVideoURL: Foundation.URL, completion: (Swift.Bool, Swift.Optional&lt;Swift.Error&gt;) -&gt; ()) -&gt; ()"
moduleName = "SwiftProject"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/aaa/Documents/IOS%20Dev/VR/SwiftProject/SwiftProject/Project/Util/SpatialVideoWriter.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "85"
endingLineNumber = "85"
offsetFromSymbolStart = "4532">
</Location>
<Location
uuid = "679B28C9-4889-4546-A3C6-246F045B6896 - ad91d10e3e2f7253"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "SwiftProject.SpatialVideoWriter.writeSpatialVideo(leftEyeVideoURL: Foundation.URL, rightEyeVideoURL: Foundation.URL, outputVideoURL: Foundation.URL, completion: (Swift.Bool, Swift.Optional&lt;Swift.Error&gt;) -&gt; ()) -&gt; ()"
moduleName = "SwiftProject"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/aaa/Documents/IOS%20Dev/VR/SwiftProject/SwiftProject/Project/Util/SpatialVideoWriter.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "88"
endingLineNumber = "88"
offsetFromSymbolStart = "3468">
</Location>
</Locations>
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "82615B78-E63E-4A1B-BDE7-151EC8CAECFE"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "SwiftProject/Project/Util/SpatialVideoWriter.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "78"
endingLineNumber = "78"
landmarkName = "writeSpatialVideo(leftEyeVideoURL:rightEyeVideoURL:outputVideoURL:completion:)"
landmarkType = "7">
<Locations>
<Location
uuid = "82615B78-E63E-4A1B-BDE7-151EC8CAECFE - ad91d10e3e2f731d"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "SwiftProject.SpatialVideoWriter.writeSpatialVideo(leftEyeVideoURL: Foundation.URL, rightEyeVideoURL: Foundation.URL, outputVideoURL: Foundation.URL, completion: (Swift.Bool, Swift.Optional&lt;Swift.Error&gt;) -&gt; ()) -&gt; ()"
moduleName = "SwiftProject"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/aaa/Documents/IOS%20Dev/VR/SwiftProject/SwiftProject/Project/Util/SpatialVideoWriter.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "78"
endingLineNumber = "78"
offsetFromSymbolStart = "4652">
</Location>
<Location
uuid = "82615B78-E63E-4A1B-BDE7-151EC8CAECFE - ad91d10e3e2f731d"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "SwiftProject.SpatialVideoWriter.writeSpatialVideo(leftEyeVideoURL: Foundation.URL, rightEyeVideoURL: Foundation.URL, outputVideoURL: Foundation.URL, completion: (Swift.Bool, Swift.Optional&lt;Swift.Error&gt;) -&gt; ()) -&gt; ()"
moduleName = "SwiftProject"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/aaa/Documents/IOS%20Dev/VR/SwiftProject/SwiftProject/Project/Util/SpatialVideoWriter.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "78"
endingLineNumber = "78"
offsetFromSymbolStart = "4348">
</Location>
<Location
uuid = "82615B78-E63E-4A1B-BDE7-151EC8CAECFE - ad91d10e3e2f733a"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "SwiftProject.SpatialVideoWriter.writeSpatialVideo(leftEyeVideoURL: Foundation.URL, rightEyeVideoURL: Foundation.URL, outputVideoURL: Foundation.URL, completion: (Swift.Bool, Swift.Optional&lt;Swift.Error&gt;) -&gt; ()) -&gt; ()"
moduleName = "SwiftProject"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/aaa/Documents/IOS%20Dev/VR/SwiftProject/SwiftProject/Project/Util/SpatialVideoWriter.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "79"
endingLineNumber = "79"
offsetFromSymbolStart = "4348">
</Location>
<Location
uuid = "82615B78-E63E-4A1B-BDE7-151EC8CAECFE - ad91d10e3e2f7253"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "SwiftProject.SpatialVideoWriter.writeSpatialVideo(leftEyeVideoURL: Foundation.URL, rightEyeVideoURL: Foundation.URL, outputVideoURL: Foundation.URL, completion: (Swift.Bool, Swift.Optional&lt;Swift.Error&gt;) -&gt; ()) -&gt; ()"
moduleName = "SwiftProject"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/aaa/Documents/IOS%20Dev/VR/SwiftProject/SwiftProject/Project/Util/SpatialVideoWriter.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "88"
endingLineNumber = "88"
offsetFromSymbolStart = "3468">
</Location>
</Locations>
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy <BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent <BreakpointContent

View File

@ -12,6 +12,7 @@ import AVKit
import VideoToolbox import VideoToolbox
import SVProgressHUD import SVProgressHUD
import Firebase import Firebase
import CoreMotion
class CCSpatialShootController: BaseController { class CCSpatialShootController: BaseController {
let kNowTimeToUserDefaultKey_SpatialShootController:String = "kNowTimeToUserDefaultKey_SpatialShootController" let kNowTimeToUserDefaultKey_SpatialShootController:String = "kNowTimeToUserDefaultKey_SpatialShootController"
var wideAngleCameraDevice:AVCaptureDevice?//使 var wideAngleCameraDevice:AVCaptureDevice?//使
@ -33,11 +34,13 @@ class CCSpatialShootController: BaseController {
var isRecording = false var isRecording = false
var imageCGImagePropertyOrientation:CGImagePropertyOrientation = CGImagePropertyOrientation.left//cgimage var imageCGImagePropertyOrientation:CGImagePropertyOrientation = CGImagePropertyOrientation.left//cgimage
var imageOrientation:UIImage.Orientation = UIImage.Orientation.up var imageOrientation:UIImage.Orientation = UIImage.Orientation.up
var deviceOrientation = 1// 1,2
let operationQueue:OperationQueue = OperationQueue()
var leftEyeVideoURL:URL? var leftEyeVideoURL:URL?
var rightEyeVideoURL:URL? var rightEyeVideoURL:URL?
var outputVideoURL: URL? var outputVideoURL: URL?
let motionManager = CMMotionManager()
var imgs:NSMutableArray = NSMutableArray() //广 var imgs:NSMutableArray = NSMutableArray() //广
//================================ //================================
@ -270,9 +273,9 @@ class CCSpatialShootController: BaseController {
//====== //======
// //
UIDevice.current.beginGeneratingDeviceOrientationNotifications() // UIDevice.current.beginGeneratingDeviceOrientationNotifications()
// UIDevice.orientationDidChangeNotification // // UIDevice.orientationDidChangeNotification
NotificationCenter.default.addObserver(self, selector: #selector(orientationDidChange), name: UIDevice.orientationDidChangeNotification, object: nil) // NotificationCenter.default.addObserver(self, selector: #selector(orientationDidChange), name: UIDevice.orientationDidChangeNotification, object: nil)
configureSession() // configureSession() //
@ -286,9 +289,21 @@ class CCSpatialShootController: BaseController {
showHorizontalScreenTips() showHorizontalScreenTips()
} }
if motionManager.isDeviceMotionAvailable {
motionManager.startDeviceMotionUpdates(to: OperationQueue.main) {[weak self] motion, error in
if let motion = motion {
//
self?.dealDeviceScreenOrientationByMotaion(motion)
}
}
}
// //
getAlbumFirstPhoto() getAlbumFirstPhoto()
orientationDidChange()
} }
private func setUI() { private func setUI() {
@ -673,18 +688,22 @@ class CCSpatialShootController: BaseController {
}else{ }else{
print("录像结束!!!") stopRVideo()
// }
stopRecordingTimer() }
stopVideoRecording()
UIView.animate(withDuration: 0.3) { func stopRVideo(){
// transform print("录像结束!!!")
self.shutterVideoButton.transform = CGAffineTransform(scaleX: 1.0, y: 1.0) //
self.shutterVideoButton.layer.cornerRadius = 28 stopRecordingTimer()
}completion: { finished in stopVideoRecording()
self.isRecording = false UIView.animate(withDuration: 0.3) {
self.changeSwitchstatus() // transform
} self.shutterVideoButton.transform = CGAffineTransform(scaleX: 1.0, y: 1.0)
self.shutterVideoButton.layer.cornerRadius = 28
}completion: { finished in
self.isRecording = false
self.changeSwitchstatus()
} }
} }
@ -841,47 +860,96 @@ class CCSpatialShootController: BaseController {
} }
func enableShutterBtn(_ value:Bool) {
shutterPhotoButton.isEnabled = value
shutterVideoButton.isEnabled = value
}
//MARK: - //MARK: -
func dealDeviceScreenOrientationByMotaion(_ motion:CMDeviceMotion){
let x = motion.gravity.x
let y = motion.gravity.y
if (fabs(y) >= fabs(x)){
if deviceOrientation != 1 {
enableShutterBtn(false)
deviceOrientation = 1
print("竖屏");
autoStopRecordVideo()
showHorizontalScreenTips()
}
}
else{
if deviceOrientation != 2 {
enableShutterBtn(true)
deviceOrientation = 2
hidenHorizontalScreenTips()
print("横屏");
}
}
}
@objc fileprivate func orientationDidChange() { @objc fileprivate func orientationDidChange() {
switch UIDevice.current.orientation { // enableShutterBtn(false)
case .unknown: // switch UIDevice.current.orientation {
print("未知") // case .unknown:
case .portrait: // print("")
print("竖屏") // case .portrait:
imageCGImagePropertyOrientation = .up // print("")
imageOrientation = .up // imageCGImagePropertyOrientation = .up
showHorizontalScreenTips() // imageOrientation = .up
case .portraitUpsideDown: //
print("颠倒竖屏") // autoStopRecordVideo()
imageCGImagePropertyOrientation = .down // showHorizontalScreenTips()
imageOrientation = .down // case .portraitUpsideDown:
showHorizontalScreenTips() // print("")
case .landscapeLeft: // autoStopRecordVideo()
print("设备向左旋转横屏") // imageCGImagePropertyOrientation = .down
imageCGImagePropertyOrientation = .left // imageOrientation = .down
imageOrientation = .left // showHorizontalScreenTips()
hidenHorizontalScreenTips() // case .landscapeLeft:
case .landscapeRight: // print("")
print("设备向右旋转横屏") // imageCGImagePropertyOrientation = .left
imageCGImagePropertyOrientation = .right // imageOrientation = .left
imageOrientation = .right // hidenHorizontalScreenTips()
hidenHorizontalScreenTips() // enableShutterBtn(true)
case .faceUp: // case .landscapeRight:
print("屏幕朝上") // print("")
case .faceDown: // imageCGImagePropertyOrientation = .right
print("屏幕朝下") // imageOrientation = .right
default: // hidenHorizontalScreenTips()
break // enableShutterBtn(true)
// case .faceUp:
// autoStopRecordVideo()
// print("")
// case .faceDown:
// autoStopRecordVideo()
// print("")
// default:
// break
// }
}
//
func autoStopRecordVideo(){
if self.isRecording {
stopRVideo()
} }
} }
deinit { deinit {
// //
NotificationCenter.default.removeObserver(self, name: UIDevice.orientationDidChangeNotification, object: nil) // NotificationCenter.default.removeObserver(self, name: UIDevice.orientationDidChangeNotification, object: nil)
// // //
UIDevice.current.endGeneratingDeviceOrientationNotifications() // UIDevice.current.endGeneratingDeviceOrientationNotifications()
if let timer = self.timer { if let timer = self.timer {
// //