The constructor for the Soundpool class is as follows:
Soundpool (int maxstreams, int streamtype, int srcquality)
Role: Instantiate a Soundpool instance
First parameter: Maximum number of sounds allowed to play simultaneously
Second parameter: type of sound
Third parameter: Quality of Sound
The functions commonly used in the Soundpool class are as follows:
int load (context context, int resId, int priority)
Function: Load music file, return music ID (music stream file data)
First parameter: instance of the Context
Second parameter: Music file ID
The third parameter: Identifies the sound that takes precedence. Currently used without any effect, but with the compatibility value
int play (int soundid, float leftvolume, float rightvolume, int priority, int loop, floatrate)
Function: Music playback, playback failed to return 0, normal playback return non 0 value
First parameter: The music file ID that is obtained after loading
Second parameter: Left channel of volume, Range: 0.0~1.0
Third parameter: Right channel of volume, Range: 0.0~1.0
Fourth parameter: Music stream priority, 0 is the lowest priority
The fifth parameter: the number of times the music is played, 1 is the infinite loop, 0 is normal once, and more than 0 indicates the number of cycles
Sixth parameter: Playback rate, Value range: 0.5~2.0,1.0 indicates normal playback
Pause (int streamid)
Role: Pause Music playback
Parameters: Stream ID After the music file is loaded
Stop (int streamid)
Effect: End Music playback
Parameters: Stream ID After the music file is loaded
Release ()
Role: releasing resources from Soundpool
Setloop (int streamid, int loop)
Function: Set the number of cycles
First parameter: Stream ID after a music file is loaded
Second parameter: Number of cycles
setrate (int streamid, float rate)
Action: Set playback rate
First parameter: Stream ID after a music file is loaded
Second parameter: rate value
SetVolume (int streamid, float leftvolume, float rightvolume)
Function: Set the volume size
First parameter: Stream ID after a music file is loaded
Second parameter: Left channel volume
Third parameter: Right channel volume
setpriority (int streamid, int priority)
Role: Set the priority of the stream
First parameter: Stream ID after a music file is loaded
Second parameter: Priority value
Android Soundpool parameter description