Browse Source

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

* 'dev' of https://git.yishihui.com/iOS/BFRecordScreenKit:
  区分 单段和全陪段落 进度显示
  添加 LOG
  变量返回 传给对应的段落
  图片变音预览
胡志强 3 years ago
parent
commit
c754c428a7

+ 5 - 0
BFRecordScreenKit/Classes/BFRecordExport.swift

@@ -195,6 +195,11 @@ public class BFRecordExport {
                             sticker.locationPath = mod.wavFilePath
                             sticker.volumeGain = 100 // Float64(model.volume)
                             voiceList.append(sticker)
+                            
+                            
+                            let ttsAudioAsset = AVURLAsset(url: URL(fileURLWithPath: sticker.locationPath), options: avAssertOptions)
+                      
+                            BFLog(message: "导出使用的音频文件 timelineIn:\(sticker.timelineIn) timelineOut\(sticker.timelineOut)  sticker.locationPath\( sticker.locationPath) tss语音时长\(ttsAudioAsset.duration.seconds)")
                         }
                     }
                 }

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

@@ -32,6 +32,8 @@ struct WithDrawModel {
 }
 
 public class BFRecordScreenController: BFBaseViewController {
+    // add by ak 是否点击了导出操作用于显示变量进度,预览是当前段落,导出是全部段落。
+    public var isExportAction:Bool = false
     public var nextActionHandle: (() -> Void)?
     public var closeActionHandle: (() -> Void)?
     public var changeItemHandle: ((_ index: Int) -> Void)?
@@ -1062,6 +1064,7 @@ public class BFRecordScreenController: BFBaseViewController {
                 ttsModel.fontName = wself.mSelectVoiced?.voice ?? ""
                 ttsModel.recordId = recordId ?? ""
                 ttsModel.tTtaskId = getUniqueId(desc: "tTtaskId")
+                ttsModel.itemModelIndex = Int32(wself.currItemModelIndex)
                 ttsModel.text = showText
                 if(wself.mSelectVoiced == nil){
                     wself.tts?.pushTaskCache(ttsModel, autoTranslate:false)
@@ -2836,16 +2839,35 @@ extension BFRecordScreenController: BFTTSManagerDelegte{
         voice.endCMTime = model.timelineOut
         voice.ttsTaskID = model.tTtaskId
         voice.recordId = model.recordId
-        itemModels[currItemModelIndex].voiceChangeStickers.append(voice)
+        itemModels[Int(model.itemModelIndex)].voiceChangeStickers.append(voice)
+        
+        //显示当前段的转换进度isExportAction
+        var  progress:Float = 0.0
+        if(isExportAction){
+            isExportAction = false
+            //所有任务数也就是字幕的个数
+            var AllCount = 0
+            //完成的任务数(已经有发音人地址的)
+            var FinishCount = 0
+
+            for itemModel in itemModels{
+                AllCount += itemModel.titleStickers.count
+                FinishCount += itemModel.voiceChangeStickers.count
+            }
+            progress = Float(FinishCount * 100 / AllCount)
+
+            
+        }else{
+            progress =  Float(itemModels[currItemModelIndex].voiceChangeStickers.count * 100 / itemModels[currItemModelIndex].titleStickers.count)
+            
+            if(voiceChangeStickerFinish(itemIndex: currItemModelIndex)){
+                loadingView.loadHidden()
+            }
+        }
         
-        //显示转换进度
-        let progress =  Float(itemModels[currItemModelIndex].voiceChangeStickers.count * 100 / itemModels[currItemModelIndex].titleStickers.count)
         BFLog(message: "TTS 进度:\(Int(progress))")
         loadingView.titleL.text = "变音中 \(Int(progress))%"
-        
-        if(voiceChangeStickerFinish(itemIndex: currItemModelIndex)){
-            loadingView.loadHidden()
-        }
+ 
         
     }
  

+ 9 - 1
BFRecordScreenKit/Classes/RecordScreen/Controller/BFRecordScreenImageManager.swift

@@ -59,7 +59,7 @@ class BFRecordScreenImageManager : BFRecordScreenBaseManager{
     }
     
     func checkCurrentPlayStatus(){
-        if let voice = recordItem?.voiceStickers.first(where: { mod in
+        if let voice = recordItem?.getUsedVoices().first(where: { mod in
             (mod.startCMTime - currentAssetProgress).seconds <= 0.05 && (mod.endCMTime - currentAssetProgress).seconds > 0.05
         }){
             let su = (recordPlayer?.currentItem?.asset as? AVURLAsset)?.url.lastPathComponent != (voice.wavFilePath as NSString?)?.lastPathComponent
@@ -127,6 +127,14 @@ class BFRecordScreenImageManager : BFRecordScreenBaseManager{
                         titleM.timelineIn = titleM.timelineIn - currDuration
                         titleM.timelineOut = titleM.timelineOut - currDuration
                     }
+                    //add by ak 修改变音的数据的开始结束时间
+                    let vcList = recordItem.voiceChangeStickers.filter { vc in
+                        vc.recordId == item.recordId
+                    }
+                    for voice in vcList {
+                        voice.startCMTime = voice.startCMTime - currDuration
+                        voice.endCMTime = voice.endCMTime - currDuration
+                    }
                 }
             }
             /// 重绘录音进度视图