java.lang.Runnable
public class AudioPlayer
extends java.lang.Object
implements java.lang.Runnable
Modifier and Type | Field | Description |
---|---|---|
private float |
gain |
|
private javax.sound.sampled.LineEvent.Type |
intendetState |
|
private javax.sound.sampled.SourceDataLine |
line |
|
private java.lang.Object |
listenerLock |
|
private java.util.List<javax.sound.sampled.LineListener> |
listeners |
|
private static org.apache.logging.log4j.Logger |
logger |
|
private int |
loop |
|
static int |
LOOP_FOREVER |
|
private float |
maxGain |
|
private float |
minGain |
|
private javax.sound.sampled.Mixer.Info |
mixer |
|
private java.util.Queue<javax.sound.sampled.AudioInputStream> |
nextStream |
|
private java.util.List<PlaybackListener> |
playbackListeners |
|
private Sound |
sound |
|
private javax.sound.sampled.AudioInputStream |
stream |
|
private java.lang.Thread |
thread |
Constructor | Description |
---|---|
AudioPlayer(Sound sound,
javax.sound.sampled.Mixer.Info mixer) |
Modifier and Type | Method | Description |
---|---|---|
void |
addLineListener(javax.sound.sampled.LineListener listener) |
|
void |
addPlaybackListener(PlaybackListener listener) |
|
void |
cleanup() |
|
void |
close() |
|
private static float |
decibelToLinear(float dB) |
|
private void |
fireLineEvent(javax.sound.sampled.LineEvent evnt) |
|
private void |
firePlaybackEvent(boolean start) |
|
java.lang.String |
getAudioFile() |
|
private javax.sound.sampled.AudioInputStream |
getAudioStream(java.lang.String file) |
|
javax.sound.sampled.Control |
getControl(javax.sound.sampled.Control.Type control) |
|
javax.sound.sampled.Control[] |
getControls() |
|
float |
getGain() |
|
float |
getMaxGain() |
|
float |
getMinGain() |
|
Sound |
getSound() |
|
void |
initNextStream() |
|
boolean |
isActive() |
|
boolean |
isOpen() |
|
private static float |
linearToDecibel(float linear) |
|
void |
loop(int loops) |
|
void |
open() |
|
void |
removeLineListener(javax.sound.sampled.LineListener listener) |
|
void |
removePlaybackListener(PlaybackListener listener) |
|
void |
reset() |
|
void |
run() |
|
void |
setGain(float gain) |
|
void |
start() |
|
void |
stop(boolean async) |
private static org.apache.logging.log4j.Logger logger
public static int LOOP_FOREVER
private Sound sound
private int loop
private java.util.List<PlaybackListener> playbackListeners
private java.util.List<javax.sound.sampled.LineListener> listeners
private java.lang.Object listenerLock
private javax.sound.sampled.SourceDataLine line
private javax.sound.sampled.Mixer.Info mixer
private java.lang.Thread thread
private javax.sound.sampled.AudioInputStream stream
private java.util.Queue<javax.sound.sampled.AudioInputStream> nextStream
private javax.sound.sampled.LineEvent.Type intendetState
private float maxGain
private float minGain
private float gain
public AudioPlayer(Sound sound, javax.sound.sampled.Mixer.Info mixer)
public void addLineListener(javax.sound.sampled.LineListener listener)
public void removeLineListener(javax.sound.sampled.LineListener listener)
public void addPlaybackListener(PlaybackListener listener)
public void removePlaybackListener(PlaybackListener listener)
public void open() throws java.io.IOException, javax.sound.sampled.LineUnavailableException, javax.sound.sampled.UnsupportedAudioFileException
java.io.IOException
javax.sound.sampled.LineUnavailableException
javax.sound.sampled.UnsupportedAudioFileException
private javax.sound.sampled.AudioInputStream getAudioStream(java.lang.String file) throws java.io.IOException, javax.sound.sampled.UnsupportedAudioFileException
java.io.IOException
javax.sound.sampled.UnsupportedAudioFileException
public boolean isOpen()
public boolean isActive()
public void start()
public void stop(boolean async)
public void close()
private static float linearToDecibel(float linear)
private static float decibelToLinear(float dB)
public void loop(int loops)
public javax.sound.sampled.Control[] getControls()
public java.lang.String getAudioFile()
public Sound getSound()
public javax.sound.sampled.Control getControl(javax.sound.sampled.Control.Type control)
public void run()
run
in interface java.lang.Runnable
public void reset() throws java.io.IOException, javax.sound.sampled.UnsupportedAudioFileException
java.io.IOException
javax.sound.sampled.UnsupportedAudioFileException
private void fireLineEvent(javax.sound.sampled.LineEvent evnt)
private void firePlaybackEvent(boolean start)
public void initNextStream()
public float getMaxGain()
public float getMinGain()
public void setGain(float gain)
public float getGain()
public void cleanup()