停止声音通过无限循环运行

时间:2011-08-31 12:11:18

标签: android

我正在使用以下代码播放无限时间

SoundPool sounds = new SoundPool(10, AudioManager.STREAM_MUSIC, 0);  
beepSound = sounds.load(this, R.raw.beep, 1);  
beepSoundStream = sounds.play(beepSound, 1.0f, 1.0f, 0,-1, 1.5f);  

在某些情况下,我想停止声音。我正在尝试

sounds.stop(beepSoundStream);  

我也试过

sounds.stop(beepSound)  

但它没有用。

2 个答案:

答案 0 :(得分:0)

您将播放方法设置为循环播放。将第五个参数更改为0 ...

beepSoundStream = sounds.play(beepSound, 1.0f, 1.0f, 0, 0, 1.5f);

答案 1 :(得分:0)

sounds.autoPause()适合我。

相关问题