|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcage.audio.Sound
public class Sound
The sound class represents a sound data file and contains a player for that file. Currently the only format supported is MP3 via the JLayer library. Calling play will create a thread which reads the file and sends it to the sound card. The player in this thread is assigned to the player member field. If loop is true, when the file ends it will be opened again and played again. Calling stop will close the player and end the sound playing. If player is already assigned, that player is closed when play is called. This limits a sound to only one currently playing player at once. We did this so the script would not have to track instances of players. TODO:Removing this limit in some clean way should be a goal for future versions.
Constructor Summary | |
---|---|
Sound(java.lang.String fileName)
Creates a Sound which will load from the specifed filename |
|
Sound(java.lang.String name,
java.lang.String fileName,
boolean loop)
Creteas a sound with the specified resource name, fileName and looping option |
Method Summary | |
---|---|
java.lang.String |
getFileName()
Returns the name of the file this sound is loaded from |
boolean |
getLoop()
Returns true if this sound will loop when played |
java.lang.String |
getName()
Returns the resource name of the sound |
void |
play()
Creates a new player and starts playback in a thread. |
void |
setLoop(boolean loop)
Sets if this sound should loop or not. |
void |
stop()
If a player has been created, close the player. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Sound(java.lang.String fileName)
fileName
- the file to loadpublic Sound(java.lang.String name, java.lang.String fileName, boolean loop)
name
- name of the soundfileName
- the file to loadloop
- if the sound should loop or notMethod Detail |
---|
public void play()
public void stop()
public java.lang.String getName()
public java.lang.String getFileName()
public boolean getLoop()
public void setLoop(boolean loop)
loop
- true if the sound should looppublic java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |