It is ideal for playing sound that needs to be played repeatedly, but with shorter time. It supports simultaneous playback of multiple sounds, which are loaded into the list at the beginning of the system and can be called by the ID of these sounds.
1. Create a Soundpool object: New Soundpool (int maxstreams, int streamtype, int srcquality);
The first parameter is the number of sounds that soundpool can support, which determines how much of the buffer the Android opens for it, the second parameter is the sound type, The final parameter is sound quality, the higher the quality, the better the sound effect, but consumes more system resources.
2, load the audio stream from a resource or file:
int load (context context, int ResId, int priority) //load from APK resource;
int Load (filedescriptor fd, long offset, long length, int priority) //load from FileDescriptor object;
iint Load (String path, int Priority) //load from full file path name;
Priority Precedence
3. Play sound Play (int soundid, float leftvolume, float rightvolume, int priority, int loop, float rate)
The first argument is Id,id, which is the order in which it is put into soundpool, for example, now Collide.wav is the first, so its ID is 1. The second and third parameters are the volume control of the left and right channels. The fourth parameter is the priority, because only this one sound, so the priority is not important here. The fifth parameter is whether the loop plays, 0 is not looped, and 1 is a loop. The last parameter is the playback ratio, from 0.5 to 2, which is typically 1, which indicates normal playback.
The code is as follows:
Private Soundpool Soundpool;
Soundpool = new Soundpool (4, Audiomanager.stream_music, 5);
final int load = Soundpool.load (this, R.raw.wen, 1);
Soundpool.setonloadcompletelistener (New Onloadcompletelistener () {
public void Onloadcomplete (Soundpool soundpool, int sampleid, int status) {
Soundpool.play (Load, 1, 1, 0, 0, 1);
}
});
Note the point:
1. soundpool can only request 1M of memory space Instead of using it to play songs or play background music.
   , Because sometimes they may cause your program to end somehow.
   3. soundpool efficiency issues. In fact, the efficiency of Soundpool in these playback class is very good
Soundpool Sound in Android