Question

I'd like to know exactly what the difference is between the play() and write() methods in the AudioTrack API. I searched on Google for this but I didn't find an answer.

Was it helpful?

Solution

well its a basic question, the play() method is used for static mode and write() method for streaming mode. to be clear static mode contains small chunks of audio files with predefined size and the audio track plays until that specified size and stops.

where as in streaming mode u use write() methods. there are two write methods write(byte[], int, int) and write(short[], int, int),these are blocking and return when the data has been transferred from the Java layer to the native layer and queued for playback. The streaming mode is most useful when playing blocks of audio data that for instance are: too big to fit in memory because of the duration of the sound to play

for further information read this

http://developer.android.com/reference/android/media/AudioTrack.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top