public class PlaybackThread
extends java.lang.Thread
Modifier and Type | Field and Description |
---|---|
protected javax.sound.sampled.AudioInputStream[] |
audioInputStream |
protected byte[][] |
buffer |
protected byte[] |
datalineBuffer |
static int |
decodedCount |
static java.util.LinkedHashMap<java.io.File,java.io.File> |
decodedFiles |
private java.lang.String |
decodedOutputDir |
static float |
DEFAULT_PROBABILITY_TO_DECODE
Probability to decode a mp3 file to wav
|
(package private) boolean[] |
empty
Flag if channel is empty: in this case, there will be silence on the respective channel
|
protected java.io.File |
file1 |
protected java.io.File |
file2 |
(package private) java.io.File[][] |
files
Files to play
|
(package private) java.lang.String |
id |
protected javax.sound.sampled.SourceDataLine |
line |
protected int |
monoFramesize |
(package private) boolean |
otherChannelAlreadyFinished
(if bRepeat == false): if the first channel's musicfile stops, it is set to true.
If the second channel's musicfile stops, this thread is stopped. |
private java.util.Vector<PlaybackListener> |
playbackListeners |
(package private) java.awt.Point[] |
positions |
(package private) float |
probalityToDecode |
protected boolean |
quitLoop |
static java.util.Random |
rand |
protected boolean |
ready |
(package private) boolean |
repeatShuffle
Flag: if true, then music is played endlessly, alwas repeating.
|
static int |
songCount |
private boolean |
threadSuspended |
(package private) boolean |
updateStats
Flag: if false, no global statistic variable will be updated by this Thread
|
(package private) boolean[] |
waitForDecoder
Flag: if
true , then the respective channel is waiting for a DecoderThread to finish. |
Constructor and Description |
---|
PlaybackThread(java.lang.String id,
PlaybackThreadDataRecord record,
javax.sound.sampled.SourceDataLine line,
boolean repeat,
float probalityToDecode,
boolean updateStats,
java.lang.String decodedOutputDir) |
PlaybackThread(java.lang.String id,
PlaybackThreadDataRecord record,
javax.sound.sampled.SourceDataLine line,
boolean repeat,
float probalityToDecode,
java.lang.String decodedOutputDir) |
PlaybackThread(java.lang.String id,
PlaybackThreadDataRecord record,
javax.sound.sampled.SourceDataLine line,
java.lang.String decodedOutputDir)
Convenience constructur that takes a
PlaybackThreadDataRecord and pulls all data from it to create a new
thread.Note the constructor call that looks quite crazy with all its necessary casts. |
Modifier and Type | Method and Description |
---|---|
boolean |
addPlaybackListener(PlaybackListener listener) |
void |
decodingFailed(int channel,
boolean stats) |
void |
decodingFinished(java.io.File file,
int channel,
boolean stats,
DecoderThread dt) |
javax.sound.sampled.AudioInputStream |
getNextSong(int channel,
boolean stats) |
boolean |
isReady() |
void |
muteChannel(int channel) |
void |
pausePlayback() |
javax.sound.sampled.AudioInputStream |
prepareAudioInputStream(java.io.File file,
int channel,
boolean stats) |
boolean |
removePlaybackListener(PlaybackListener listener) |
void |
resumePlayback() |
void |
run() |
void |
stopPlayback() |
void |
unMuteChannel(int channel) |
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
public static int decodedCount
public static java.util.LinkedHashMap<java.io.File,java.io.File> decodedFiles
public static final float DEFAULT_PROBABILITY_TO_DECODE
public static java.util.Random rand
public static int songCount
protected javax.sound.sampled.AudioInputStream[] audioInputStream
protected byte[][] buffer
protected byte[] datalineBuffer
private java.lang.String decodedOutputDir
boolean[] empty
protected java.io.File file1
protected java.io.File file2
java.io.File[][] files
java.lang.String id
protected javax.sound.sampled.SourceDataLine line
protected int monoFramesize
boolean otherChannelAlreadyFinished
private java.util.Vector<PlaybackListener> playbackListeners
java.awt.Point[] positions
float probalityToDecode
protected boolean quitLoop
protected boolean ready
boolean repeatShuffle
If false, then on each channel there will be played each song in the list, from the first to the last, then exit.
private boolean threadSuspended
boolean updateStats
boolean[] waitForDecoder
true
, then the respective channel is waiting for a DecoderThread
to finish.public PlaybackThread(java.lang.String id, PlaybackThreadDataRecord record, javax.sound.sampled.SourceDataLine line, boolean repeat, float probalityToDecode, boolean updateStats, java.lang.String decodedOutputDir)
public PlaybackThread(java.lang.String id, PlaybackThreadDataRecord record, javax.sound.sampled.SourceDataLine line, boolean repeat, float probalityToDecode, java.lang.String decodedOutputDir)
public PlaybackThread(java.lang.String id, PlaybackThreadDataRecord record, javax.sound.sampled.SourceDataLine line, java.lang.String decodedOutputDir)
PlaybackThreadDataRecord
and pulls all data from it to create a new
thread.public boolean addPlaybackListener(PlaybackListener listener)
public void decodingFailed(int channel, boolean stats)
public void decodingFinished(java.io.File file, int channel, boolean stats, DecoderThread dt)
public javax.sound.sampled.AudioInputStream getNextSong(int channel, boolean stats) throws java.io.IOException, javax.sound.sampled.UnsupportedAudioFileException
java.io.IOException
javax.sound.sampled.UnsupportedAudioFileException
public boolean isReady()
public void muteChannel(int channel)
public void pausePlayback()
public javax.sound.sampled.AudioInputStream prepareAudioInputStream(java.io.File file, int channel, boolean stats) throws java.io.IOException, javax.sound.sampled.UnsupportedAudioFileException
java.io.IOException
javax.sound.sampled.UnsupportedAudioFileException
public boolean removePlaybackListener(PlaybackListener listener)
public void resumePlayback()
public void run()
run
in interface java.lang.Runnable
run
in class java.lang.Thread
public void stopPlayback()
public void unMuteChannel(int channel)