相机拍摄页面,将首选项调整为拍摄视频

This commit is contained in:
bluesea 2024-04-02 16:30:31 +08:00
parent a898f957f9
commit 3e3f368489

View File

@ -265,14 +265,11 @@ class CCSpatialShootController: BaseController {
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
ZZHHelper.setNowTimeToUserDefaultWithKey(kNowTimeToUserDefaultKey_SpatialShootController) ZZHHelper.setNowTimeToUserDefaultWithKey(kNowTimeToUserDefaultKey_SpatialShootController)
// view.backgroundColor = .white
outputVideoURL = URL.documentsDirectory.appendingPathComponent("output.MOV") outputVideoURL = URL.documentsDirectory.appendingPathComponent("output.MOV")
configureSession() // configureSession() //
setUI() setUI()
// showTips()
self.view.bringSubviewToFront(navtionImgView!) self.view.bringSubviewToFront(navtionImgView!)
// //
@ -295,8 +292,9 @@ class CCSpatialShootController: BaseController {
// //
getAlbumFirstPhoto() getAlbumFirstPhoto()
// orientationDidChange()
enableShutterBtn(false) enableShutterBtn(false)
//
switchButtonAction(videoButton)
} }
private func setUI() { private func setUI() {
@ -349,26 +347,28 @@ class CCSpatialShootController: BaseController {
cameraButton.snp.makeConstraints { (make) in cameraButton.snp.makeConstraints { (make) in
make.centerY.equalTo(switchBackView.snp.centerY) 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.width.equalTo(56)
make.height.equalTo(32) make.height.equalTo(32)
} }
videoButton.snp.makeConstraints { (make) in videoButton.snp.makeConstraints { (make) in
make.centerY.equalTo(switchBackView.snp.centerY) 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.width.equalTo(56)
make.height.equalTo(32) make.height.equalTo(32)
} }
cameraLabel.snp.makeConstraints { (make) in cameraLabel.snp.makeConstraints { (make) in
make.bottom.equalTo(switchBackView.snp.top).offset(-8) 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 videoLabel.snp.makeConstraints { (make) in
make.bottom.equalTo(switchBackView.snp.top).offset(-8) 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 wideAngleCameraDevice = backCamera
do { do {
print("builtInWideAngleCamera:\(backCamera.videoZoomFactor)")
// try backCamera.lockForConfiguration()
// backCamera.videoZoomFactor=1.0
// backCamera.unlockForConfiguration()
wideAngleCameraDeviceInput = try AVCaptureDeviceInput(device: backCamera) wideAngleCameraDeviceInput = try AVCaptureDeviceInput(device: backCamera)
guard let wideAngleCameraDeviceInput = wideAngleCameraDeviceInput, guard let wideAngleCameraDeviceInput = wideAngleCameraDeviceInput,
@ -1029,6 +1023,7 @@ extension CCSpatialShootController: AVCaptureFileOutputRecordingDelegate {
}) { success, error in }) { success, error in
if success { if success {
print("保存成功") print("保存成功")
// self?.getAlbumFirstPhoto()
} else if let error = error { } else if let error = error {
print("保存失败") print("保存失败")
} }
@ -1156,7 +1151,7 @@ extension CCSpatialShootController: AVCaptureFileOutputRecordingDelegate {
let creationRequest = PHAssetCreationRequest.forAsset() let creationRequest = PHAssetCreationRequest.forAsset()
creationRequest.addResource(with: .photoProxy, fileURL: fileURL, options: nil) creationRequest.addResource(with: .photoProxy, fileURL: fileURL, options: nil)
}) { success, error in }) {[weak self] success, error in
DispatchQueue.main.async { DispatchQueue.main.async {
SVProgressHUD.dismiss() SVProgressHUD.dismiss()
@ -1169,9 +1164,10 @@ extension CCSpatialShootController: AVCaptureFileOutputRecordingDelegate {
} }
} else { } else {
print("Photo saved to library successfully.") print("Photo saved to library successfully.")
// DispatchQueue.main.async { DispatchQueue.main.async {
// SVProgressHUD.showSuccess(withStatus: "") // SVProgressHUD.showSuccess(withStatus: "")
// } self?.getAlbumFirstPhoto()
}
} }
} }
} }