TrackPlayer: allow retreiving track from player.

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

Loading…
Cancel
Save