From bbd61c2b8046be61819be325a3bc892c683e4eda Mon Sep 17 00:00:00 2001
From: client_linchunjie <461730578@qq.com>
Date: 星期三, 12 九月 2018 14:40:00 +0800
Subject: [PATCH] 1913【前端】【主干】语音无法自动播放

---
 System/Chat/ChatCenter.cs |   36 +++++++++++++++++-------------------
 1 files changed, 17 insertions(+), 19 deletions(-)

diff --git a/System/Chat/ChatCenter.cs b/System/Chat/ChatCenter.cs
index ac1ecd0..05adb6c 100644
--- a/System/Chat/ChatCenter.cs
+++ b/System/Chat/ChatCenter.cs
@@ -148,7 +148,6 @@
             m_VoiceChatDict.Clear();
             autoPlayVoices.Clear();
             voicePlaying = false;
-            netState = 0;
         }
 
         public void OnSwitchAccount()
@@ -346,12 +345,6 @@
                            }
                            var bytes = Convert.FromBase64String(speech.content);
                            SaveSpeech(_player, tick, bytes);
-                           if (autoPlayVoices.Count > 0
-                           && autoPlayVoices[0].playerId == _player
-                           && autoPlayVoices[0].tick == tick)
-                           {
-                               AutoPlayVoice();
-                           }
                        }
                        catch (Exception e)
                        {
@@ -404,12 +397,20 @@
                 dict = new Dictionary<long, AudioClip>();
                 speechDict.Add(_decodec.playerId, dict);
             }
+            if (dict.ContainsKey(_decodec.tick))
+            {
+                return;
+            }
             var clip = AudioClip.Create("Sound", _decodec.samples.Length, 1, VoiceSettings.frequency, false);
             clip.SetData(_decodec.samples, 0);
             dict.Add(_decodec.tick, clip);
             if (_decodec.playerId == cachePlayerId && cacheTick == _decodec.tick)
             {
                 PlaySpeech(clip, cacheLength);
+            }
+            else if (autoPlayVoices.Count > 0)
+            {
+                AutoPlayVoice();
             }
             if (speechDownloadSuccess != null)
             {
@@ -520,12 +521,9 @@
             return ChatInfoType.World;
         }
 
-        int netState = 0;
-
         private void OnNetStatusChanged(NetworkReachability _state)
         {
-            netState = (int)_state;
-            if (netState != 1 && netState != 4)
+            if ((int)SDKUtility.Instance.NetworkType == 0)
             {
                 autoPlayVoices.Clear();
             }
@@ -536,9 +534,9 @@
 
         public void CheckAutoPlayVoice(ChatData _chat)
         {
-            var _netState = netState;
+            var netType = (int)SDKUtility.Instance.NetworkType;
 #if UNITY_EDITOR
-            _netState = 1;
+            netType = 2;
 #endif
             if (!serverInited)
             {
@@ -557,7 +555,7 @@
             {
                 return;
             }
-            if (!ChatSetting.Instance.GetAutoPlayVoice(_chat.type, _netState))
+            if (!ChatSetting.Instance.GetAutoPlayVoice(_chat.type, netType))
             {
                 return;
             }
@@ -626,7 +624,7 @@
                 case ChatBoolType.GradVoice4G:
                 case ChatBoolType.GradVoiceWifi:
                     if (!ChatSetting.Instance.GetAutoPlayVoice(ChatInfoType.Fairy, 1)
-                        && !ChatSetting.Instance.GetAutoPlayVoice(ChatInfoType.Fairy, 4))
+                        && !ChatSetting.Instance.GetAutoPlayVoice(ChatInfoType.Fairy, 2))
                     {
                         RemoveAutoVoice(ChatInfoType.Fairy);
                     }
@@ -634,7 +632,7 @@
                 case ChatBoolType.PrivatChatVoice4G:
                 case ChatBoolType.PrivateChatVoiceWifi:
                     if (!ChatSetting.Instance.GetAutoPlayVoice(ChatInfoType.Friend, 1)
-                        && !ChatSetting.Instance.GetAutoPlayVoice(ChatInfoType.Friend, 4))
+                        && !ChatSetting.Instance.GetAutoPlayVoice(ChatInfoType.Friend, 2))
                     {
                         RemoveAutoVoice(ChatInfoType.Friend);
                     }
@@ -642,7 +640,7 @@
                 case ChatBoolType.TeamVoice4G:
                 case ChatBoolType.TeamVoiceWifi:
                     if (!ChatSetting.Instance.GetAutoPlayVoice(ChatInfoType.Team, 1)
-                       && !ChatSetting.Instance.GetAutoPlayVoice(ChatInfoType.Team, 4))
+                       && !ChatSetting.Instance.GetAutoPlayVoice(ChatInfoType.Team, 2))
                     {
                         RemoveAutoVoice(ChatInfoType.Team);
                     }
@@ -650,7 +648,7 @@
                 case ChatBoolType.WorldVoice4G:
                 case ChatBoolType.WorldVoiceWifi:
                     if (!ChatSetting.Instance.GetAutoPlayVoice(ChatInfoType.World, 1)
-                       && !ChatSetting.Instance.GetAutoPlayVoice(ChatInfoType.World, 4))
+                       && !ChatSetting.Instance.GetAutoPlayVoice(ChatInfoType.World, 2))
                     {
                         RemoveAutoVoice(ChatInfoType.World);
                     }
@@ -658,7 +656,7 @@
                 case ChatBoolType.AreaVoiceWifi:
                 case ChatBoolType.AreaVoice4G:
                     if (!ChatSetting.Instance.GetAutoPlayVoice(ChatInfoType.Area, 1)
-                       && !ChatSetting.Instance.GetAutoPlayVoice(ChatInfoType.Area, 4))
+                       && !ChatSetting.Instance.GetAutoPlayVoice(ChatInfoType.Area, 2))
                     {
                         RemoveAutoVoice(ChatInfoType.Area);
                     }

--
Gitblit v1.8.0