AudioTrack skipping after pause and resume
- by Markus Drösser
Hi, here is the problem.
I play a wav file that i recorded earlier without problems. but when i call audiotrack.pause() and audiotrack.start() again after some waiting, it skips some frames of the file. why is that?
here is my play listener
// Start playback
audioTrack.setPlaybackPositionUpdateListener(new OnPlaybackPositionUpdateListener() {
@Override
public void onPeriodicNotification(AudioTrack track) {
try {
if(ramfile!=null && ramfile.read(buffer)==-1)
{
audioTrack.release();
audioTrack = null;
ramfile.close();
playing=false;
}
else
{
audioTrack.write(buffer, 0, buffer.length);
}
} catch (IOException e) {
try {
ramfile.close();
playing=false;
} catch (IOException e1) {
}
}
}
@Override
public void onMarkerReached(AudioTrack track) {
playing=false;
track.release();
}
});