Pārlūkot izejas kodu

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

# Conflicts:
#	BFRecordScreenKit/Classes/RecordScreen/Controller/BFRecordScreenCameraManager.swift
#	BFRecordScreenKit/Classes/RecordScreen/Controller/BFRecordScreenController.swift
合并代码
jsonwang 3 gadi atpakaļ
vecāks
revīzija
ed4d149807

+ 13 - 5
BFRecordScreenKit/Classes/RecordScreen/Controller/BFRecordScreenCameraManager.swift

@@ -320,7 +320,7 @@ class BFRecordScreenCameraManager: BFRecordScreenBaseManager {
             currentAssetProgress = videoS.1.timelineCMIn
             // 更新音频的时间点
             for model in item.voiceStickers {
-                if CMTimeCompare(currentAssetProgress, model.startCMTime) < 0 {
+                if CMTimeCompare(currentAssetProgress, model.startCMTime) <= 0 {
                     model.startCMTime = model.startCMTime - currDuration
                     model.endCMTime = model.endCMTime - currDuration
                     BFLog(1, message: "camera删除后更新voice time:\(model.startCMTime.seconds) ~ \(model.endCMTime.seconds)")
@@ -330,6 +330,14 @@ class BFRecordScreenCameraManager: BFRecordScreenBaseManager {
                             tm.timelineOut = tm.timelineOut - currDuration
                         }
                     }
+                    
+                    let vcList = recordItem!.voiceChangeStickers.filter { vc in
+                        vc.recordId == model.recordId
+                    }
+                    for voice in vcList {
+                        voice.startCMTime = voice.startCMTime - currDuration
+                        voice.endCMTime = voice.endCMTime - currDuration
+                    }
                 }
             }
             // 更新录像的时间点
@@ -428,15 +436,15 @@ class BFRecordScreenCameraManager: BFRecordScreenBaseManager {
 
     func playRecordVoice(needPlay: Bool = true) {
 
-        // 三种状态值
+        // 三种状态值ff
 //        case paused = 0
 //        case waitingToPlayAtSpecifiedRate = 1
 //        case playing = 2
         if (BFAudioPlayer.shared.player?.isPlaying ?? false || audioPlayerIsPlaying){
-            BFLog(2, message: "is playering 本次查找无效,有播放任务")
+//            BFLog(2, message: "is playering 本次查找无效,有播放任务")
             return
         }
-        BFLog(2,message: "开始查找!!!!当前进度:\(currentAssetProgress.seconds)")
+//        BFLog(2,message: "开始查找!!!!当前进度:\(currentAssetProgress.seconds)")
 
         // 播放音频
         var useVoiceStickers = [PQVoiceModel]()
@@ -480,9 +488,9 @@ class BFRecordScreenCameraManager: BFRecordScreenBaseManager {
            let outTime =  ttsAudioAsset.duration.seconds - (mod.endCMTime - mod.startCMTime).seconds
             BFAudioPlayer.shared.delegate = self
             BFAudioPlayer.shared.configPlayer(audioPathURL: URL(fileURLWithPath: mod.wavFilePath))
-     
             //如果音频比原来的字幕时间要长,动态加速保证和字幕时长一致。
             BFAudioPlayer.shared.player?.rate = Float(outTime > 0 ? ttsAudioAsset.duration.seconds / (mod.endCMTime - mod.startCMTime).seconds : 1.0)
+ 
             
             let tt = currentAssetProgress - mod.startCMTime
             BFLog(1, message: "record - tt: \(tt.seconds), curr:\(currentAssetProgress.seconds) \(needPlay) rate:\(BFAudioPlayer.shared.player?.rate  ?? -1) 音频比字幕显示时间长 :\(outTime) \(mod.wavFilePath ?? "")")

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

@@ -918,8 +918,6 @@ public class BFRecordScreenController: BFBaseViewController {
                     wself.tts?.startTTS("", taskId: "", isAudition: true,fontName: selectVoice?.voice ?? "")
                     wself.voiceSettingView.flushSelectVoiceStatus(voiceStatue: .isLoading)
                 }
-                
- 
             }
             
         }
@@ -1455,7 +1453,7 @@ public class BFRecordScreenController: BFBaseViewController {
             let model = itemModels[currItemModelIndex].voiceStickers[isStopAtRecordRange]
 
             // 撤销记录点
-            var event = WithDrawModel(type: 3, timestamp: currentAssetProgress, recordItem: rscurrentManager.recordItem!.mutableCopy() as! BFRecordItemModel)
+            let event = WithDrawModel(type: 3, timestamp: currentAssetProgress, recordItem: rscurrentManager.recordItem!.mutableCopy() as! BFRecordItemModel)
             events.append(event)
 
             itemModels[currItemModelIndex].voiceStickers.remove(at: isStopAtRecordRange)
@@ -1465,10 +1463,10 @@ public class BFRecordScreenController: BFBaseViewController {
             deleteTitles(voiceModel: model)
         
             indirectionView?.deleteItem(index: isStopAtRecordRange)
-            
+ 
             // add by ak 删除变音的缓存数据
             tts?.deleteTasksCache(model.recordId ?? "")
-
+ 
             rscurrentManager.deleteRecord(at: currentAssetProgress)
             
             if currMediaType != .Video{
@@ -2821,7 +2819,6 @@ extension BFRecordScreenController: BFTTSManagerDelegte{
     
     public func ttsFinish(_ model:BFTTSTaskModel){
         
-        
         let ttsAudioAsset = AVURLAsset(url: URL(fileURLWithPath: model.wavFilePath), options: avAssertOptions)
      
         BFLog(message: "文字转语音完成recordId:\(model.recordId) tttaskid:\(model.tTtaskId)  tss语音时长\(ttsAudioAsset.duration.seconds) 字幕开始\(model.timelineIn.seconds) 字幕结束\(model.timelineOut.seconds) 字幕原时长\(CMTimeSubtract(model.timelineOut, model.timelineIn).seconds)")