TrackPlayer: allow retreiving track from player.

soundboard
Nekojimi 4 weeks ago
parent fd8cb9ebf0
commit 9313c9272e
  1. 18
      src/main/java/moe/nekojimi/chords/TrackPlayer.java

@ -31,13 +31,15 @@ public class TrackPlayer implements Closeable
private static final int RETRY_DELAY = 100;
private final CircularByteBuffer audioBuffer = new CircularByteBuffer(3840 * 1024);
private final Track track;
private final AudioInputStream input;
private boolean arrayErr = false; // supresses ArrayIndexOutOfBoundsException after the first time, to prevent spam
public TrackPlayer(Track track) throws UnsupportedAudioFileException, IOException
public TrackPlayer(Track t) throws UnsupportedAudioFileException, IOException
{
track = t;
AudioInputStream in = null;
AudioFormat decodedFormat = null;
int retry = 0;
@ -72,11 +74,11 @@ public class TrackPlayer implements Closeable
fillBuffer(false);
}
public TrackPlayer(AudioInputStream input) throws IOException
{
this.input = input;
fillBuffer(false);
}
// public TrackPlayer(AudioInputStream input) throws IOException
// {
// this.input = input;
// fillBuffer(false);
// }
public boolean has(int byteCount)
{
@ -168,6 +170,10 @@ public class TrackPlayer implements Closeable
input.close(); //q
}
public Track getTrack()
{
return track;
}
public static class OutOfInputException extends RuntimeException

Loading…
Cancel
Save