diff --git a/src/main/java/org/camelia/studio/kiss/shot/acerola/audio/TrackScheduler.java b/src/main/java/org/camelia/studio/kiss/shot/acerola/audio/TrackScheduler.java index 46bf097..c358e68 100644 --- a/src/main/java/org/camelia/studio/kiss/shot/acerola/audio/TrackScheduler.java +++ b/src/main/java/org/camelia/studio/kiss/shot/acerola/audio/TrackScheduler.java @@ -1,5 +1,8 @@ package org.camelia.studio.kiss.shot.acerola.audio; +import java.util.LinkedList; +import java.util.Queue; + import com.sedmelluq.discord.lavaplayer.player.AudioPlayer; import com.sedmelluq.discord.lavaplayer.player.event.AudioEventAdapter; import com.sedmelluq.discord.lavaplayer.track.AudioTrack; @@ -7,19 +10,35 @@ import com.sedmelluq.discord.lavaplayer.track.AudioTrackEndReason; public class TrackScheduler extends AudioEventAdapter { private final AudioPlayer player; + private final Queue queue; public TrackScheduler(AudioPlayer player) { this.player = player; + this.queue = new LinkedList<>(); } public void queue(AudioTrack track) { - player.startTrack(track, false); + if (!player.startTrack(track, true)) { + queue.offer(track); + } } @Override public void onTrackEnd(AudioPlayer player, AudioTrack track, AudioTrackEndReason endReason) { if (endReason.mayStartNext) { - // Ici vous pouvez gérer la lecture de la prochaine piste si vous implémentez une file d'attente + nextTrack(); } } + + public void nextTrack() { + player.startTrack(queue.poll(), false); + } + + public Queue getQueue() { + return queue; + } + + public void clearQueue() { + queue.clear(); + } } \ No newline at end of file