Bladeren bron

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

wenweiwei 3 jaren geleden
bovenliggende
commit
7e730ad1e7
1 gewijzigde bestanden met toevoegingen van 16 en 1 verwijderingen
  1. 16 1
      BFRecordScreenKit/Classes/RecordScreen/Controller/BFRecordScreenController.swift

+ 16 - 1
BFRecordScreenKit/Classes/RecordScreen/Controller/BFRecordScreenController.swift

@@ -507,6 +507,9 @@ public class BFRecordScreenController: BFBaseViewController {
                             BFLog(1, message: "卡在录音尾巴上了1")
                             newSubtitle.timelineIn = newSubtitle.timelineIn - CMTime(seconds: 0.1, preferredTimescale: 1000)
                         }
+                    }else {
+                        BFLog(1, message: "没有对应音频播放记录,出现错误!!!!!!")
+                        return
                     }
                 }
                 var showText = ((payload?["result"]) as? String) ?? ""
@@ -719,7 +722,7 @@ public class BFRecordScreenController: BFBaseViewController {
         }
         var findShowSubtitle: PQEditSubTitleModel?
         for (index, subtitle) in itemModels[currItemModelIndex].titleStickers.enumerated() {
-            if CMTimeCompare(subtitle.timelineIn, time) <= 0, CMTimeCompare(subtitle.timelineOut, time) >= 0 {
+            if CMTimeCompare(subtitle.timelineIn, time) <= 0, CMTimeCompare(subtitle.timelineOut, time) > 0, subtitle.audioFilePath.count > 0 { //  audioFilePath.count 这个条件是确保这个字幕有对应录音
                 findShowSubtitle = subtitle
                 BFLog(1, message: "找到要显示的字幕 in \((findShowSubtitle?.timelineIn ?? .zero).seconds) out \((findShowSubtitle?.timelineOut ?? .zero).seconds) text:\(findShowSubtitle?.text ?? "") currTime is \(CMTimeGetSeconds(time))")
                 showSubtitleIndex = index
@@ -1041,6 +1044,11 @@ public class BFRecordScreenController: BFBaseViewController {
         }
         beginOnStartBtn = false
 
+        recordBtn.isEnabled = false
+        DispatchQueue.main.asyncAfter(deadline: .now() + 0.25) {[weak self] in
+            self?.recordBtn.isEnabled = true
+        }
+        
         isRecording = false
 //        progressThumV.progressView.isUserInteractionEnabled = true
 //        collectionView.isScrollEnabled = true
@@ -1066,6 +1074,7 @@ public class BFRecordScreenController: BFBaseViewController {
         if !avatarView.isHidden {
             avatarView.endRecord()
         }
+        
     }
 
     @objc func cancleRecord() {
@@ -1967,6 +1976,10 @@ extension BFRecordScreenController: UICollectionViewDelegate, UICollectionViewDa
 
     public func collectionView(_: UICollectionView, didSelectItemAt _: IndexPath) {}
 
+    public func scrollViewWillBeginDragging(_ scrollView: UIScrollView) {
+        BFLog(1, message: "开始滚动")
+        recordBtn.isEnabled = false
+    }
     public func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
         endScrollItem(scrollView)
     }
@@ -1980,6 +1993,7 @@ extension BFRecordScreenController: UICollectionViewDelegate, UICollectionViewDa
     func endScrollItem(_ scrollView: UIScrollView) {
 //    public func scrollViewDidScroll(_ scrollView: UIScrollView) {
         BFLog(1, message: "滚动结束")
+        
         let page = Int((scrollView.contentOffset.x + scrollView.frame.width / 2) / scrollView.frame.width)
         if page != currItemModelIndex {
             // 切换素材时先把录制状态切为不可用,延迟可点,避免在缩略图未加载出来时即可录制
@@ -2044,6 +2058,7 @@ extension BFRecordScreenController: UICollectionViewDelegate, UICollectionViewDa
             cell?.contentView.addSubview(subtitleLabel)
             updateSubtitle(time: currentAssetProgress)
         }
+        recordBtn.isEnabled = true
     }
 
     public func updateContentOffset(index: Int) {