Code example for AudioTrack

Methods: flushplaywrite

public class PlaySound { 
	public static void playBa(final int sampleRate,
			final byte[] baSoundByteArray, final OnPlaySoundComplete opsc) {
		final AudioTrack audioTrack = new AudioTrack(AudioManager.STREAM_MUSIC,
				sampleRate, AudioFormat.CHANNEL_OUT_MONO,
				AudioFormat.ENCODING_PCM_16BIT, baSoundByteArray.length,
		Log.i(PlaySound.class.getName(), "PlaySound - Size of the stream : "
				+ baSoundByteArray.length);
		audioTrack.write(baSoundByteArray, 0, baSoundByteArray.length);
		new Thread() {
			public void run() { 
				int lastFrame = -1;
				while (lastFrame != audioTrack.getPlaybackHeadPosition()) {
Stop searching for code, let great code find you!  Add Codota to your java IDE