From f58669e5225237c3b649138ef01958f3df05e838 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Melaine=20G=C3=A9rard?= Date: Tue, 24 Dec 2024 15:16:57 +0100 Subject: [PATCH] :bug: fix playlists loading only first audio --- .../kiss/shot/acerola/audio/PlayerManager.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/camelia/studio/kiss/shot/acerola/audio/PlayerManager.java b/src/main/java/org/camelia/studio/kiss/shot/acerola/audio/PlayerManager.java index f35b1ad..a7708f7 100644 --- a/src/main/java/org/camelia/studio/kiss/shot/acerola/audio/PlayerManager.java +++ b/src/main/java/org/camelia/studio/kiss/shot/acerola/audio/PlayerManager.java @@ -11,6 +11,7 @@ import net.dv8tion.jda.api.entities.Guild; import net.dv8tion.jda.api.entities.channel.middleman.GuildMessageChannel; import java.util.HashMap; +import java.util.List; import java.util.Map; public class PlayerManager { @@ -41,7 +42,7 @@ public class PlayerManager { public void loadAndPlay(GuildMessageChannel channel, String url) { final GuildMusicManager musicManager = getMusicManager(channel.getGuild()); - + audioPlayerManager.loadItemOrdered(musicManager, url, new AudioLoadResultHandler() { @Override public void trackLoaded(AudioTrack track) { @@ -51,9 +52,14 @@ public class PlayerManager { @Override public void playlistLoaded(AudioPlaylist playlist) { - final AudioTrack track = playlist.getTracks().get(0); - musicManager.scheduler.queue(track); - channel.sendMessage("Ajout à la file d'attente: `" + track.getInfo().title + "`").queue(); + List tracks = playlist.getTracks(); + + channel.sendMessage( + "Ajout à la file d'attente: `" + playlist.getName() + "` - " + tracks.size() + " musiques.") + .queue(); + + for (AudioTrack track : tracks) + musicManager.scheduler.queue(track); } @Override