public class SoundManager
extends java.lang.Thread
Modifier and Type | Field and Description |
---|---|
protected static float |
DEFAULT_MEDIA_VOLUME |
protected AudioManager |
mAudioManager |
protected Context |
mContext |
protected Handler |
mHandler |
protected boolean |
mMediaEnabled |
protected MediaPlayer |
mMediaPlayer |
protected boolean |
mMediaPrepared |
protected float |
mMediaVolume |
protected boolean |
mSoundEnabled |
protected |
mSoundMap |
protected SoundPool |
mSoundPool |
protected SparseIntArray |
mStreamIds |
protected static java.lang.String |
TAG |
Constructor and Description |
---|
SoundManager(Context context,
int maxStream) |
Modifier and Type | Method and Description |
---|---|
void |
dispose() |
Context |
getContext() |
Soundable |
getSound(int key)
Find a sound by Key
|
Soundable |
getSoundByID(int soundID)
Find a sound by the sound ID
|
boolean |
isMediaEnabled() |
boolean |
isMediaPlaying() |
boolean |
isSoundEnabled() |
void |
load(Soundable... sounds) |
boolean |
onError(MediaPlayer mp,
int what,
int extra) |
void |
onLoadComplete(SoundPool soundPool,
int sampleId,
int status) |
void |
onPrepared(MediaPlayer mp) |
void |
play(int key) |
void |
play(Media media) |
void |
play(Soundable sound) |
protected void |
playByID(int soundID) |
void |
playDelayed(Soundable sound,
int msec) |
void |
releaseMedia() |
void |
run() |
void |
seekToMedia(int msec) |
void |
setMediaEnabled(boolean mediaEnabled) |
void |
setMediaVolume(float volume) |
void |
setSoundEnabled(boolean enabled) |
void |
stop(int soundID) |
void |
stopMedia() |
boolean |
unload(Soundable sound) |
boolean |
unloadByID(int soundID) |
boolean |
unloadByKey(int key) |
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
protected static final java.lang.String TAG
protected static final float DEFAULT_MEDIA_VOLUME
protectedmSoundMap
protected final SoundPool mSoundPool
protected volatile boolean mSoundEnabled
protected volatile boolean mMediaEnabled
protected boolean mMediaPrepared
protected final Context mContext
protected final AudioManager mAudioManager
protected MediaPlayer mMediaPlayer
protected float mMediaVolume
protected Handler mHandler
protected volatile SparseIntArray mStreamIds
public void run()
run
in interface java.lang.Runnable
run
in class java.lang.Thread
public boolean isSoundEnabled()
public void setSoundEnabled(boolean enabled)
public void load(Soundable... sounds)
public void play(int key)
public void play(Soundable sound)
public void playDelayed(Soundable sound, int msec)
public void play(Media media) throws java.lang.IllegalStateException
java.lang.IllegalStateException
public void setMediaVolume(float volume)
public void stopMedia()
public boolean isMediaPlaying()
public void releaseMedia()
public void seekToMedia(int msec)
public boolean isMediaEnabled()
public void setMediaEnabled(boolean mediaEnabled)
protected void playByID(int soundID)
public void stop(int soundID)
public boolean unloadByID(int soundID)
public boolean unloadByKey(int key)
public boolean unload(Soundable sound)
public Soundable getSoundByID(int soundID)
soundID
- getSound(int)
public Soundable getSound(int key)
key
- getSoundByID(int)
public Context getContext()
public void dispose()
public void onLoadComplete(SoundPool soundPool, int sampleId, int status)
public void onPrepared(MediaPlayer mp)
public boolean onError(MediaPlayer mp, int what, int extra)