Android MediaPlayer Clipping on Restart after seekTo
I am using an Android MediaPlayer to play from a local source. It is working well other than one bug when restarting the sound.
public void create() {
FileInputStream in = mApp.openFileInput(mMusicFile);
mp = new MediaPlayer();
mp.setDataSource(in.getFD());
mp.prepare()开发者_运维百科;
mp.setLooping(true);
}
public void play() {
mp.start();
}
public void stop() {
mp.stop();
mp.prepare();
mp.seekTo(0);
}
If I call stop(), then a second or so later call play() I hear a brief clip of the sound where it had been stopped then it sound restarts.
I believe this is a known bug in Android 2.2 Froyo. The prescribed work around is to delete the MediaPlayer and make a new one or fade in to the playback.
The internal buffers are not being flushed after the seek.
精彩评论