From 9313c9272ec3bb24597822f3aec2412a8cc689dd Mon Sep 17 00:00:00 2001 From: Nekojimi Date: Sun, 21 Apr 2024 16:47:53 +0100 Subject: [PATCH] TrackPlayer: allow retreiving track from player. --- .../java/moe/nekojimi/chords/TrackPlayer.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/main/java/moe/nekojimi/chords/TrackPlayer.java b/src/main/java/moe/nekojimi/chords/TrackPlayer.java index 6081bf0..ff1e74b 100644 --- a/src/main/java/moe/nekojimi/chords/TrackPlayer.java +++ b/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