org.openstreetmap.josm.tools
Class AudioPlayer

java.lang.Object
  extended by java.lang.Thread
      extended by org.openstreetmap.josm.tools.AudioPlayer
All Implemented Interfaces:
java.lang.Runnable

public class AudioPlayer
extends java.lang.Thread

Creates and controls a separate audio player thread.


Nested Class Summary
private static class AudioPlayer.Command
           
private  class AudioPlayer.Execute
          Passes information from the control thread to the playing thread
private static class AudioPlayer.Result
           
private static class AudioPlayer.State
           
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
private static AudioPlayer audioPlayer
           
private  double bytesPerSecond
           
private  double calibration
           
private static long chunk
           
private  AudioPlayer.Execute command
           
private  double leadIn
           
private  java.net.URL playingUrl
           
private  double position
           
private  double speed
           
private  AudioPlayer.State state
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
private AudioPlayer()
           
 
Method Summary
static void audioMalfunction(java.lang.Exception ex)
           
private static AudioPlayer get()
          gets the singleton object, and if this is the first time, creates it along with the thread to support audio
static void pause()
          Pauses the currently playing audio stream.
static boolean paused()
          Whether or not we are paused.
static void play(java.net.URL url)
          Plays a WAV audio file from the beginning.
static void play(java.net.URL url, double seconds)
          Plays a WAV audio file from a specified position.
static void play(java.net.URL url, double seconds, double speed)
          Plays a WAV audio file from a specified position at variable speed.
static boolean playing()
          Whether or not we are playing.
static double position()
          How far we are through playing, in seconds.
static void reset()
           
 void 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
static double speed()
          Speed at which we will play.
static java.net.URL url()
          To get the Url of the playing or recently played audio.
 
Methods inherited from class java.lang.Thread
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
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

audioPlayer

private static AudioPlayer audioPlayer

state

private AudioPlayer.State state

playingUrl

private java.net.URL playingUrl

leadIn

private double leadIn

calibration

private double calibration

position

private double position

bytesPerSecond

private double bytesPerSecond

chunk

private static long chunk

speed

private double speed

command

private AudioPlayer.Execute command
Constructor Detail

AudioPlayer

private AudioPlayer()
Method Detail

play

public static void play(java.net.URL url)
                 throws java.lang.Exception
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:
audio - fault exception, e.g. can't open stream, unhandleable audio format
java.lang.Exception

play

public static void play(java.net.URL url,
                        double seconds)
                 throws java.lang.Exception
Plays a WAV audio file from a specified position.

Parameters:
url - The resource to play, which must be a WAV file or stream
seconds - The number of seconds into the audio to start playing
Throws:
audio - fault exception, e.g. can't open stream, unhandleable audio format
java.lang.Exception

play

public static void play(java.net.URL url,
                        double seconds,
                        double speed)
                 throws java.lang.Exception
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 stream
seconds - The number of seconds into the audio to start playing
speed - Rate at which audio playes (1.0 = real time, > 1 is faster)
Throws:
audio - fault exception, e.g. can't open stream, unhandleable audio format
java.lang.Exception

pause

public static void pause()
                  throws java.lang.Exception
Pauses the currently playing audio stream. Does nothing if nothing playing.

Throws:
audio - fault exception, e.g. can't open stream, unhandleable audio format
java.lang.Exception

url

public static java.net.URL url()
To get the Url of the playing or recently played audio.

Returns:
url - could be null

paused

public static boolean paused()
Whether or not we are paused.

Returns:
boolean whether or not paused

playing

public static boolean playing()
Whether or not we are playing.

Returns:
boolean whether or not playing

position

public static double position()
How far we are through playing, in seconds.

Returns:
double seconds

speed

public static double speed()
Speed at which we will play.

Returns:
double, speed multiplier

get

private static AudioPlayer get()
gets the singleton object, and if this is the first time, creates it along with the thread to support audio


reset

public static void reset()

run

public void 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

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

audioMalfunction

public static void audioMalfunction(java.lang.Exception ex)


JOSM