Code example for SoundPool

Methods: release

0
            if (mSoundPool != null) {
                mSoundPool.release();
                mSoundPool = null;
            } 
        } 
 
        @Override 
        public synchronized void play(int action) {
            if (action < 0 || action >= mSoundRes.length) {
                Log.e(TAG, "Resource ID not found for action:" + action + " in play().");
                return; 
            } 
 
            int index = mSoundRes[action];
            if (mSoundIDs[index] == ID_NOT_LOADED) {
                // Not loaded yet, load first and then play when the loading is complete. 
                mSoundIDs[index] = mSoundPool.load(mContext, SOUND_RES[index], 1);
                mSoundIDToPlay = mSoundIDs[index];
            } else if (!mSoundIDReady[index]) {
                // Loading and not ready yet. 
                mSoundIDToPlay = mSoundIDs[index];