From ab1fe085c2da8083fc083f4452026f6d2eec30b3 Mon Sep 17 00:00:00 2001 From: Matt Kohls Date: Sat, 4 May 2019 19:27:40 -0400 Subject: Adding in bits needed to clean up when people leave channel SoundChan will leave a channel after 10 seconds if it is the only member left. When it leaves it will empty the queue of audio to play. When SoundChan is the last member in a channel, it will pause any playing audio. New command to drop play queue and stop current audio. --- src/main/java/soundchan/TrackScheduler.java | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/main/java/soundchan/TrackScheduler.java') diff --git a/src/main/java/soundchan/TrackScheduler.java b/src/main/java/soundchan/TrackScheduler.java index cf7b1f8..7c14ebc 100644 --- a/src/main/java/soundchan/TrackScheduler.java +++ b/src/main/java/soundchan/TrackScheduler.java @@ -80,6 +80,14 @@ public class TrackScheduler extends AudioEventAdapter { player.startTrack(queue.poll(), false); } + /** + * Cleans out the queue of tracks and stops any playing track + */ + public void emptyQueue() { + player.stopTrack(); + queue.clear(); + } + @Override public void onTrackEnd(AudioPlayer player, AudioTrack track, AudioTrackEndReason endReason) { // Only start the next track if the end reason is suitable for it (FINISHED or LOAD_FAILED) -- cgit v1.2.3