|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--nu.dll.mm.Sound
A very simple generic sound clip API. As of now only useful for smaller sound collections, as each loaded sounds allocates its own channel and keeps it until unloaded. This also means that each sound clip can only be played once concurrently. The playSound() methods are asyncronous (they will return as soon as the sound clip has started playing). The loadSound() methods are, however, synchronous and will not return until the audio clip has been loaded into memory.
| Constructor Summary | |
Sound()
Created a normal sound object. |
|
Sound(boolean enabled)
If the enabled parameter is false,
the audio subsystem will never be used and all methods in
this class will be dummies. |
|
| Method Summary | |
boolean |
isEnabled()
Returns true if this Sound object is capable of playing audio, false otherwise. |
boolean |
isMuted()
Returns true if this Sound object has been muted by the mute() method, false otherwise. |
void |
loadSound(java.io.File f,
java.lang.String key)
Loads a sound clip from the file represented by given File object. |
void |
loadSound(java.io.InputStream is,
java.lang.String key)
Loads an uncompressed sound clip (in a supported format such as WAV or AU). |
void |
loadSound(java.io.InputStream is,
java.lang.String key,
boolean gzipped)
Loads a sound clip of a supported format such as WAV or AU from the given InputStream. |
void |
loadSounds(java.io.InputStream is)
Reads a property list from the input stream and loads the audio resources specified therein. |
void |
mute()
Stops all sounds and prevents sounds from be played until unmute() is called. |
void |
playSound(java.lang.String key)
Plays the sound with the given label. |
void |
playSound(java.lang.String key,
int loop)
Please the sound with the given label, perhaps repeatedly. |
void |
playSound(java.lang.String key,
int loop,
boolean restart)
Please the sound with the given label, perhaps repeatedly. |
void |
stopAllSounds()
Stops all currently playing sound clips. |
void |
stopSound(java.lang.String key)
Stops a sound clip if it is playing. |
void |
unloadSound(java.lang.String key)
Closes a sound clip's resources and dereferences it. |
void |
unmute()
If mute() has been called, re-enabled sound playing. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public Sound()
public Sound(boolean enabled)
enabled parameter is false,
the audio subsystem will never be used and all methods in
this class will be dummies.| Method Detail |
public void loadSounds(java.io.InputStream is)
throws java.io.IOException
Properties.load(InputStream)
public void loadSound(java.io.File f,
java.lang.String key)
throws java.io.IOException
public void loadSound(java.io.InputStream is,
java.lang.String key)
throws java.io.IOException
public void loadSound(java.io.InputStream is,
java.lang.String key,
boolean gzipped)
throws java.io.IOException
is - The InputStream object to load the sound data fromkey - The label to store the sound clip withgzipped - if true, the stream will be uncompressed before passed to the audio subsystem.public void playSound(java.lang.String key)
key - The label of the sound to play.
public void playSound(java.lang.String key,
int loop)
key - The label of the sound to play.loop - an integer specifying how many times to loop the clip (i.e. 1 plays the clip twice).
public void playSound(java.lang.String key,
int loop,
boolean restart)
key - The label of the sound to play.loop - an integer specifying how many times to loop the clip (i.e. 1 plays the clip twice).restart - if false, the given clip does not restart if it is already playing.public void stopSound(java.lang.String key)
public void stopAllSounds()
public void unloadSound(java.lang.String key)
public void mute()
public void unmute()
mute() has been called, re-enabled sound playing.public boolean isEnabled()
true if this Sound object is capable of playing audio, false otherwise.public boolean isMuted()
true if this Sound object has been muted by the mute() method, false otherwise.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||