tobi.g
tobi.g

Reputation: 946

Buffering problems with android.media.MediaPlayer

I'm trying to implement a MediaPlayer on an Android app, but now I have two problems, which are not THE BIG SHOWSTOPPER but they are more then annoying and i have to fix it, just for me.

I implemented a async MediaPlayer+Controller to a Activity, which works fine. My plan was to show also the percentage of the buffering on the MediaControl. This also works.

But now, after I can see the percentage, I saw a strange behaviour: if I seek to a position which is already in the buffer, the buffering will start from this position again. Is this a known and/or normal behavior/problem/feature ?

Here are more details:

I'm using the 2.2 SDK This is how I implement it

public class Details extends Activity implements MediaPlayer.OnPreparedListener, MediaController.MediaPlayerControl { 

[...]

private void setPosition(int currentPos ){
    position = currentPos;
}

[...]

public void onCreate(Bundle savedInstanceState) {

[...] 

mediaPlayer.setOnBufferingUpdateListener(new MediaPlayer.OnBufferingUpdateListener() {
            @Override
            public void onBufferingUpdate(MediaPlayer mp, int progress) {
                setPosition(progress);
            }
        });

[...]

public int getBufferPercentage() {
    return position;
}

[...]

public void seekTo(int i) {
    General.mediaPlayer.seekTo(i);
}
}

enter image description here

What I expected after clicking on the seekbar

enter image description here

What I got

enter image description here

Is this normal?

Upvotes: 11

Views: 2940

Answers (1)

MGK
MGK

Reputation: 7098

This thread confirms that although a position is already buffered MediaPlayer sends a request to a server.

Upvotes: 1

Related Questions