Package org.openstreetmap.josm.io.audio
Class AudioPlayer
java.lang.Object
java.lang.Thread
org.openstreetmap.josm.io.audio.AudioPlayer
- All Implemented Interfaces:
Runnable,AudioListener
Creates and controls a separate audio player thread.
- Since:
- 12326 (move to new package), 547
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumAudio player command.classPasses information from the control thread to the playing threadstatic enumAudio player result.static enumAudio player state.Nested classes/interfaces inherited from class java.lang.Thread
Thread.UncaughtExceptionHandler -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static AudioPlayerprivate final AudioPlayer.Executeprivate URLprivate SoundPlayerprivate static Class<? extends SoundPlayer>private AudioPlayer.StateFields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static AudioPlayerReturns the singleton object, and if this is the first time, creates it along with the thread to support audiostatic Class<? extends SoundPlayer>Returns the custom sound player class, if any.static voidpause()Pauses the currently playing audio stream.static booleanpaused()Whether or not we are paused.static voidPlays a WAV audio file from the beginning.static voidPlays a WAV audio file from a specified position.static voidPlays a WAV audio file from a specified position at variable speed.static booleanplaying()Whether or not we are playing.voidCalled when a new URL is being played.static doubleposition()How far we are through playing, in seconds.static voidreset()Resets the audio player.voidrun()Starts the thread to actually play the audio, per Thread interface Not to be used as public, though Thread interface doesn't allow it to be made privatestatic voidsetSoundPlayerClass(Class<? extends SoundPlayer> playerClass) Sets the custom sound player class to override default core player.static doublespeed()Speed at which we will play.static URLurl()To get the Url of the playing or recently played audio.Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
-
Field Details
-
audioPlayer
-
state
-
soundPlayerClass
-
soundPlayer
-
playingUrl
-
command
-
-
Constructor Details
-
AudioPlayer
private AudioPlayer()
-
-
Method Details
-
play
Plays a WAV audio file from the beginning. See also the variant which doesn't start at the beginning of the stream- Parameters:
url- The resource to play, which must be a WAV file or stream- Throws:
InterruptedException- thread interruptedIOException- audio fault exception, e.g. can't open stream, unhandleable audio format
-
play
Plays a WAV audio file from a specified position.- Parameters:
url- The resource to play, which must be a WAV file or streamseconds- The number of seconds into the audio to start playing- Throws:
InterruptedException- thread interruptedIOException- audio fault exception, e.g. can't open stream, unhandleable audio format
-
play
public static void play(URL url, double seconds, double speed) throws InterruptedException, IOException Plays a WAV audio file from a specified position at variable speed.- Parameters:
url- The resource to play, which must be a WAV file or streamseconds- The number of seconds into the audio to start playingspeed- Rate at which audio plays (1.0 = real time, > 1 is faster)- Throws:
InterruptedException- thread interruptedIOException- audio fault exception, e.g. can't open stream, unhandleable audio format
-
pause
Pauses the currently playing audio stream. Does nothing if nothing playing.- Throws:
InterruptedException- thread interruptedIOException- audio fault exception, e.g. can't open stream, unhandleable audio format
-
url
To get the Url of the playing or recently played audio.- Returns:
- url - could be null
-
paused
Whether or not we are paused.- Returns:
- boolean whether or not paused
-
playing
Whether or not we are playing.- Returns:
- boolean whether or not playing
-
position
How far we are through playing, in seconds.- Returns:
- double seconds
-
speed
Speed at which we will play.- Returns:
- double, speed multiplier
-
getInstance
Returns the singleton object, and if this is the first time, creates it along with the thread to support audio- Returns:
- the unique instance
-
reset
Resets the audio player. -
run
Starts the thread to actually play the audio, per Thread interface Not to be used as public, though Thread interface doesn't allow it to be made private -
playing
Description copied from interface:AudioListenerCalled when a new URL is being played.- Specified by:
playingin interfaceAudioListener- Parameters:
playingUrl- new URL being played
-
getSoundPlayerClass
Returns the custom sound player class, if any.- Returns:
- the custom sound player class, or
null - Since:
- 14183
-
setSoundPlayerClass
Sets the custom sound player class to override default core player. Must be called before the first audio method invocation.- Parameters:
playerClass- custom sound player class to override default core player- Since:
- 14183
-