class JavaSoundPlayer extends java.lang.Object implements SoundPlayer
Modifier and Type | Field and Description |
---|---|
private byte[] |
abData |
private javax.sound.sampled.AudioInputStream |
audioInputStream |
private javax.sound.sampled.SourceDataLine |
audioOutputLine |
private double |
bytesPerSecond |
private double |
calibration |
private static int |
chunk |
private double |
leadIn |
private ListenerList<AudioListener> |
listeners |
private double |
position |
private double |
speed |
Constructor and Description |
---|
JavaSoundPlayer(double leadIn,
double calibration) |
Modifier and Type | Method and Description |
---|---|
void |
addAudioListener(AudioListener listener)
Adds a listener that will be notified of audio playback events.
|
void |
pause(AudioPlayer.Execute command,
AudioPlayer.State stateChange,
java.net.URL playingUrl)
Ask player to pause the current playing media.
|
void |
play(AudioPlayer.Execute command,
AudioPlayer.State stateChange,
java.net.URL playingUrl)
Ask player to play a new media.
|
boolean |
playing(AudioPlayer.Execute command)
Method called when a media is being played.
|
double |
position()
Returns the media playback position, in seconds.
|
double |
speed()
Returns the media playback speed ratio.
|
private static int chunk
private javax.sound.sampled.AudioInputStream audioInputStream
private javax.sound.sampled.SourceDataLine audioOutputLine
private final double leadIn
private final double calibration
private double bytesPerSecond
private final byte[] abData
private double position
private double speed
private final ListenerList<AudioListener> listeners
JavaSoundPlayer(double leadIn, double calibration)
public void play(AudioPlayer.Execute command, AudioPlayer.State stateChange, java.net.URL playingUrl) throws AudioException, java.io.IOException
SoundPlayer
play
in interface SoundPlayer
command
- Command containing media informationstateChange
- the previous stateplayingUrl
- the currently playing URL, if anyAudioException
- if an audio error occursjava.io.IOException
- if an I/O error occurspublic void pause(AudioPlayer.Execute command, AudioPlayer.State stateChange, java.net.URL playingUrl) throws AudioException, java.io.IOException
SoundPlayer
pause
in interface SoundPlayer
command
- Command containing media informationstateChange
- the previous stateplayingUrl
- the currently playing URL, if anyAudioException
- if an audio error occursjava.io.IOException
- if an I/O error occurspublic boolean playing(AudioPlayer.Execute command) throws AudioException, java.io.IOException, java.lang.InterruptedException
SoundPlayer
playing
in interface SoundPlayer
command
- Command containing media informationtrue
if the playing call was blocking, and the playback is finished when this method returnsAudioException
- if an audio error occursjava.io.IOException
- if an I/O error occursjava.lang.InterruptedException
- if the play is interruptedpublic double position()
SoundPlayer
position
in interface SoundPlayer
public double speed()
SoundPlayer
speed
in interface SoundPlayer
public void addAudioListener(AudioListener listener)
SoundPlayer
addAudioListener
in interface SoundPlayer
listener
- audio listener