Bladeren bron

Merge branch 'master' of https://git.yishihui.com/iOS/BFRecordScreenKit
合并代码

jsonwang 3 jaren geleden
bovenliggende
commit
fd66cfba4e

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

@@ -490,26 +490,27 @@ public class BFRecordScreenController: BFBaseViewController {
                 BFLog(message: "识别结果为空????不能生成字幕数据")
                 return
             }
-            if eventCode == 2 || eventCode == 26 {
+            if eventCode == 26 {
                 self?.currentRecordId = nil
             }
             if eventCode == 0 {
                 self?.currentRecordId = recordId
             }
             // 只有为24时才有字幕返回
-            if eventCode != 24 {
+            if eventCode != 24 || recordId == nil{
                 return
             }
-            DispatchQueue.global().async {
+            DispatchQueue.global().async { [weak self] in
                 let dicResult: [String: Any]? = jsonStringToDictionary(asrResult!)
                 let header = dicResult?["header"] as? [String: Any]
                 let payload = dicResult?["payload"] as? [String: Any]
-                BFLog(1, message: "识别结果:) \(payload?["result"] ?? "") ,taskId:\((header?["task_id"] as? String) ?? "taskId"), 识别时间:\(((payload?["begin_time"]) as? Int) ?? 0) ~ \(((payload?["time"]) as? Int) ?? 0) startTime:\(self?.recorderManager?.voiceModel?.startCMTime.seconds ?? 0.0)")
+                BFLog(1, message: "onNuiEventCallback event 识别结果:) \(payload?["result"] ?? "") ,taskId:\((header?["task_id"] as? String) ?? "taskId"), 识别时间:\(((payload?["begin_time"]) as? Int) ?? 0) ~ \(((payload?["time"]) as? Int) ?? 0) startTime:\(self?.recorderManager?.voiceModel?.startCMTime.seconds ?? 0.0)")
                 // 1,保存字幕数据 begin_time是开始出现文字的时间,time 是结束文字出现的时间 单位都为毫秒,都是相对于录制音频数据整段时间。self.recorderManager.voiceModel?.startCMTime.seconds 为开始的录制的时间,开始和结束都要加上这个时差
 
                 let newSubtitle = PQEditSubTitleModel()
                 // 任务全局唯一ID,请记录该值,便于排查问题。 每次 startRecorder 和 stopRecoder 之间  task_Id都不会变化
                 let taskID = header?["task_id"] as? String
+
                 newSubtitle.taskID = taskID ?? ""
                 newSubtitle.recordId = self?.currentRecordId
                 BFLog(1, message: "对应关系:字幕所属地址:taskID:\(taskID ?? ""),\((audioFilePath ?? "b").replacingOccurrences(of: documensDirectory, with: "")), 开始录音输入:\((self?.recorderManager?.voiceModel?.wavFilePath ?? "aa").replacingOccurrences(of: documensDirectory, with: ""))")
@@ -520,7 +521,7 @@ public class BFRecordScreenController: BFBaseViewController {
                 self?.itemModels.enumerated().forEach { index, item in
                     if tempVoice == nil {
                         tempVoice = item.voiceStickers.first { voice in
-                            voice.recordId == self?.currentRecordId
+                            voice.recordId == recordId
                         }
                         if tempVoice != nil {
                             tempItem = item
@@ -1373,7 +1374,7 @@ public class BFRecordScreenController: BFBaseViewController {
         hadPrepareToPlayRecord = false
         BFLog(1, message: "isDragingProgressSlder : \(isDragingProgressSlder)")
         BFLog(3, message: "重置播放index-\(#function) = \(currentPlayRecordIndex)")
-        searchStopAtRecordRange(needAdsorb: true)
+        searchStopAtRecordRange()
         changeWithDrawBtnLayout(0)
         isEndPlay = (progress == 1)
         recorderManager?.voiceModel = nil

+ 5 - 1
BFRecordScreenKit/Classes/RecordScreen/View/BFSubtitleSettingView.swift

@@ -165,6 +165,11 @@ class BFSubtitleSettingView: UIView {
                 make.centerY.equalTo(pointTitle.snp.centerY)
             }
         }
+        
+        let config = styleConfig[3]
+        subtitle.setting.subtitleSize = config?["subtitleSize"] as! Int
+        subtitle.setting.strokeWidth = CGFloat(config?["strokeWidth"] as? Double ?? 0.0)
+        
         // 就是一个线
         let line = UIView()
         line.backgroundColor = UIColor.hexColor(hexadecimal: "#121212")
@@ -234,7 +239,6 @@ class BFSubtitleSettingView: UIView {
         subtitle.setting.backgroundColor = config?["backgroundColor"] as! UIColor
         subtitle.setting.backgroundAlpha = Float(config?["backgroundAlpha"] as! Double)
         subtitle.setting.strokeColor = config?["strokeColor"] as! UIColor
-        subtitle.setting.strokeWidth =  CGFloat(config?["strokeWidth"] as! Double)
 
         if subtitleSettingCallBack != nil {
             subtitleSettingCallBack!(subtitle)