From 3e3f368489ce4799225305cb62a906af23839a83 Mon Sep 17 00:00:00 2001 From: bluesea <307723040@qq.com> Date: Tue, 2 Apr 2024 16:30:31 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9B=B8=E6=9C=BA=E6=8B=8D=E6=91=84=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2,=E5=B0=86=E9=A6=96=E9=80=89=E9=A1=B9=E8=B0=83?= =?UTF-8?q?=E6=95=B4=E4=B8=BA=E6=8B=8D=E6=91=84=E8=A7=86=E9=A2=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CCSpatialShootController.swift | 32 ++++++++----------- 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/SwiftProject/SwiftProject/Project/Controller/RecordingVideo/CCSpatialShootController.swift b/SwiftProject/SwiftProject/Project/Controller/RecordingVideo/CCSpatialShootController.swift index d7d5bb7..ef701cd 100644 --- a/SwiftProject/SwiftProject/Project/Controller/RecordingVideo/CCSpatialShootController.swift +++ b/SwiftProject/SwiftProject/Project/Controller/RecordingVideo/CCSpatialShootController.swift @@ -265,14 +265,11 @@ class CCSpatialShootController: BaseController { override func viewDidLoad() { super.viewDidLoad() ZZHHelper.setNowTimeToUserDefaultWithKey(kNowTimeToUserDefaultKey_SpatialShootController) - // view.backgroundColor = .white - + outputVideoURL = URL.documentsDirectory.appendingPathComponent("output.MOV") - configureSession() // 设置相机参数 setUI() -// showTips() self.view.bringSubviewToFront(navtionImgView!) //判断当前是否是横屏 @@ -295,8 +292,9 @@ class CCSpatialShootController: BaseController { //读取相册第一张照片 getAlbumFirstPhoto() -// orientationDidChange() enableShutterBtn(false) + //进入页面的首选项调整为视频拍摄 + switchButtonAction(videoButton) } private func setUI() { @@ -349,26 +347,28 @@ class CCSpatialShootController: BaseController { cameraButton.snp.makeConstraints { (make) in make.centerY.equalTo(switchBackView.snp.centerY) - make.leading.equalTo(switchBackView.snp.leading).offset(4) + + make.trailing.equalTo(switchBackView.snp.trailing).offset(-4) make.width.equalTo(56) make.height.equalTo(32) } videoButton.snp.makeConstraints { (make) in make.centerY.equalTo(switchBackView.snp.centerY) - make.trailing.equalTo(switchBackView.snp.trailing).offset(-4) + make.leading.equalTo(switchBackView.snp.leading).offset(4) make.width.equalTo(56) make.height.equalTo(32) } cameraLabel.snp.makeConstraints { (make) in make.bottom.equalTo(switchBackView.snp.top).offset(-8) - make.centerX.equalTo(switchBackView.snp.leading).offset(32) + + make.centerX.equalTo(switchBackView.snp.trailing).offset(-32) } videoLabel.snp.makeConstraints { (make) in make.bottom.equalTo(switchBackView.snp.top).offset(-8) - make.centerX.equalTo(switchBackView.snp.trailing).offset(-32) + make.centerX.equalTo(switchBackView.snp.leading).offset(32) } } @@ -387,12 +387,6 @@ class CCSpatialShootController: BaseController { wideAngleCameraDevice = backCamera do { - print("builtInWideAngleCamera:\(backCamera.videoZoomFactor)") -// try backCamera.lockForConfiguration() -// backCamera.videoZoomFactor=1.0 - -// backCamera.unlockForConfiguration() - wideAngleCameraDeviceInput = try AVCaptureDeviceInput(device: backCamera) guard let wideAngleCameraDeviceInput = wideAngleCameraDeviceInput, @@ -1029,6 +1023,7 @@ extension CCSpatialShootController: AVCaptureFileOutputRecordingDelegate { }) { success, error in if success { print("保存成功") +// self?.getAlbumFirstPhoto() } else if let error = error { print("保存失败") } @@ -1156,7 +1151,7 @@ extension CCSpatialShootController: AVCaptureFileOutputRecordingDelegate { let creationRequest = PHAssetCreationRequest.forAsset() creationRequest.addResource(with: .photoProxy, fileURL: fileURL, options: nil) - }) { success, error in + }) {[weak self] success, error in DispatchQueue.main.async { SVProgressHUD.dismiss() @@ -1169,9 +1164,10 @@ extension CCSpatialShootController: AVCaptureFileOutputRecordingDelegate { } } else { print("Photo saved to library successfully.") -// DispatchQueue.main.async { + DispatchQueue.main.async { // SVProgressHUD.showSuccess(withStatus: "空间图片成功保存到相册") -// } + self?.getAlbumFirstPhoto() + } } } }