|
@@ -10,6 +10,7 @@ import BFUIKit
|
|
|
import Photos
|
|
|
import BFRecordScreenKit
|
|
|
import UIKit
|
|
|
+import BFCommonKit
|
|
|
|
|
|
|
|
|
class INVideoExportController: BFBaseViewController {
|
|
@@ -17,6 +18,11 @@ class INVideoExportController: BFBaseViewController {
|
|
|
var videoAsset : AVURLAsset?
|
|
|
var avplayerTimeObserver: NSKeyValueObservation?
|
|
|
let backV = UIView()
|
|
|
+ var hasSaveAll = false
|
|
|
+ var hasSaveOnly = false
|
|
|
+ var saveAllUlr = URL(fileURLWithPath: "aaa")
|
|
|
+ var saveOnlyUlr = URL(fileURLWithPath: "aaa")
|
|
|
+
|
|
|
// 播放进度
|
|
|
lazy var progreddL : UILabel = {
|
|
|
let l = UILabel(frame: CGRect(x: 0, y: cDevice_iPhoneStatusBarHei, width: cScreenWidth, height: 14))
|
|
@@ -69,7 +75,7 @@ class INVideoExportController: BFBaseViewController {
|
|
|
exportBtn.setImage(UIImage(named: "export_btn"), for: .normal)
|
|
|
exportBtn.backgroundColor = ThemeStyleColor
|
|
|
exportBtn.addCorner(roundingCorners: .allCorners, corner: 8)
|
|
|
- exportBtn.addTarget(self, action: #selector(exportNow), for: .touchUpInside)
|
|
|
+ exportBtn.addTarget(self, action: #selector(saveNow), for: .touchUpInside)
|
|
|
return exportBtn
|
|
|
}()
|
|
|
|
|
@@ -128,6 +134,16 @@ class INVideoExportController: BFBaseViewController {
|
|
|
let item = AVPlayerItem(url: fileUrl)
|
|
|
sself.avplayer.replaceCurrentItem(with: item)
|
|
|
sself.avplayer.play()
|
|
|
+
|
|
|
+ if sself.saveAllBtn.isSelected {
|
|
|
+ sself.saveAllUlr = fileUrl
|
|
|
+ sself.hasSaveAll = true
|
|
|
+ }
|
|
|
+
|
|
|
+ if sself.saveOnlyBtn.isSelected {
|
|
|
+ sself.saveOnlyUlr = fileUrl
|
|
|
+ sself.hasSaveOnly = true
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -164,6 +180,9 @@ class INVideoExportController: BFBaseViewController {
|
|
|
|
|
|
// export.startExprot()
|
|
|
|
|
|
+ DispatchQueue.main.asyncAfter(deadline: .now()+0.2) {[weak self] in
|
|
|
+ self?.exportNow()
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
func addSubviews(){
|
|
@@ -243,12 +262,31 @@ class INVideoExportController: BFBaseViewController {
|
|
|
|
|
|
//MARK: - 按钮事件
|
|
|
|
|
|
- @objc func exportNow(){
|
|
|
- bottomView.isHidden = true
|
|
|
- progressView.isHidden = false
|
|
|
- progressL.isHidden = false
|
|
|
- progreddL.isHidden = true
|
|
|
- export.startExprot(synthesisAll:saveAllBtn.isSelected)
|
|
|
+ func exportNow(){
|
|
|
+ if bottomView.isHidden {
|
|
|
+ cShowHUB(superView: nil, msg: "正在合成中。。。")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ bottomView.isHidden = true
|
|
|
+ progressView.isHidden = false
|
|
|
+ progressL.isHidden = false
|
|
|
+ progreddL.isHidden = true
|
|
|
+ export.startExprot(synthesisAll:saveAllBtn.isSelected)
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @objc func saveNow(){
|
|
|
+ if let url = (avplayer.currentItem?.asset as? AVURLAsset)?.url{
|
|
|
+ PHPhotoLibrary.shared().performChanges {
|
|
|
+ PHAssetChangeRequest.creationRequestForAssetFromVideo(atFileURL: url)
|
|
|
+ } completionHandler: { isFinished, _ in
|
|
|
+ if isFinished {
|
|
|
+ DispatchQueue.main.async {
|
|
|
+ cShowHUB(superView: nil, msg: "保存成功")
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@objc func saveAllAction(btn:UIButton){
|
|
@@ -257,7 +295,14 @@ class INVideoExportController: BFBaseViewController {
|
|
|
}
|
|
|
btn.isSelected = true
|
|
|
saveOnlyBtn.isSelected = false
|
|
|
-
|
|
|
+ avplayer.pause()
|
|
|
+ if !hasSaveAll{
|
|
|
+ exportNow()
|
|
|
+ }else{
|
|
|
+ let item = AVPlayerItem(url: saveAllUlr)
|
|
|
+ avplayer.replaceCurrentItem(with: item)
|
|
|
+ avplayer.play()
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@objc func saveOnlyAction(btn:UIButton){
|
|
@@ -266,6 +311,14 @@ class INVideoExportController: BFBaseViewController {
|
|
|
}
|
|
|
btn.isSelected = true
|
|
|
saveAllBtn.isSelected = false
|
|
|
+ avplayer.pause()
|
|
|
+ if !hasSaveOnly {
|
|
|
+ exportNow()
|
|
|
+ }else{
|
|
|
+ let item = AVPlayerItem(url: saveOnlyUlr)
|
|
|
+ avplayer.replaceCurrentItem(with: item)
|
|
|
+ avplayer.play()
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@objc func play(){
|