Browse Source

撤回Ui修正

harry 3 years ago
parent
commit
f2dc96c3df

+ 1 - 1
BFRecordScreenKit/Classes/BFRecordItemModel.swift

@@ -93,7 +93,7 @@ public class BFRecordItemModel: NSObject {
         })
     }
 
-    func fetchAVUrlAsset(_ phasset: PHAsset) {
+    public func fetchAVUrlAsset(_ phasset: PHAsset) {
         let options = PHVideoRequestOptions()
         options.isNetworkAccessAllowed = true
         options.deliveryMode = .automatic

+ 30 - 13
BFRecordScreenKit/Classes/RecordScreen/Controller/BFRecordScreenController.swift

@@ -529,7 +529,7 @@ public class BFRecordScreenController: BFBaseViewController {
                 }
                 DispatchQueue.main.async { [weak self] in
                     // 录音完,重绘撤销按钮,更新录音按钮,
-                    self?.changeWithDrawBtnLayout(true)
+                    self?.changeWithDrawBtnLayout(2)
                     // 注:在录制结束时矫正当前位置,避免跟指针无法对其
                     if deletedVoices.count == 0 {
                         self?.indirectionView?.resetCurrentItem(start: model.startTime, end: model.endTime)
@@ -570,6 +570,7 @@ public class BFRecordScreenController: BFBaseViewController {
             self?.resetCurrentProgress()
             // 移除
             self?.indirectionView?.deleteItem(isCurrent: true)
+   
         }
          
         recorderManager?.NeoNuiDebugHandle = { [weak self] msg in
@@ -915,6 +916,9 @@ public class BFRecordScreenController: BFBaseViewController {
             events.append(event)
 
             searchStopAtRecordRange()
+            
+            changeWithDrawBtnLayout(3)
+
         }
     }
 
@@ -977,7 +981,16 @@ public class BFRecordScreenController: BFBaseViewController {
         collectionView.isScrollEnabled = true
 
         recorderManager?.stopRecord(isCancel: false)
-        changeWithDrawBtnLayout(true)
+//        changeWithDrawBtnLayout(2)
+        /*
+         if currentAssetProgress.seconds - (recorderManager?.voiceModel?.startTime ?? 0 ) >= 1.0 {
+             recorderManager?.stopRecord(isCancel: false)
+             changeWithDrawBtnLayout(2)
+         }else{
+             recorderManager?.stopRecord(isCancel: true)
+             changeProgress(progress: Float(recorderManager?.voiceModel?.startTime ?? 0))
+         }
+         */
         if !avatarView.isHidden {
             avatarView.endRecord()
         }
@@ -1074,10 +1087,11 @@ public class BFRecordScreenController: BFBaseViewController {
             hadPrepareToPlayRecord = false
             progressThumV.progress = jumpTime
 
-            if let event = events.last, event.type == 2 {
-                changeWithDrawBtnLayout(true)
+            if let event = events.last{
+                changeWithDrawBtnLayout(event.type)
             } else {
-                changeWithDrawBtnLayout(false)
+                changeWithDrawBtnLayout(0)
+                withDrawBtn.isEnabled = false
             }
             searchStopAtRecordRange()
             let itemModel = itemModels[currItemModelIndex]
@@ -1106,7 +1120,7 @@ public class BFRecordScreenController: BFBaseViewController {
             searchStopAtRecordRange()
         } else {
             events.append(WithDrawModel(type: 1, timestamp: currentAssetProgress.seconds))
-            changeWithDrawBtnLayout(false)
+            changeWithDrawBtnLayout(0)
             play()
         }
     }
@@ -1136,7 +1150,7 @@ public class BFRecordScreenController: BFBaseViewController {
         BFLog(1, message: "isDragingProgressSlder : \(isDragingProgressSlder)")
         BFLog(3, message: "重置播放index-\(#function) = \(currentPlayRecordIndex)")
         searchStopAtRecordRange(needAdsorb: true)
-        changeWithDrawBtnLayout(false)
+        changeWithDrawBtnLayout(0)
         isEndPlay = (progress == 1)
     }
 
@@ -1146,7 +1160,7 @@ public class BFRecordScreenController: BFBaseViewController {
 
         // TODO: 滑动,播放暂停,撤销时,判断是否停止录音区间,是则删除相关录音,画笔,头像,字幕
         let elems = itemModels[currItemModelIndex].voiceStickers.enumerated().filter { elem in
-            elem.1.startTime <= self.currentAssetProgress.seconds && elem.1.endTime > self.currentAssetProgress.seconds
+            (elem.1.startTime + 0.001) <= self.currentAssetProgress.seconds && (elem.1.endTime - 0.001) > self.currentAssetProgress.seconds
         }
 
         isEndPlay = false
@@ -1589,10 +1603,13 @@ public class BFRecordScreenController: BFBaseViewController {
     // MARK: - 录音对应图像绘制
 
     // 撤销按钮修改title,重绘
-    func changeWithDrawBtnLayout(_ recorded: Bool) {
-        if recorded {
+    func changeWithDrawBtnLayout(_ type: Int) {
+        switch type {
+        case 3:
+            withDrawBtn.setTitle("撤销删除", for: .normal)
+        case 2:
             withDrawBtn.setTitle("撤销录制", for: .normal)
-        } else {
+        default:
             withDrawBtn.setTitle("回退", for: .normal)
         }
         withDrawBtn.imageEdgeInsets = UIEdgeInsets(top: -withDrawBtn.imageView!.height, left: 0, bottom: 0, right: -withDrawBtn.titleLabel!.width)
@@ -1790,7 +1807,7 @@ extension BFRecordScreenController: UICollectionViewDelegate, UICollectionViewDa
             recordPlayer?.seek(to: CMTime.zero)
 
             searchStopAtRecordRange()
-            changeWithDrawBtnLayout(false)
+            changeWithDrawBtnLayout(0)
             pauseTime = 0
             if recordItem.mediaType == .VIDEO {
                 reloadMaterial()
@@ -1876,7 +1893,7 @@ public extension BFRecordScreenController {
     /// 重置进度
     func resetCurrentProgress() {
         DispatchQueue.main.async { [weak self] in
-            BFLog(message: "更新录音进度\(#function)-\(self?.currentAssetProgress.seconds ?? 0)")
+            BFLog(1, message: "更新录音进度\(#function)-\(self?.currentAssetProgress.seconds ?? 0)")
             self?.progreddL.text = String(format: "%@", (self?.currentAssetProgress.seconds ?? 0).formatDurationToHMS())
             self?.progressThumV.progress = (self?.currentAssetProgress.seconds ?? 0)
             self?.updateSubtitle(time: self?.currentAssetProgress ?? CMTime.zero)