Example #1
0
        private void PlayNext()
        {
            var item = InternalMusicQueue.Peek();

            OnMusicPlay?.Invoke(this, item);
            VoiceConnection.PlayAudio(item.AudioSource).Forget();
        }
Example #2
0
        public void Halt()
        {
            _halted = true;

            lock (InternalMusicQueue)
            {
                InternalMusicQueue.Clear();
            }
            Guild.VoiceConnection?.Dispose();
        }
Example #3
0
        public void AddToQueue(MusicQueueItem musicQueueItem)
        {
            ThrowIfHalted();

            InternalMusicQueue.Enqueue(musicQueueItem);

            OnMusicAdded?.Invoke(this, musicQueueItem);

            if (InternalMusicQueue.Count == 1)
            {
                PlayNext();
            }
        }
Example #4
0
 private void CreateListeners()
 {
     VoiceConnection.OnStopAudio += (a, b) =>
     {
         lock (InternalMusicQueue)
         {
             if (InternalMusicQueue.Any())
             {
                 InternalMusicQueue.Dequeue();
                 if (InternalMusicQueue.Any())
                 {
                     PlayNext();
                 }
             }
         }
     };
 }