speech.sound
Class AudioPlayer

java.lang.Object
  |
  +--speech.sound.AudioPlayer

public class AudioPlayer
extends Object

The AudioPlayer class uses Java's AudioClip interface to play several types of audio clips. You can play AU, AIFF, WAV (PCM only) and MIDI formats.

See Also:
AudioClip

Constructor Summary
AudioPlayer()
          Creates a new AudioPlayer instance.
 
Method Summary
 void clearCache()
          Clears the sound cache.
 Enumeration getCacheKeys()
          Gets the names of the files in the sound cache
 int getCacheSize()
          Gets the size of the sound cache
 AudioClip load(URL soundFileName)
          Loads a sound file into memory, for faster access in later calls.
 void play(URL soundFileName)
          Plays a sound file named in soundFileName.
 void play(URL soundFileName, boolean useCache)
          Plays a sound file named in soundFileName.
 void unload(URL soundFileName)
          Unloads an entry from the sound cache
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AudioPlayer

public AudioPlayer()
Creates a new AudioPlayer instance.
Method Detail

load

public AudioClip load(URL soundFileName)
Loads a sound file into memory, for faster access in later calls. If the sound file has already been loaded into memory, it will not be reloaded.
Parameters:
soundFileName - a URL value of the name of the sound file. This should include the full path.
Returns:
an AudioClip value of the sound file referred to in soundFileName.
See Also:
clearCache()

play

public void play(URL soundFileName)
Plays a sound file named in soundFileName. If the sound file has been previously cached, then the cached sound is played. If the sound file was not previously cached, then it is added to the cache.
Parameters:
soundFileName - a URL value of the name of the sound file. This should include the full path.
See Also:
play(URL, boolean), clearCache()

play

public void play(URL soundFileName,
                 boolean useCache)
Plays a sound file named in soundFileName. If useCache is true, the we first try to use a cached copy (if one exists).
Parameters:
soundFileName - an URL value of the name of the sound file. This should include the full path.
useCache - a boolean value
See Also:
play(URL)

clearCache

public void clearCache()
Clears the sound cache.

unload

public void unload(URL soundFileName)
Unloads an entry from the sound cache
Parameters:
soundFileName - an URL value

getCacheKeys

public Enumeration getCacheKeys()
Gets the names of the files in the sound cache
Returns:
an Enumeration of URL names

getCacheSize

public int getCacheSize()
Gets the size of the sound cache
Returns:
an int value