Package org.openstreetmap.josm.io.audio
Class JavaSoundPlayer
- java.lang.Object
-
- org.openstreetmap.josm.io.audio.JavaSoundPlayer
-
- All Implemented Interfaces:
SoundPlayer
class JavaSoundPlayer extends java.lang.Object implements SoundPlayer
Legacy sound player based on the Java Sound API. Used on platforms where Java FX is not yet available. It supports only WAV files.- Since:
- 12328
-
-
Field Summary
Fields Modifier and Type Field 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 Summary
Constructors Constructor Description JavaSoundPlayer(double leadIn, double calibration)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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.
-
-
-
Field Detail
-
chunk
private static final int chunk
- See Also:
- Constant Field Values
-
audioInputStream
private javax.sound.sampled.AudioInputStream audioInputStream
-
audioOutputLine
private javax.sound.sampled.SourceDataLine audioOutputLine
-
leadIn
private final double leadIn
-
calibration
private final double calibration
-
bytesPerSecond
private double bytesPerSecond
-
abData
private final byte[] abData
-
position
private double position
-
speed
private double speed
-
listeners
private final ListenerList<AudioListener> listeners
-
-
Constructor Detail
-
JavaSoundPlayer
JavaSoundPlayer(double leadIn, double calibration)
-
-
Method Detail
-
play
public void play(AudioPlayer.Execute command, AudioPlayer.State stateChange, java.net.URL playingUrl) throws AudioException, java.io.IOException
Description copied from interface:SoundPlayer
Ask player to play a new media.- Specified by:
play
in interfaceSoundPlayer
- Parameters:
command
- Command containing media informationstateChange
- the previous stateplayingUrl
- the currently playing URL, if any- Throws:
AudioException
- if an audio error occursjava.io.IOException
- if an I/O error occurs
-
pause
public void pause(AudioPlayer.Execute command, AudioPlayer.State stateChange, java.net.URL playingUrl) throws AudioException, java.io.IOException
Description copied from interface:SoundPlayer
Ask player to pause the current playing media.- Specified by:
pause
in interfaceSoundPlayer
- Parameters:
command
- Command containing media informationstateChange
- the previous stateplayingUrl
- the currently playing URL, if any- Throws:
AudioException
- if an audio error occursjava.io.IOException
- if an I/O error occurs
-
playing
public boolean playing(AudioPlayer.Execute command) throws AudioException, java.io.IOException, java.lang.InterruptedException
Description copied from interface:SoundPlayer
Method called when a media is being played.- Specified by:
playing
in interfaceSoundPlayer
- Parameters:
command
- Command containing media information- Returns:
true
if the playing call was blocking, and the playback is finished when this method returns- Throws:
AudioException
- if an audio error occursjava.io.IOException
- if an I/O error occursjava.lang.InterruptedException
- if the play is interrupted
-
position
public double position()
Description copied from interface:SoundPlayer
Returns the media playback position, in seconds.- Specified by:
position
in interfaceSoundPlayer
- Returns:
- the media playback position, in seconds
-
speed
public double speed()
Description copied from interface:SoundPlayer
Returns the media playback speed ratio.- Specified by:
speed
in interfaceSoundPlayer
- Returns:
- the media playback speed ratio
-
addAudioListener
public void addAudioListener(AudioListener listener)
Description copied from interface:SoundPlayer
Adds a listener that will be notified of audio playback events.- Specified by:
addAudioListener
in interfaceSoundPlayer
- Parameters:
listener
- audio listener
-
-