soundPool 后如何清理?应用程序被杀死后,我的循环声音仍在播放
// 我的 onStop() onPause() 是相同的声音一直持续到重新启动。
public void onStop(){
soundPool.stop(curs);
}
public int playSound(int sound, int loop) {
if (curs != sound)
{
curs = sound;
AudioManager mgr = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
float streamVolumeCurrent = mgr.getStreamVolume(AudioManager.STREAM_MUSIC);
float streamVolumeMax = mgr.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
float volume = streamVolumeCurrent / streamVolumeMax;
return soundPool.play(soundsMap.get(sound), volume, volume, 1, loop, 1);
}
return curs;
}
// is how I call it in a runnable class
curs=playSound(cur,-1);