From ae7fe8cc7b14cf0d3b45fb00a8c32347de6326cb Mon Sep 17 00:00:00 2001 From: Nekojimi Date: Thu, 23 Jun 2022 17:58:15 +0100 Subject: [PATCH] Add back support for restarting the current track. --- .../java/moe/nekojimi/chords/QueueManager.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/main/java/moe/nekojimi/chords/QueueManager.java b/src/main/java/moe/nekojimi/chords/QueueManager.java index 2200392..021c0fb 100644 --- a/src/main/java/moe/nekojimi/chords/QueueManager.java +++ b/src/main/java/moe/nekojimi/chords/QueueManager.java @@ -26,6 +26,8 @@ import java.util.function.Consumer; */ public class QueueManager implements Consumer { + + private Song restartingSong = null; private final Queue jukeboxQueue; private Playlist playlist; private MusicHandler handler; @@ -52,6 +54,13 @@ public class QueueManager implements Consumer */ public Song nextSongNeeded() { + // if we're restarting the current song: store, clear, and return it + if (restartingSong != null) + { + Song ret = restartingSong; + restartingSong = null; + return ret; + } // if there's anything in the queue, play that first if (!jukeboxQueue.isEmpty()) { @@ -118,6 +127,12 @@ public class QueueManager implements Consumer public boolean restartSong() { - throw new UnsupportedOperationException("Not supported yet."); + restartingSong = handler.getCurrentSong(); + if (restartingSong != null) + { + handler.playNext(); + return true; + } else + return false; } }