Пример #1
0
 void PlayNextVoice()
 {
     if (m_Record.Count > 0)
     {
         SpeechEngine.PlayAudio(m_Record[0].VoiceIndex, m_Record[0].VoiceBuffer);
     }
 }
Пример #2
0
        public bool Add(int voiceindex, byte[] voicebuffer)
        {
            if (voicebuffer == null)
            {
                return(false);
            }

            if (voicebuffer.Length <= 0)
            {
                return(false);
            }

            if (IsHaveVoice(voiceindex))
            {
                for (int i = 0; i < m_Record.Count; i++)
                {
                    if (m_Record[i].VoiceIndex == voiceindex)
                    {
                        m_Record.RemoveAt(i);
                        break;
                    }
                }
            }

            if (voiceindex == m_ForcePlayIndex)
            {
                if (m_PlayerDownload.Count >= m_PlayerDownloadMax)
                {
                    m_PlayerDownload.RemoveAt(0);
                }

                m_PlayerDownload.Add(new VoiceChat(voiceindex, voicebuffer));

                SpeechEngine.PlayAudio(voiceindex, voicebuffer, true);
            }
            else
            {
                if (m_Record.Count >= m_RecordMax)
                {
                    m_Record.RemoveAt(0);
                }

                m_Record.Add(new VoiceChat(voiceindex, voicebuffer));

                if (SpeechEngine.Status == SpeechEngine.SpeechStatus.SS_DEFAULT)
                {
                    PlayNextVoice();
                }
            }

            LogModule.DebugLog("PlayVoiceChat");

            return(true);
        }
Пример #3
0
 public void PlayInPlayerDownload(int voiceindex)
 {
     for (int i = 0; i < m_PlayerDownload.Count; i++)
     {
         if (m_PlayerDownload[i].VoiceIndex == voiceindex)
         {
             SpeechEngine.PlayAudio(m_PlayerDownload[i].VoiceIndex, m_PlayerDownload[i].VoiceBuffer, true);
             return;
         }
     }
 }
Пример #4
0
 public void ForcePlay(int voiceindex)
 {
     if (voiceindex == m_ForcePlayIndex)
     {
         for (int i = 0; i < m_Record.Count; i++)
         {
             if (m_Record[i].VoiceIndex == voiceindex)
             {
                 SpeechEngine.PlayAudio(m_Record[i].VoiceIndex, m_Record[i].VoiceBuffer, true);
                 return;
             }
         }
     }
 }
Пример #5
0
        public bool Add(int voiceindex, ByteString voicebuffer)
        {
            if (voicebuffer == null)
            {
                LogModule.DebugLog("voicebuffer == null");
                return(false);
            }

            if (voicebuffer.IsEmpty)
            {
                LogModule.DebugLog("voicebuffer.IsEmpty");
                return(false);
            }

            if (IsHaveVoice(voiceindex))
            {
                LogModule.DebugLog("IsHaveVoice(voiceindex)");
                return(false);
            }

            if (voiceindex == m_ForcePlayIndex)
            {
                if (m_PlayerDownload.Count >= m_PlayerDownloadMax)
                {
                    m_PlayerDownload.RemoveAt(0);
                }

                m_PlayerDownload.Add(new VoiceChat(voiceindex, voicebuffer.ToByteArray()));

                SpeechEngine.PlayAudio(voiceindex, voicebuffer.ToByteArray(), true);
            }
            else
            {
                if (m_Record.Count >= m_RecordMax)
                {
                    m_Record.RemoveAt(0);
                }

                m_Record.Add(new VoiceChat(voiceindex, voicebuffer.ToByteArray()));

                if (SpeechEngine.Status == SpeechEngine.SpeechStatus.SS_DEFAULT)
                {
                    PlayNextVoice();
                }
            }

            LogModule.DebugLog("PlayVoiceChat");

            return(true);
        }