|
|
|
@ -42,22 +42,9 @@ public class MusicHandler implements AudioSendHandler, Closeable, Consumer<Track |
|
|
|
|
// private TrackPlayer player;
|
|
|
|
|
private final List<TrackPlayer> playingTracks = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
private File debugOutFile; |
|
|
|
|
private BufferedOutputStream debugOut; |
|
|
|
|
|
|
|
|
|
public MusicHandler() |
|
|
|
|
{ |
|
|
|
|
try |
|
|
|
|
{ |
|
|
|
|
debugOutFile = new File("debug.wav"); |
|
|
|
|
if (debugOutFile.exists()) |
|
|
|
|
debugOutFile.delete(); |
|
|
|
|
debugOutFile.createNewFile(); |
|
|
|
|
debugOut = new BufferedOutputStream(new FileOutputStream(debugOutFile)); |
|
|
|
|
} catch (IOException ex) |
|
|
|
|
{ |
|
|
|
|
Logger.getLogger(MusicHandler.class.getName()).log(Level.SEVERE, null, ex); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@ -84,6 +71,9 @@ public class MusicHandler implements AudioSendHandler, Closeable, Consumer<Track |
|
|
|
|
|
|
|
|
|
public boolean play(Track track, boolean immediate) |
|
|
|
|
{ |
|
|
|
|
if (track == currentTrack) |
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
if (immediate) |
|
|
|
|
{ |
|
|
|
|
System.out.println("Immediate next - clearing buffer"); |
|
|
|
@ -103,7 +93,6 @@ public class MusicHandler implements AudioSendHandler, Closeable, Consumer<Track |
|
|
|
|
nowPlayingConsumer.accept(currentTrack); |
|
|
|
|
if (currentTrack == null) |
|
|
|
|
{ |
|
|
|
|
debugOut.flush(); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
System.out.println("Playing track " + currentTrack.getLocation().getAbsolutePath()); |
|
|
|
@ -124,6 +113,9 @@ public class MusicHandler implements AudioSendHandler, Closeable, Consumer<Track |
|
|
|
|
|
|
|
|
|
public boolean requestTrack() |
|
|
|
|
{ |
|
|
|
|
if (isPlaying()) |
|
|
|
|
System.out.println("How did we get here?"); |
|
|
|
|
System.out.println("MusicHandler requesting track..."); |
|
|
|
|
List<QueueThing.Promise<Track, Track>> request = queueManager.request(1, this); |
|
|
|
|
// Queuemanager will syncronously attempt to call play()
|
|
|
|
|
return !playingTracks.isEmpty(); |
|
|
|
|