Переглянути джерело

删除后变声时间点移动

harry 3 роки тому
батько
коміт
aaa077f4d2

+ 12 - 4
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
+                    }
                 }
             }
             // 更新录像的时间点
@@ -433,10 +441,10 @@ class BFRecordScreenCameraManager: BFRecordScreenBaseManager {
 //        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]()
@@ -470,7 +478,7 @@ class BFRecordScreenCameraManager: BFRecordScreenBaseManager {
             
             BFAudioPlayer.shared.delegate = self
             BFAudioPlayer.shared.configPlayer(audioPathURL: URL(fileURLWithPath: mod.wavFilePath))
-            BFAudioPlayer.shared.player?.rate = 2.0
+//            BFAudioPlayer.shared.player?.rate = 2.0
             
             let tt = currentAssetProgress - mod.startCMTime
             BFLog(1, message: "record - tt: \(tt.seconds), curr:\(currentAssetProgress.seconds) \(needPlay)")

+ 1 - 5
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)
@@ -1466,7 +1464,6 @@ public class BFRecordScreenController: BFBaseViewController {
         
             indirectionView?.deleteItem(index: isStopAtRecordRange)
             
-
             rscurrentManager.deleteRecord(at: currentAssetProgress)
             
             if currMediaType != .Video{
@@ -2817,7 +2814,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)")