Wednesday, July 16, 2014

How to create SoundPool in Android

Below is a brief tutorial on how to add a SoundPool to an Android activity.

Declare SoundPool at the top of activity and create an instance.

SoundPool sound1;
int mysound = 0;

Within onCreate Method, add the following code.

sound1 = new SoudPool(5,AudioManager.STREAM_MUSIC,1);
mysound  = sound1.load(this,path to file,1);

Next, within your onClickListener event, add the play action.

sound1.play(mysound,1,1,0,0,1);

That's it. Thanks for visiting.

Click here for Car information app

No comments:

Post a Comment