|
|
@ -42,22 +42,9 @@ public class MusicHandler implements AudioSendHandler, Closeable, Consumer<Track |
|
|
|
// private TrackPlayer player;
|
|
|
|
// private TrackPlayer player;
|
|
|
|
private final List<TrackPlayer> playingTracks = new ArrayList<>(); |
|
|
|
private final List<TrackPlayer> playingTracks = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
|
|
private File debugOutFile; |
|
|
|
|
|
|
|
private BufferedOutputStream debugOut; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public MusicHandler() |
|
|
|
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 |
|
|
|
@Override |
|
|
@ -84,6 +71,9 @@ public class MusicHandler implements AudioSendHandler, Closeable, Consumer<Track |
|
|
|
|
|
|
|
|
|
|
|
public boolean play(Track track, boolean immediate) |
|
|
|
public boolean play(Track track, boolean immediate) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
if (track == currentTrack) |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
if (immediate) |
|
|
|
if (immediate) |
|
|
|
{ |
|
|
|
{ |
|
|
|
System.out.println("Immediate next - clearing buffer"); |
|
|
|
System.out.println("Immediate next - clearing buffer"); |
|
|
@ -103,7 +93,6 @@ public class MusicHandler implements AudioSendHandler, Closeable, Consumer<Track |
|
|
|
nowPlayingConsumer.accept(currentTrack); |
|
|
|
nowPlayingConsumer.accept(currentTrack); |
|
|
|
if (currentTrack == null) |
|
|
|
if (currentTrack == null) |
|
|
|
{ |
|
|
|
{ |
|
|
|
debugOut.flush(); |
|
|
|
|
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
System.out.println("Playing track " + currentTrack.getLocation().getAbsolutePath()); |
|
|
|
System.out.println("Playing track " + currentTrack.getLocation().getAbsolutePath()); |
|
|
@ -124,6 +113,9 @@ public class MusicHandler implements AudioSendHandler, Closeable, Consumer<Track |
|
|
|
|
|
|
|
|
|
|
|
public boolean requestTrack() |
|
|
|
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); |
|
|
|
List<QueueThing.Promise<Track, Track>> request = queueManager.request(1, this); |
|
|
|
// Queuemanager will syncronously attempt to call play()
|
|
|
|
// Queuemanager will syncronously attempt to call play()
|
|
|
|
return !playingTracks.isEmpty(); |
|
|
|
return !playingTracks.isEmpty(); |
|
|
|