开发者

Android MediaPlayer Clipping on Restart after seekTo

开发者 https://www.devze.com 2023-03-05 19:04 出处:网络
I am using an Android MediaPlayer to play from a local source.It is working well other than one bug when restarting the sound.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消