| java.lang.Object | |
| ↳ | sofia.audio.SoundPlayer |
This class provides a simple interface for playing basic sounds (such as notification chimes or game play effects) in a Sofia application.
| Public Constructors | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
|
SoundPlayer(Context context)
Creates a new SoundPlayer with given context (which is an activity or
screen).
| |||||||||||
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| void |
loadSound(String name)
Attempts to load the sound file with the given name by first checking
for a resource with the matching name in res/raw, and if it is not found
there then it is looked up in the assets/sounds folder.
| ||||||||||
| void |
pause(String name)
Pauses the sound with the specified name, if it is playing.
| ||||||||||
| void |
pauseAll()
Pauses all currently playing sounds.
| ||||||||||
| void |
play(String name, int loopCount)
Plays the sound with the specified name, repeating it a given number of
times.
| ||||||||||
| void |
play(String name)
Plays the sound with the specified name once.
| ||||||||||
| void |
playForever(String name)
Plays the sound with the specified name, repeating it forever (until a
method such as
pause(String) or stop(String) is
called). | ||||||||||
| void |
resume(String name)
Resumes the sound with the specified name, if it is paused.
| ||||||||||
| void |
resumeAll()
Resumes all sounds that were playing when
pauseAll() was
called. | ||||||||||
| void |
stop(String name)
Stops the sound with the specified name, if it is currently playing.
| ||||||||||
|
[Expand]
Inherited Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
Creates a new SoundPlayer with given context (which is an activity or screen).
| context | the context |
|---|
Attempts to load the sound file with the given name by first checking for a resource with the matching name in res/raw, and if it is not found there then it is looked up in the assets/sounds folder.
| name | the name of the sound file, without the file extension |
|---|
| IllegalArgumentException | if a sound with the given name cannot be located |
|---|
Pauses the sound with the specified name, if it is playing. If the sound is not playing, nothing happens.
| name | the name of the sound to pause |
|---|
Pauses all currently playing sounds. Call resumeAll() to start
them again where they left off.
Plays the sound with the specified name, repeating it a given number of times.
| name | the name of the sound to play |
|---|---|
| loopCount | the number of times to repeat the sound |
Plays the sound with the specified name once.
| name | the name of the sound to play |
|---|
Plays the sound with the specified name, repeating it forever (until a
method such as pause(String) or stop(String) is
called).
| name | the name of the sound to play |
|---|
Resumes the sound with the specified name, if it is paused. If the sound is not paused (or was never loaded), nothing happens.
| name | the name of the sound to resume |
|---|
Stops the sound with the specified name, if it is currently playing. If the sound is not currently playing, nothing happens.
| name | the name of the sound to stop |
|---|