avignon.handlers
Class MessagePlayer

java.lang.Object
  extended byavignon.handlers.MessagePlayer
All Implemented Interfaces:
java.lang.Runnable

public class MessagePlayer
extends java.lang.Object
implements java.lang.Runnable

Plays Allows the Allows the sequential playing of WAV files started at different times.


Constructor Summary
protected MessagePlayer()
          Protected constructor to be used internally and by subclasses during unit testing.
 
Method Summary
 boolean anyQueuedMessages()
          Allows the programmer to determine if any messages remain in the queue.
static void enqueueAudioMessage(java.lang.String message)
          Addeds a message to the playlist.
protected  javax.sound.sampled.AudioInputStream getAudioInputStream(java.lang.String message)
          Creates an AudioInputStream for a WAV file specified by the parameter.
protected  javax.sound.sampled.Clip getClip()
          Creates a Clip that can be used to play an AudioInputStream.
static MessagePlayer getInstance()
          Allows access to the single instance of the message player.
static java.lang.String getLastEnqueuedMessage()
          Used in unit testing to determine the last message added to the queue.
 void run()
          Run method for Thread.
static void shunt(boolean on)
          Allows the programmer to turn off the actual message playing during unit testing.
 void stop()
          Stops the message playing thread.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MessagePlayer

protected MessagePlayer()
Protected constructor to be used internally and by subclasses during unit testing.

Method Detail

getAudioInputStream

protected javax.sound.sampled.AudioInputStream getAudioInputStream(java.lang.String message)
Creates an AudioInputStream for a WAV file specified by the parameter. Protected to allow overriding for unit testing.

Parameters:
message - File name of the WAV file to be played.
Returns:
An AudioInputStream representing the WAV file.

getClip

protected javax.sound.sampled.Clip getClip()
Creates a Clip that can be used to play an AudioInputStream. Protected to allow overriding during unit tests.

Returns:
A Clip capable of playing a WAV file.

getLastEnqueuedMessage

public static java.lang.String getLastEnqueuedMessage()
Used in unit testing to determine the last message added to the queue.

Returns:
The file name of the last message added to the queue.

enqueueAudioMessage

public static void enqueueAudioMessage(java.lang.String message)
Addeds a message to the playlist. If the system is not shunted, this message will be played when its turn comes up.

Parameters:
message - The file name of the WAV file to play.

shunt

public static void shunt(boolean on)
Allows the programmer to turn off the actual message playing during unit testing.

Parameters:
on - True to turn off message playing.

getInstance

public static MessagePlayer getInstance()
Allows access to the single instance of the message player. Can be changed by setInstance to alter behaviour or during unit testing.

Returns:
The single instance of the MessagePlayer.

run

public void run()
Run method for Thread. Should not be used directly.

Specified by:
run in interface java.lang.Runnable

anyQueuedMessages

public boolean anyQueuedMessages()
Allows the programmer to determine if any messages remain in the queue. Mostly used internally, but is public for unit testing.

Returns:
True if the message queue is not empty.

stop

public void stop()
Stops the message playing thread.


SourceForge.net Logo