package com.edufound.base.util; import android.content.Context; import android.media.AudioManager; import android.media.SoundPool; public class SoundPoolUtil { SoundPool soundPool; boolean isLoadComplete = false; public void init(Context context, int rawId) { soundPool = new SoundPool(10, AudioManager.STREAM_SYSTEM, 5); soundPool.setOnLoadCompleteListener(new SoundPool.OnLoadCompleteListener() { @Override public void onLoadComplete(SoundPool soundPool, int sampleId, int status) { isLoadComplete = true; } }); soundPool.load(context, rawId, 3); } public void startSoundPool(float left, float right) { soundPool.play(1, left, right, 5, 0, 1); } public boolean soundComplete() { return isLoadComplete; } public void release() { soundPool.release(); } }