加载声音。返回值为soundID。 priority参数无效,置1 若文件大于1M,则只加载前1M int load(AssetFileDescriptor afd, int priority) //通过一个AssetFileDescriptor对象 int load(Context context, int resId, int priority) //通过一个资源ID int load(String path, int priority) //通过指定的路径加载 int load(FileDescriptor fd, long offset, long length, int priority) //通过FileDescriptor加载
播放控制。 final int play(int soundID, float leftVolume, float rightVolume, int priority, int loop, float rate) //播放指定音频的音效,并返回一个streamID 。 //priority —— 流的优先级,值越大优先级高,影响当同时播放数量超出了最大支持数时SoundPool对该流的处理; //loop —— 循环播放的次数,0为值播放一次,-1为无限循环,其他值为播放loop+1次(例如,3为一共播放4次). //rate —— 播放的速率,范围0.5-2.0(0.5为一半速率,1.0为正常速率,2.0为两倍速率) final void pause(int streamID) //暂停指定播放流的音效(streamID 应通过play()返回)。 final void resume(int streamID) //继续播放指定播放流的音效(streamID 应通过play()返回)。 final void stop(int streamID) //终止指定播放流的音效(streamID 应通过play()返回)。
释放资源。 final boolean unload(int soundID) //卸载一个指定的音频资源. final void release() //释放SoundPool中的所有音频资源.