Browse Source

录制中不显示字幕;
字幕翻译最后被吃掉的保护

harry 3 years ago
parent
commit
464c7aa907

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

@@ -461,13 +461,24 @@ public class BFRecordScreenController: BFBaseViewController {
                 if URL(fileURLWithPath: audioFilePath ?? "b").deletingPathExtension().lastPathComponent.contains(URL(fileURLWithPath: (self?.recorderManager?.voiceModel?.wavFilePath ?? "aa")).deletingPathExtension().lastPathComponent) {
                     newSubtitle.timelineIn = (self?.recorderManager?.voiceModel?.startCMTime.seconds ?? 0.0) + Float64((((payload?["begin_time"]) as? Int) ?? 0) + 300) / 1000.0
                     newSubtitle.timelineOut = (self?.recorderManager?.voiceModel?.startCMTime.seconds ?? 0.0) + Float64(((payload?["time"]) as? Int) ?? 0) / 1000.0
+                    
+                    if newSubtitle.timelineIn - 0.2 > (self?.recorderManager?.voiceModel?.endCMTime.seconds ?? 0) {
+                        BFLog(1, message: "卡在录音尾巴上了1")
+                        newSubtitle.timelineIn -= 0.2
+                    }
                 } 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
+                        
+                        if newSubtitle.timelineIn - 0.2 > (voice.endCMTime.seconds ) {
+                            BFLog(1, message: "卡在录音尾巴上了1")
+                            newSubtitle.timelineIn -= 0.2
+                        }
                     }
+                    
                 }
                 var showText = ((payload?["result"]) as? String) ?? ""
                 if showText.count > subtitleMaxlength {
@@ -682,6 +693,9 @@ public class BFRecordScreenController: BFBaseViewController {
     /// - Parameter time: 当前播放的进度
     func updateSubtitle(time: CMTime) {
         BFLog(message: "currTime is \(CMTimeGetSeconds(time))")
+        if isRecording {
+            return
+        }
         var findShowSubtitle: PQEditSubTitleModel?
         for (index, subtitle) in itemModels[currItemModelIndex].titleStickers.enumerated() {
             if subtitle.timelineIn <= CMTimeGetSeconds(time), subtitle.timelineOut >= CMTimeGetSeconds(time) {
@@ -949,7 +963,8 @@ public class BFRecordScreenController: BFBaseViewController {
         collectionView.isScrollEnabled = false
         // 开始录制时清除屏幕上的字幕
         subtitleLabel.text = ""
-
+        subtitleLabel.backgroundColor = UIColor.clear
+        
         pause()
         if recorderManager == nil {
             BFLog(message: "录音机初始化错误!!!")