|
@@ -342,6 +342,7 @@ class INVideoExportController: BFBaseViewController {
|
|
|
DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) { [weak self] in
|
|
|
self?.exportNow()
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
func addSubviews() {
|
|
@@ -351,6 +352,8 @@ class INVideoExportController: BFBaseViewController {
|
|
|
playerLayer = AVPlayerLayer(player: avplayer)
|
|
|
backV.layer.addSublayer(playerLayer)
|
|
|
|
|
|
+ backV.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(playAction)))
|
|
|
+
|
|
|
backV.addSubview(progressView)
|
|
|
backV.addSubview(progressL)
|
|
|
backV.addSubview(errorView)
|
|
@@ -451,11 +454,21 @@ class INVideoExportController: BFBaseViewController {
|
|
|
}
|
|
|
isExporting = true
|
|
|
// bottomView.isHidden = true
|
|
|
+
|
|
|
+ if saveAllBtn.isSelected {
|
|
|
+ saveAllBtn.setImage(UIImage(named: "export_saveall_h"), for: .disabled)
|
|
|
+ saveAllBtn.setImage(UIImage(named: "export_saveall_h"), for: .disabled)
|
|
|
+ saveOnlyBtn.setImage(UIImage(named: "export_saveonly_n"), for: .disabled)
|
|
|
+ }else{
|
|
|
+ saveAllBtn.setImage(UIImage(named: "export_saveall_n"), for: .disabled)
|
|
|
+ saveOnlyBtn.setImage(UIImage(named: "export_saveonly_h"), for: .disabled)
|
|
|
+ }
|
|
|
+
|
|
|
saveAllBtn.isEnabled = false
|
|
|
saveOnlyBtn.isEnabled = false
|
|
|
saveToPhotoBtn.isEnabled = false
|
|
|
completeBtn.isEnabled = false
|
|
|
-
|
|
|
+
|
|
|
progressView.isHidden = false
|
|
|
progressL.isHidden = false
|
|
|
sliderView?.isHidden = true
|
|
@@ -534,43 +547,90 @@ class INVideoExportController: BFBaseViewController {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ @objc func playAction(){
|
|
|
+ if !isExporting {
|
|
|
+ if let sbtn = sliderView?.viewWithTag(1) as? UIButton{
|
|
|
+ sbtn.isSelected = !sbtn.isSelected
|
|
|
+ if sbtn.isSelected {
|
|
|
+ avplayer.pause()
|
|
|
+ }else{
|
|
|
+ avplayer.play()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
@objc func completeAction() {
|
|
|
// MARK: 删除所有录制资源. 现在放在了选择相册展示时清理cache
|
|
|
|
|
|
- if (!hasSaveOnly && saveOnlyUlr.absoluteString != "aaa")
|
|
|
- || (!hasSaveAll && saveAllUlr.absoluteString != "aaa")
|
|
|
- {
|
|
|
- let remindData = BFBaseModel()
|
|
|
- remindData.summary = "合成的视频尚未保存到相册"
|
|
|
- let alertV = BFRemindView(frame: view.bounds)
|
|
|
- alertV.isBanned = true
|
|
|
- alertV.confirmBtn.setTitle("不保存", for: .normal)
|
|
|
- alertV.cancelBtn.setTitle("确认保存", for: .normal)
|
|
|
- alertV.remindData = remindData
|
|
|
- alertV.remindBlock = { [weak self] item, _ in
|
|
|
+ if (!hasSaveOnly && !saveOnlyUlr.absoluteString.contains("aaa"))
|
|
|
+ || (!hasSaveAll && !saveAllUlr.absoluteString.contains("aaa")) {
|
|
|
+
|
|
|
+ let alertController = UIAlertController(title: "退出将不会保存当前操作",
|
|
|
+ message: "", preferredStyle: .alert)
|
|
|
+ let cancelAction = UIAlertAction(title: "不保存", style: .default){[weak self] action in
|
|
|
guard let sself = self else {
|
|
|
return
|
|
|
}
|
|
|
- if item.tag == 1 { // 确定返回到上一层
|
|
|
- if sself.hasExportOnly {
|
|
|
- PHPhotoLibrary.shared().performChanges {
|
|
|
- PHAssetChangeRequest.creationRequestForAssetFromVideo(atFileURL: sself.saveOnlyUlr)
|
|
|
- } completionHandler: { _, _ in
|
|
|
- }
|
|
|
+ sself.export.cancelExport()
|
|
|
+ sself.navigationController?.popToRootViewController(animated: true)
|
|
|
+ }
|
|
|
+ let okAction = UIAlertAction(title: "确认保存", style: .default) {[weak self] action in
|
|
|
+ guard let sself = self else {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if sself.hasExportOnly {
|
|
|
+ PHPhotoLibrary.shared().performChanges {
|
|
|
+ PHAssetChangeRequest.creationRequestForAssetFromVideo(atFileURL: sself.saveOnlyUlr)
|
|
|
+ } completionHandler: { _, _ in
|
|
|
}
|
|
|
- if sself.hasExportAll {
|
|
|
- PHPhotoLibrary.shared().performChanges {
|
|
|
- PHAssetChangeRequest.creationRequestForAssetFromVideo(atFileURL: sself.saveAllUlr)
|
|
|
- } completionHandler: { _, _ in
|
|
|
- }
|
|
|
+ }
|
|
|
+ if sself.hasExportAll {
|
|
|
+ PHPhotoLibrary.shared().performChanges {
|
|
|
+ PHAssetChangeRequest.creationRequestForAssetFromVideo(atFileURL: sself.saveAllUlr)
|
|
|
+ } completionHandler: { _, _ in
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
sself.export.cancelExport()
|
|
|
sself.navigationController?.popToRootViewController(animated: true)
|
|
|
}
|
|
|
- UIApplication.shared.keyWindow?.addSubview(alertV)
|
|
|
+ alertController.addAction(okAction)
|
|
|
+ alertController.addAction(cancelAction)
|
|
|
+
|
|
|
+ self.present(alertController, animated: true, completion: nil)
|
|
|
+
|
|
|
+//
|
|
|
+// let remindData = BFBaseModel()
|
|
|
+// remindData.summary = "合成的视频尚未保存到相册"
|
|
|
+// let alertV = BFRemindView(frame: view.bounds)
|
|
|
+// alertV.isBanned = true
|
|
|
+// alertV.confirmBtn.setTitle("不保存", for: .normal)
|
|
|
+// alertV.cancelBtn.setTitle("确认保存", for: .normal)
|
|
|
+// alertV.remindData = remindData
|
|
|
+// alertV.remindBlock = { [weak self] item, _ in
|
|
|
+// guard let sself = self else {
|
|
|
+// return
|
|
|
+// }
|
|
|
+// if item.tag == 1 { // 确定返回到上一层
|
|
|
+// if sself.hasExportOnly {
|
|
|
+// PHPhotoLibrary.shared().performChanges {
|
|
|
+// PHAssetChangeRequest.creationRequestForAssetFromVideo(atFileURL: sself.saveOnlyUlr)
|
|
|
+// } completionHandler: { _, _ in
|
|
|
+// }
|
|
|
+// }
|
|
|
+// if sself.hasExportAll {
|
|
|
+// PHPhotoLibrary.shared().performChanges {
|
|
|
+// PHAssetChangeRequest.creationRequestForAssetFromVideo(atFileURL: sself.saveAllUlr)
|
|
|
+// } completionHandler: { _, _ in
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// sself.export.cancelExport()
|
|
|
+// sself.navigationController?.popToRootViewController(animated: true)
|
|
|
+// }
|
|
|
+// UIApplication.shared.keyWindow?.addSubview(alertV)
|
|
|
} else {
|
|
|
export.cancelExport()
|
|
|
navigationController?.popToRootViewController(animated: true)
|