Hi,

I have a scenario where I want to play several samples after each
other. Sounds like a job for the SoundPool since they will re-occur
and I want to keep them loaded. Below is a code snippet:

SoundPool soundPool = new SoundPool(1, AudioManager.STREAM_MUSIC, 0);
int mySampleId = soundPool.load(context, R.raw.mySample, 1);

//Load a bunch of other samples here...

AudioManager mgr = (AudioManager) context.getSystemService
(Context.AUDIO_SERVICE);
int streamVolume = mgr.getStreamVolume(AudioManager.STREAM_MUSIC);
soundPool.play(mySampleId, streamVolume, streamVolume, 1, 0, 1f);

The play() method of the SoundPool returns instantly so I want to be
able to know how long to wait before starting to play the next sample.

The MediaPlayer has a getDuration() method that would be conviniant in
the SoundPool as well, i.e. to get the duration of a sound ID.

Does anybody know how to get the duration of a sample fetched as a
resource or do you have an alternative solution. Using a MediaPlayer
instance feels a bit more heavy weight .

Thanks,
Pettax

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to