Browse Source

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

* 'dev' of https://git.yishihui.com/iOS/BFRecordScreenKit:
  设置变音 View  添加到 WINDWOS 上
  1,修改字幕后不显示 LOADDING view 静默转换  2, 如果点击播放 BTN 时 变音还有没有完成的 ,在变音完成后进行自动播放
  设置 UI
  没有选择发音人时 不显示 LOADING
胡志强 3 years ago
parent
commit
0e4017a562

+ 19 - 5
BFRecordScreenKit/Classes/RecordScreen/Controller/BFRecordScreenController.swift

@@ -604,6 +604,9 @@ public class BFRecordScreenController: BFBaseViewController {
         return audioQueueRecoderLabel
 
     }()
+    
+    //变音完成后是否自动播放,当前版本只有手动点击播放时,完成后自动进行播放
+    var voiceFinishAutoPlay:Bool = false
 
     // MARK: - ----------------- 生命周期
 
@@ -728,7 +731,9 @@ public class BFRecordScreenController: BFBaseViewController {
         view.addSubview(cameraFlipBtn)
         view.addSubview(subtitleSettingView)
         view.addSubview(audioSettingView)
-        view.addSubview(voiceSettingView)
+        //??? add key windows?
+        UIApplication.shared.keyWindow?.addSubview(voiceSettingView)
+
 
         bottomeView.addSubview(progreddL)
         //        view.addSubview(toolV)
@@ -772,7 +777,7 @@ public class BFRecordScreenController: BFBaseViewController {
             // 更新缓存数据
             if index < (wself.itemModels[wself.currItemModelIndex ].titleStickers.count ) {
                 //add by ak 1刷新变音缓存
-                let deleteTaskids:[String]? = wself.tts?.changedTitle(newtext, oldText:      wself.itemModels[wself.currItemModelIndex ].titleStickers[index].text) as? [String]
+                let deleteTaskids:[String]? = wself.tts?.changedTitle(newtext, oldText:wself.itemModels[wself.currItemModelIndex ].titleStickers[index].text) as? [String]
                 
                 //2刷新变量后的老音频数据
                 if((deleteTaskids?.count ?? 0) > 0){
@@ -795,13 +800,16 @@ public class BFRecordScreenController: BFBaseViewController {
                     wself.itemModels[wself.currItemModelIndex ].titleStickers.remove(at: index)
                     wself.subtitleLabel.text = ""
                 } else {
-                    wself.loadingView.loadShow()
-                    wself.tts?.runNextTask()
-                    wself.loadingView.titleL.text = "变声中 0%"
+                    
+              
                     //更新已经变音数据
                     // 更新数据
                     wself.itemModels[wself.currItemModelIndex ].titleStickers[index].text = newtext
                     wself.subtitleLabel.text = newtext
+                    
+                    //静默进行变音任务
+                    wself.tts?.runNextTask()
+
                 }
             }
 
@@ -2140,6 +2148,7 @@ public class BFRecordScreenController: BFBaseViewController {
     func play() {
         //如果当前段有没有转完的发音人显示 Loadingview
         if(!voiceChangeStickerFinish(itemIndex: currItemModelIndex,isShowLoadView: true)){
+            voiceFinishAutoPlay = true
             return
         }
 
@@ -2859,6 +2868,11 @@ extension BFRecordScreenController: BFTTSManagerDelegte{
             
             if(voiceChangeStickerFinish(itemIndex: currItemModelIndex)){
                 loadingView.loadHidden()
+                //完成后自动进行播放逻辑
+                if(voiceFinishAutoPlay){
+                    voiceFinishAutoPlay = false
+                    play()
+                }
             }
         }
         

+ 6 - 3
BFRecordScreenKit/Classes/RecordScreen/View/BFVoiceSettingView.swift

@@ -111,9 +111,11 @@ class BFVoiceSettingView: UIView {
         layout.scrollDirection = .vertical
 //        layout.itemSize = CGSize(width: adapterWidth(width: 60), height: 78)
         // 每行最小边距
-        layout.minimumLineSpacing = 20
+       
+        layout.minimumLineSpacing =  adapterWidth(width: 20)
         // 每列最小边距
-        layout.minimumInteritemSpacing = 24
+        layout.minimumInteritemSpacing =  24
+//        layout.minimumInteritemSpacing = (cScreenWidth - 64 - 240) / 3
         layout.sectionInset = UIEdgeInsets.zero
 
         let collectView = UICollectionView(frame: CGRect(x: 32, y: 118, width: cScreenWidth - 32 * 2, height: 242), collectionViewLayout: layout)
@@ -270,13 +272,14 @@ class BFVoiceSettingView: UIView {
 }
 
 extension BFVoiceSettingView: UICollectionViewDelegate, UICollectionViewDataSource, UIScrollViewDelegate, UICollectionViewDelegateFlowLayout {
+
     func collectionView(_ collectionView: UICollectionView,
                         layout _: UICollectionViewLayout,
                         sizeForItemAt indexPath: IndexPath) -> CGSize {
         if collectionView == catagaryCollectView {
             return CGSize(width: adapterWidth(width: 52) + 9, height: 40)
         }
-        return CGSize(width: adapterWidth(width: 60), height: 78)
+        return CGSize(width:(cScreenWidth - 64 - 3 * 24) / 4, height: 78)
     }
 
     func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection _: Int) -> Int {