|
|
|
@ -26,6 +26,8 @@ import java.util.function.Consumer; |
|
|
|
|
*/ |
|
|
|
|
public class QueueManager implements Consumer<Song> |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
private Song restartingSong = null; |
|
|
|
|
private final Queue<Song> jukeboxQueue; |
|
|
|
|
private Playlist playlist; |
|
|
|
|
private MusicHandler handler; |
|
|
|
@ -52,6 +54,13 @@ public class QueueManager implements Consumer<Song> |
|
|
|
|
*/ |
|
|
|
|
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<Song> |
|
|
|
|
|
|
|
|
|
public boolean restartSong() |
|
|
|
|
{ |
|
|
|
|
throw new UnsupportedOperationException("Not supported yet."); |
|
|
|
|
restartingSong = handler.getCurrentSong(); |
|
|
|
|
if (restartingSong != null) |
|
|
|
|
{ |
|
|
|
|
handler.playNext(); |
|
|
|
|
return true; |
|
|
|
|
} else |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|