我在使用 SoundPool 和 .OGG 文件播放循环声音时遇到问题。我设置了这个 HashMap 来查找与名称关联的声音并播放/停止它
public void playLoopSound(String soundName){
currentSound = (Integer) soundMap.get(soundName);
if(currentSound != -1){
try{
Logger.log("Playing Loop Sound: " + currentSound);
loopingSound = soundPool.play(currentSound, 1, 1, 0, -1, 1);
} catch (Exception e) {
Logger.log("Sound Playing Error: " + e.getMessage());
}
} else {
Logger.log("Sound Not Found");
}
}
public void stopLoopSound(){
soundPool.stop(loopingSound);
loopingSound = 0;
}
这个设置工作正常,我在角色开始行走时启动循环,并在它停止行走时停止循环。
然而,声音会随机停止播放,通常在使用后一分钟左右(打开和关闭)......
有没有其他人遇到过与 SoundPool 和循环声音类似的问题?