Sfoglia il codice sorgente

Merge branch 'master' of https://git.yishihui.com/iOS/BFRecordScreenKit

* 'master' of https://git.yishihui.com/iOS/BFRecordScreenKit:
  1.回复cancel录音
harry 3 anni fa
parent
commit
b3960c5a1e

+ 6 - 7
BFRecordScreenKit/Classes/RecordScreen/Controller/BFRecordScreenController.swift

@@ -464,9 +464,9 @@ public class BFRecordScreenController: BFBaseViewController {
                 } else {
                     if let voice = self?.itemModels[self?.currItemModelIndex ?? 0].voiceStickers.first(where: { m in
                         m.wavFilePath == audioFilePath
-                    }){
-                        newSubtitle.timelineIn = (voice.startCMTime.seconds ) + Float64((((payload?["begin_time"]) as? Int) ?? 0) + 300) / 1000.0
-                        newSubtitle.timelineOut = (voice.startCMTime.seconds ) + Float64(((payload?["time"]) as? Int) ?? 0) / 1000.0
+                    }) {
+                        newSubtitle.timelineIn = voice.startCMTime.seconds + Float64((((payload?["begin_time"]) as? Int) ?? 0) + 300) / 1000.0
+                        newSubtitle.timelineOut = voice.startCMTime.seconds + Float64(((payload?["time"]) as? Int) ?? 0) / 1000.0
                     }
                 }
                 var showText = ((payload?["result"]) as? String) ?? ""
@@ -669,7 +669,7 @@ public class BFRecordScreenController: BFBaseViewController {
 
     @objc func editSubtitle() {
         BFLog(message: "编辑字幕 index:\(showSubtitleIndex)")
-        if !isNormalPlaying  && subtitleLabel.text?.count != 0{
+        if !isNormalPlaying, subtitleLabel.text?.count != 0 {
             subtitleEditView.isHidden = false
             subtitleEditView.textView.becomeFirstResponder()
             subtitleEditView.setNewText(text: subtitleLabel.text ?? "", index: showSubtitleIndex)
@@ -949,7 +949,7 @@ public class BFRecordScreenController: BFBaseViewController {
         collectionView.isScrollEnabled = false
         // 开始录制时清除屏幕上的字幕
         subtitleLabel.text = ""
-        
+
         pause()
         if recorderManager == nil {
             BFLog(message: "录音机初始化错误!!!")
@@ -1625,7 +1625,7 @@ public class BFRecordScreenController: BFBaseViewController {
                         self?.progressThumV.progress = time.seconds
                     }
                     // 更新字幕
-                    if !(self?.isRecording ?? false){
+                    if !(self?.isRecording ?? false) {
                         self?.updateSubtitle(time: time)
                     }
                 }
@@ -1633,7 +1633,6 @@ public class BFRecordScreenController: BFBaseViewController {
         }
 
         if isRecording {
-            let ratioX = 0.08
             let startTime = recorderManager?.voiceModel?.startCMTime.seconds ?? 0
             let progress = currentAssetProgress.seconds - startTime // - ratioX
             // 使用播放器的进度来画线,因为进度是跟着播放器来了

+ 8 - 0
BFRecordScreenKit/Classes/RecordScreen/View/BFIndirectionProgressView.swift

@@ -15,6 +15,7 @@ class BFIndirectionProgressView: UIView {
     var themeColor: UIColor = UIColor.hexColor(hexadecimal: "#389AFF")
     var progressHeight: CGFloat = 6
     var tmpPercentW: CGFloat = 0
+    var deletedView: UIView?
     var percenWidth: CGFloat {
         get {
             if tmpPercentW.isNaN || tmpPercentW.isInfinite || (tmpPercentW <= 0 && totalDuration > 0) {
@@ -55,6 +56,7 @@ class BFIndirectionProgressView: UIView {
         frame.size.width = (superview as? UIScrollView)?.contentSize.width ?? 0
         self.totalDuration = totalDuration
         self.percenWidth = percenWidth
+        deletedView = nil
         subviews.forEach { vv in
             vv.removeFromSuperview()
         }
@@ -81,6 +83,7 @@ class BFIndirectionProgressView: UIView {
             (self?.currentItem?.frame.minX ?? 0) < sub.frame.minX && sub.frame.minX < (self?.currentItem?.frame.maxX ?? 0)
         }
         if vc !== nil {
+            deletedView = vc
             vc?.removeFromSuperview()
         }
     }
@@ -90,6 +93,7 @@ class BFIndirectionProgressView: UIView {
     func detectionAndCreateItem(start: CGFloat = 0, progress: Float64) {
         BFLog(message: "检测并创建item:\(start)")
         if currentItem == nil {
+            deletedView = nil
             currentItem = detectionItem(start: start, progress: progress)
         }
     }
@@ -132,6 +136,10 @@ class BFIndirectionProgressView: UIView {
         if isCurrent {
             currentItem?.removeFromSuperview()
             currentItem = nil
+            if deletedView != nil {
+                addSubview(deletedView!)
+            }
+            deletedView = nil
         } else {
             if index >= 0, index < subviews.count {
                 subviews[index].removeFromSuperview()