クラス MySoundPool を作成しました (このクラスを sigelton として使用していますが、他のすべてが機能するため、これは関係ないと思います)。私は、HashMap である SoundPool を初期化し、AudioManager のコンテキストを取得しています。その後、2 つのサウンドをロードしています。MySoundpool はメソッド MySoundPool.playSound(int index, float rate) によって使用されます。 playSound はレートを 0.5 <= rate >= 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 が呼び出されることがあります。新しいサウンドを再生する前にそれを停止したいと考えています。私が試した上記のコードスニペットの前に
mSoundPool.stop(mSoundPoolMap.get(index));
と
mSoundPool.autoPause();
成功しませんでした。音は最後まで再生され続けます。コメントをお待ちしております