Code example for AudioTrack

Methods: getStateplaywrite

0
mAudioTrack = null;
    } 
 
    public void playBuffer(byte[] audioData, int bufferSize) {
        if (mAudioTrack.getState() == AudioTrack.STATE_UNINITIALIZED)
            return; 
        if (mAudioTrack.write(audioData, 0, bufferSize) != bufferSize) {
            Log.w(TAG, "Could not write all the samples to the audio device");
        } 
        mAudioTrack.play();
    } 
 
}