TrackPlayer: allow retreiving track from player.

This commit is contained in:
Nekojimi 2024-04-21 16:47:53 +01:00
parent fd8cb9ebf0
commit 9313c9272e
1 changed files with 12 additions and 6 deletions

View File

@ -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