public abstract class SoundPlayer extends Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
SoundPlayer.Frob
A control for sounds.
|
static class |
SoundPlayer.SoundType
Create instances of this for your application to differentiate
between different types of sounds.
|
| Modifier and Type | Field and Description |
|---|---|
static SoundPlayer.SoundType |
DEFAULT
The default sound type.
|
static float |
PAN_CENTER
A pan value indicating that a sound should play from center.
|
static float |
PAN_LEFT
A pan value indicating that a sound should play from the left only.
|
static float |
PAN_RIGHT
A pan value indicating that a sound should play from the right only.
|
| Constructor and Description |
|---|
SoundPlayer() |
| Modifier and Type | Method and Description |
|---|---|
void |
addSoundEnabledObserver(SoundEnabledObserver listener) |
float |
getClipVolume()
Get the volume for all sound clips.
|
boolean |
isEnabled(SoundPlayer.SoundType type)
Is the specified soundtype enabled?
|
abstract void |
lock(String pkgPath,
String... keys)
Optionally lock each of these keys prior to playing, to guarantee that it will be quickly
available for playing.
|
SoundPlayer.Frob |
loop(SoundPlayer.SoundType type,
String pkgPath,
String key)
Loop the specified sound, stopping as quickly as possible when stop is called.
|
SoundPlayer.Frob |
loop(SoundPlayer.SoundType type,
String pkgPath,
String key,
float pan)
Loop the specified sound, stopping as quickly as possible when stop is called.
|
boolean |
play(SoundPlayer.SoundType type,
String pkgPath,
String key)
Play the specified sound as the specified type of sound, immediately.
|
boolean |
play(SoundPlayer.SoundType type,
String pkgPath,
String key,
float pan)
Play the specified sound as the specified type of sound, immediately, with the specified
pan value.
|
boolean |
play(SoundPlayer.SoundType type,
String pkgPath,
String key,
int delay)
Play the specified sound after the specified delay.
|
boolean |
play(SoundPlayer.SoundType type,
String pkgPath,
String key,
int delay,
float pan)
Play the specified sound after the specified delay.
|
void |
removeSoundEnabledObserver(SoundEnabledObserver listener) |
void |
setClipVolume(float vol)
Sets the volume for all sound clips.
|
void |
setEnabled(SoundPlayer.SoundType type,
boolean enabled)
Turns on or off the specified sound type.
|
boolean |
shouldPlay(SoundPlayer.SoundType type)
Is sound on and is the specified soundtype enabled?
|
abstract void |
shutdown()
Shut the damn thing off.
|
String |
summarizeState()
Returns a string summarizing our volume settings and disabled sound types.
|
abstract void |
unlock(String pkgPath,
String... keys)
Unlock the specified sounds so that its resources can be freed.
|
public static final float PAN_LEFT
public static final float PAN_RIGHT
public static final float PAN_CENTER
public static final SoundPlayer.SoundType DEFAULT
public abstract void shutdown()
public String summarizeState()
public boolean isEnabled(SoundPlayer.SoundType type)
public boolean shouldPlay(SoundPlayer.SoundType type)
public void setEnabled(SoundPlayer.SoundType type, boolean enabled)
public void addSoundEnabledObserver(SoundEnabledObserver listener)
public void removeSoundEnabledObserver(SoundEnabledObserver listener)
public void setClipVolume(float vol)
vol - a volume parameter between 0f and 1f, inclusive.public float getClipVolume()
public abstract void lock(String pkgPath, String... keys)
public abstract void unlock(String pkgPath, String... keys)
public boolean play(SoundPlayer.SoundType type, String pkgPath, String key)
public boolean play(SoundPlayer.SoundType type, String pkgPath, String key, float pan)
pan - a value from -1f (all left) to +1f (all right).public boolean play(SoundPlayer.SoundType type, String pkgPath, String key, int delay)
delay - the delay in milliseconds.public boolean play(SoundPlayer.SoundType type, String pkgPath, String key, int delay, float pan)
delay - the delay in milliseconds.pan - a value from -1f (all left) to +1f (all right).public SoundPlayer.Frob loop(SoundPlayer.SoundType type, String pkgPath, String key)
public SoundPlayer.Frob loop(SoundPlayer.SoundType type, String pkgPath, String key, float pan)
Copyright © 2015. All rights reserved.