private void PlayNext() { var item = InternalMusicQueue.Peek(); OnMusicPlay?.Invoke(this, item); VoiceConnection.PlayAudio(item.AudioSource).Forget(); }
public void Halt() { _halted = true; lock (InternalMusicQueue) { InternalMusicQueue.Clear(); } Guild.VoiceConnection?.Dispose(); }
public void AddToQueue(MusicQueueItem musicQueueItem) { ThrowIfHalted(); InternalMusicQueue.Enqueue(musicQueueItem); OnMusicAdded?.Invoke(this, musicQueueItem); if (InternalMusicQueue.Count == 1) { PlayNext(); } }
private void CreateListeners() { VoiceConnection.OnStopAudio += (a, b) => { lock (InternalMusicQueue) { if (InternalMusicQueue.Any()) { InternalMusicQueue.Dequeue(); if (InternalMusicQueue.Any()) { PlayNext(); } } } }; }