فهرست منبع

试听时 点击同一个人状态切换逻辑调整

jsonwang 3 سال پیش
والد
کامیت
20a8679bbc

+ 14 - 18
BFRecordScreenKit/Classes/RecordScreen/Controller/BFRecordScreenController.swift

@@ -832,7 +832,7 @@ public class BFRecordScreenController: BFBaseViewController {
             wself.voiceSettingView.voices = voices
          
         }
-        voiceSettingView.voiceSettingCallBack = {[weak self] actionType ,selectVoice in
+        voiceSettingView.voiceSettingCallBack = {[weak self] actionType ,selectVoice ,isSame in
             guard let wself = self else { return }
           
             if actionType == .VoiceSettingActionConfirm{//要生成真实音频文件
@@ -881,28 +881,24 @@ public class BFRecordScreenController: BFBaseViewController {
                 wself.tts?.stopTTS("")
             }else if actionType == .VoiceSettingActionSelected{//要进行试听或暂停操作
                 BFLog(2, message: "选择了一个发音人操作")
-                if(wself.mSelectVoiced == nil){
-                    //首次选直接转
-                    wself.tts?.startTTS("", taskId: "", isAudition: true,fontName: selectVoice?.voice ?? "")
-                    wself.voiceSettingView.flushSelectVoiceStatus(voiceStatue: .isLoading)
-                }else{ 
-                    if(wself.mSelectVoiced == selectVoice){  //是同一个发音人暂停
-
-                        BFLog(message: "试听播放器状态\(String(describing: wself.tts?.voicePlayer.state.rawValue) )")
-                     
-                        if (wself.tts?.voicePlayer.state == PlayerState.playing){
-                            wself.tts?.stopTTS("")
-                            wself.voiceSettingView.flushSelectVoiceStatus(voiceStatue: .isPause)
-                        }else{
-                            wself.tts?.startTTS("", taskId: "", isAudition: true,fontName: selectVoice?.voice ?? "")
-                            wself.voiceSettingView.flushSelectVoiceStatus(voiceStatue: .isLoading)
-                        }
+           
+                if(isSame){  //是同一个发音人暂停
 
-                    } else{//开始试听
+                    BFLog(message: "试听播放器状态\(String(describing: wself.tts?.voicePlayer.state.rawValue) )")
+                 
+                    if (wself.tts?.voicePlayer.state == PlayerState.playing){
+                        wself.tts?.stopTTS("")
+                        wself.voiceSettingView.flushSelectVoiceStatus(voiceStatue: .isPause)
+                    }else{
                         wself.tts?.startTTS("", taskId: "", isAudition: true,fontName: selectVoice?.voice ?? "")
                         wself.voiceSettingView.flushSelectVoiceStatus(voiceStatue: .isLoading)
                     }
+
+                } else{//开始试听
+                    wself.tts?.startTTS("", taskId: "", isAudition: true,fontName: selectVoice?.voice ?? "")
+                    wself.voiceSettingView.flushSelectVoiceStatus(voiceStatue: .isLoading)
                 }
+                
  
             }
             

+ 12 - 7
BFRecordScreenKit/Classes/RecordScreen/View/BFVoiceSettingView.swift

@@ -42,8 +42,8 @@ class BFVoiceSettingView: UIView {
         }
     }
 
-    // 操作回调
-    public var voiceSettingCallBack: ((_ actionType: VoiceSettingActionType, _ selectVoice: PQVoiceModel?) -> Void)?
+    // 操作回调  isSame 是否点击的是同一个人,进行状态切换使用
+    public var voiceSettingCallBack: ((_ actionType: VoiceSettingActionType, _ selectVoice: PQVoiceModel?,_ isSame:Bool ) -> Void)?
 
     // 当前选择的分类
     var curretnCategory: BFVoiceCategoryModel?
@@ -211,7 +211,7 @@ class BFVoiceSettingView: UIView {
     @objc func cancelAction() {
         hidden()
         if voiceSettingCallBack != nil {
-            voiceSettingCallBack!(.voiceSettingActionCancel, selectVoice)
+            voiceSettingCallBack!(.voiceSettingActionCancel, selectVoice,false)
         }
     }
     
@@ -219,7 +219,7 @@ class BFVoiceSettingView: UIView {
     @objc func okBtnAction() {
         hidden()
         if voiceSettingCallBack != nil {
-            voiceSettingCallBack!(.VoiceSettingActionConfirm, selectVoice)
+            voiceSettingCallBack!(.VoiceSettingActionConfirm, selectVoice,false)
         }
     }
 
@@ -239,7 +239,7 @@ class BFVoiceSettingView: UIView {
         }
 
         if voiceSettingCallBack != nil {
-            voiceSettingCallBack!(.voiceSettingActionDelete, selectVoice)
+            voiceSettingCallBack!(.voiceSettingActionDelete, selectVoice,false)
         }
     }
     
@@ -295,15 +295,20 @@ extension BFVoiceSettingView: UICollectionViewDelegate, UICollectionViewDataSour
 
             voicesCollectView.reloadData()
         } else {
+            //是否点击的是同一个人
+            let isSame = selectVoice == voices[curretnCategory?.cateName ?? ""]?[indexPath.item] ? true : false
+         
             selectVoice?.voiceStatue = .isNormal
             selectVoice = voices[curretnCategory?.cateName ?? ""]?[indexPath.item]
             selectVoice?.voiceStatue = .isSelected
             deleteBtn.isSelected = true
             voicesCollectView.reloadData()
-
+            
             if voiceSettingCallBack != nil {
-                voiceSettingCallBack!(.VoiceSettingActionSelected, selectVoice)
+                voiceSettingCallBack!(.VoiceSettingActionSelected, selectVoice,isSame)
             }
+            
+
         }
     }
 }