Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 722
tobi.g Avatar asked May 27 '11 18:05

tobi.g


1 Answers

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

like image 189
MGK Avatar answered Nov 05 '22 17:11

MGK