Wednesday, March 10, 2010

[android-developers] Using MediaPlayer - multiple sound files

Hi all. I need to use MediaPlayer to play some sounds, as they were
too large in size for the SoundPool class.

The constructor takes a single sound file. I have, potentially, around
20 files that I want to play, randomly and instantly, like sounds in a
game.

Do I have to create a new MediaPlayer object for each sound? i.e...

MediaPlayer mp1 = MediaPlayer.create(context, R.raw.sound1);
MediaPlayer mp2 = MediaPlayer.create(context, R.raw.sound2);
MediaPlayer mp3 = MediaPlayer.create(context, R.raw.sound3);
MediaPlayer mp4 = MediaPlayer.create(context, R.raw.sound4);

That seems expensive...

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

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate