In my onCreate () method, I do the following:
mSound = new SoundPool(1, AudioManager.STREAM_MUSIC, 0); AudioManager mAudioManager = (AudioManager) this.getSystemService(Context.AUDIO_SERVICE); soundID = mSound.load(this, R.raw.sample, 1); streamVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC); setVolumeControlStream(AudioManager.STREAM_MUSIC);
Then I want the sound file to be played at the click of a button ... so in my onClick () method I have:
mSound.play(soundID, streamVolume, streamVolume, 1, 0, 1f);
It works fine ... but only for 5 seconds, then it just cuts off ... any ideas? Thank you I am testing DROID 3 if this helps.
source share