【发布时间】:2011-07-27 18:12:57
【问题描述】:
我创建了一个 MySoundPool 类(我将这个类用作 sigelton,但不认为这是相关的,因为其他一切都有效)。我正在初始化 SoundPool,一个 HashMap,并获取 AudioManager 的上下文。此后,我正在加载两个声音。 MySoundpool 由 MySoundPool.playSound(int index, float rate) 方法使用 playSound 剪辑速率为 0.5 = 2.0 并执行语句
float streamVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
streamVolume = streamVolume / mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
mSoundPool.play(mSoundPoolMap.get(index), streamVolume, streamVolume, index, 0, rate);
到目前为止一切顺利。一切正常。 不,在前一个声音仍在播放时调用 playSound 会发生,我想在播放新声音之前停止它。在上面的代码 sn -p 之前我试过了
mSoundPool.stop(mSoundPoolMap.get(index));
和
mSoundPool.autoPause();
没有成功。声音只是继续播放到最后。 任何 cmets 将不胜感激
【问题讨论】: