Android 停止通过无限循环的声音
我用下面的代码无限期地播放声音Android 停止通过无限循环的声音,android,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
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)
但它不起作用。您已将播放方法设置为循环。将第五个参数更改为0
beepSoundStream=声音。播放BeepSound,1.0f、1.0f、0、0、1.5f sounds.autopose对我有效。我需要在循环中运行它,这就是为什么我将它设置为-1I,我甚至还尝试了sounds.setLoopbeepSoundStream,0;sounds.stoppengsoundstream;哦,对不起,我误读了你的问题,我以为你是想让它停止循环哈哈。。。我知道你现在要干什么了。第一种尝试使用sounds.stopbeepSoundStream停止声音的方法;是正确的,事实上我也试过同样的方法,它对我有效。嗯…你试过在那条流上叫暂停吗?这行得通吗?停顿也不行。我必须使用MediaPlayer。这对我来说很好。