comirva.audio
Class AudioPlayer

java.lang.Object
  extended by java.lang.Thread
      extended by comirva.audio.AudioPlayer
All Implemented Interfaces:
Runnable

public class AudioPlayer
extends Thread

This class implements methods for reading and playing audio files. Its ability to read audio files of different formats depends on the installed Java Sound implementations. To obtain plug-ins for different file formats, see e.g. http://tritonus.org/


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
AudioPlayer(AudioInputStream ais)
          Creates a new instance of the AudioPlayer.
AudioPlayer(File audioFile)
          Creates a new instance of the AudioPlayer.
 
Method Summary
(package private)  File getAudioFile()
           
 boolean isPaused()
          Returns whether the audio player is paused.
 boolean isStopped()
          Returns whether the audio player is stopped or not.
 void run()
          This method is called when the thread is started.
 void setPaused(boolean isPaused)
          Sets the state of the audio player to "paused" or "not paused" depending on the value of the argument isPaused.
 void setStopped(boolean isStopped)
          Sets the state of the audio player to "stopped" or "not stopped" depending on the value of the argument isStopped.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, 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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AudioPlayer

public AudioPlayer(File audioFile)
Creates a new instance of the AudioPlayer.

Parameters:
audioFile - the audio file to be played

AudioPlayer

public AudioPlayer(AudioInputStream ais)
Creates a new instance of the AudioPlayer.

Parameters:
ais - the AudioInputStream which is played
Method Detail

getAudioFile

File getAudioFile()

run

public void run()
This method is called when the thread is started. The audio file is opened, the content read and played.

Specified by:
run in interface Runnable
Overrides:
run in class Thread
See Also:
Runnable.run()

isPaused

public boolean isPaused()
Returns whether the audio player is paused.

Returns:
a boolean indicating if the audio player is paused

setPaused

public void setPaused(boolean isPaused)
Sets the state of the audio player to "paused" or "not paused" depending on the value of the argument isPaused.

Parameters:
isPaused - a boolean indicating if the audio player should pause or not

isStopped

public boolean isStopped()
Returns whether the audio player is stopped or not.

Returns:
a boolean indicating if the audio player is stopped

setStopped

public void setStopped(boolean isStopped)
Sets the state of the audio player to "stopped" or "not stopped" depending on the value of the argument isStopped.

Parameters:
isStopped - a boolean indicating if the audio player should stop or not