Пример #1
0
 /// <summary>
 /// Adds to queue new audio data
 /// </summary>
 /// <param name="newVoice">Audio to be played</param>
 public void AddToQueue(byte[] newVoice)
 {
     currentBPSCount += newVoice.Length;
     VoiceQueue.Enqueue(newVoice);
     if (!PlayingVoice)
     {
         Task.Run(() => PlayVoiceAsync());
     }
 }
Пример #2
0
        private async void PlayVoiceAsync()
        {
            PlayingVoice = true;
            while (VoiceQueue.Count > 0)
            {
                await Task.Run(() =>
                {
                    AudioUtils.PlaySound(VoiceQueue.Dequeue());

                    if (VoiceQueue.Count > 1)
                    {
                        VoiceQueue.Clear();
                    }
                });
            }
            PlayingVoice = false;
        }