// schedule the current sound to stop after set milliseconds
mHandler.postDelayed(new Runnable() {
public void run() {
if (!mKillSoundQueue.isEmpty()) {
mSoundPool.stop(mKillSoundQueue
.firstElement());
}
}
}, delay);
}
/**
* Loads the various sound assets
* @param locale the load to load audio files
*/
public void loadSounds(String locale)
throws SAXException, IOException,
ParserConfigurationException {
Log.d("load locale", locale);
this.locale = locale;
AssetFileDescriptor afd;
Map<String, String> audioFiles = util
.getAudioFileConfig(locale,
mContext.getAssets());
for (String key : audioFiles.keySet()) {
afd = mContext.getAssets().openFd(
audioFiles.get(key));
addSound(key, afd);
}
}
/**
* Stop a Sound
*
* @param index - index of the sound to be stopped
*/
public void stopSound(int index) {
mSoundPool.stop(mSoundPoolMap.get(index));
}
/**
* Deallocates the resources and Instance of SoundManager
*/
public void cleanup() {
mSoundPool.release();
mSoundPool = null;
mSoundPoolMap.clear();
mAudioManager.unloadSoundEffects();
_instance = null;
}
/**
* unload all resource in the sound pool
* support for user change VoiceLanguage or Locale or user close the voice function !
*/
public void unloadAllSoundsIn() {
if (mSoundPoolMap.size() > 0) {
for (String key : mSoundPoolMap.keySet()) {
mSoundPool.unload(mSoundPoolMap.get(key));
}
}
mKillSoundQueue.clear();
mSoundPoolMap.clear();
}
/**
* set the speed of soundPool
*
* @param i i<0 means slow i= 0 means normal i>0 means fast
*/
public void setVoiceSpeed(int i) {
if (i > 0) {
rate = 1.2f;
}
else if (i < 0) {
rate = 0.8f;
}
else {
rate = 1.0f;
}
}