Recognize Stop AudioTrack
<p>How to detect if an AudioTrack has finished playing? it's not simple!!!
I need to touch immediately after the other (enqueue) This code is not working ...
When press 2 times, the 1st not end, and two sound plays same time... </p>

<pre><code>private void getNextAudio() {
    try{            

        byte[] buffer = playlist.poll();
        if (buffer != null) {

            AudioTrack myatrack = getAudioTrack(buffer);                
            myatrack.setPlaybackPositionUpdateListener( new OnPlaybackPositionUpdateListener() {            

                public void onPeriodicNotification(AudioTrack track) {

                }

                public void onMarkerReached(AudioTrack track) {             
                    Log.d(TAG, "onMarker - estado: " + track.getPlayState());

                    if(track.getPlayState() == AudioTrack.PLAYSTATE_STOPPED){

                        track.flush();
                        track.stop();
                        track.release();

                        getNextAudio();
                    }                               
                }
            });             

            if (myatrack != null) {
                // toco o audio.
                myatrack.play();
            }
        }else{
            Log.d(TAG,"Finish");
        }
    }catch(NoSuchElementException ex){
        Log.d(TAG,"No such element");           
    }
}
</code></pre>

<p>Thanks again!
Mateus</p>
