Search code examples
androidmedia-player

MediaPlayer.seekTo() does not work for unbuffered position


I use MediaPlayer for playing a single mp3 song from network. Data source is a HTTP URL.

Let's assume we have following playing state.

Song duration: 1:00

Current progress: 0:10

Current buffering progress 0:30

Let's say I want to skip some part of a song and seek forward. I do it with MediaPlayer.seekTo() method. If I seek to buffered position (0:20) it is performed correctly. But if I seek to a position which has not been buffered yet (0:40) the MediaPlayer behaves odd. It indicates immediately that it has seeked correctly without waiting for a buffer to fill. In fact it continues playing at the same position where it was before seeking. From now on MediaPlayer.getCurrentPosition() method returns wrong position. When playing reaches its end and OnCompletionListener.onCompletion callback is called the current media player position is much higher than entire song duration.

Any ideas for solving this?


Solution

  • It's probably related to the bug that's (referring to one of the comments) eventually fixed in 2.2 http://code.google.com/p/android/issues/detail?id=4124