public class GreenfootSound
extends java.lang.Object
Most files of the following formats are supported: AIFF, AU, WAV, MP3 and MIDI.
Constructor and Description |
---|
GreenfootSound(java.lang.String filename)
Creates a new sound from the given file.
|
Modifier and Type | Method and Description |
---|---|
int |
getVolume()
Get the current volume of the sound, between 0 (off) and 100 (loudest.)
|
boolean |
isPlaying()
True if the sound is currently playing.
|
void |
pause()
Pauses the current sound if it is currently playing.
|
void |
play()
Start playing this sound.
|
void |
playLoop()
Play this sound repeatedly in a loop.
|
void |
setVolume(int level)
Set the current volume of the sound between 0 (off) and 100 (loudest.)
|
void |
stop()
Stop playing this sound if it is currently playing.
|
java.lang.String |
toString()
Returns a string representation of this sound containing the name of the
file and whether it is currently playing or not.
|
public GreenfootSound(java.lang.String filename)
filename
- Typically the name of a file in the sounds directory in
the project directory.public void play()
public void playLoop()
public void stop()
public void pause()
Make sure that this is really the method you want. If possible, you
should always use stop()
, because the resources can be released
after calling stop()
. The resources for the sound will not be
released while it is paused.
stop()
public boolean isPlaying()
public int getVolume()
public void setVolume(int level)
level
- the level to set the sound volume to.public java.lang.String toString()
toString
in class java.lang.Object