Code example for SoundPool

Methods: playrelease, sleep

1
	} 
	 
	public void play() throws SoundException, InterruptedException { 
		if (soundPool == null) return;
		try { 
			if (soundPool.play(soundID, 1, 1, 0, 0, 1) == 0) {
				//try twice as the sound maybe is not ready; 
				Log.w("AndroidPoolSingleSoundPlayer.play()", "Sound " + filePath + " not ready wait 1s");
				Thread.sleep(1000);
				if (soundPool.play(soundID, 1, 1, 0, 0, 1) == 0) {
					throw new SoundException("Sound not ready " + 
							filePath);
				} 
			} 
			Thread.sleep(duration);
		} finally { 
			unprepare(); 
		} 
	} 
	 
	public void unprepare() { 
		if (soundPool == null) return;
		soundPool.release();
		soundPool = null;
	} 
	 
	public String toString() {
		return "AndroidPoolSingleSoundPlayer " + filePath;