I need to play pcm file through AudioTrack, I want know to that it has finished playing or not?
My code:
scheduleTaskExecutor.scheduleAtFixedRate(new Runnable() { public
void run() {
if (audioTrack.getPlayState() == AudioTrack.PLAYSTATE_STOPPED) {
System.out.println("stop"); } // doSomethingUseful();
}
}, 0, 1, TimeUnit.SECONDS);
then
do{
if (audioTrack.getPlayState() == AudioTrack.PLAYSTATE_STOPPED) {
// stop(); // myAudioRecorder.release(); // stop(); //
myAudioRecorder = new MediaRecorder(); // myAudioRecorder.stop();
System.out.println("stopped......................."); //
myAudioRecorder.release(); r_start = false; }
} while (r_start == true);
But none of above is working.
How can I know it has finished playing?