You can set buffer size by accessing MediaPlayer object.
mVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
//mp.setVideoQuality(MediaPlayer.VIDEOQUALITY_LOW);
//mp.setPlaybackSpeed(1.0f);
mp.setBufferSize(1024*1024*4);//4MB buffer size
}
});
You can check the library for more info.
/**
* The buffer to fill before playback, default is 1024*1024 Byte
*
* @param bufSize buffer size in Byte
*/
public native void setBufferSize(long bufSize);
You can use the following buffer size calculator. It gives you how many seconds you should set for the buffer size. (source) And then you can calculate your buffer size in bytes.
// buffer padding in sec.
// should be at least twice as long as the keyframe interval and fps, e.g.:
// keyframe interval of 30 at 30fps --> min. 2 sec.
public static int BUFFER_PADDING = 3;
// videoLength in sec., videoBitrate and bandwidth in kBits/Sec
public static int calculate(int videoLength, int videoBitrate, int bandwidth) {
int bufferTime;
if (videoBitrate > bandwidth) {
bufferTime = (int) Math.ceil(videoLength - videoLength / (videoBitrate / bandwidth));
} else {
bufferTime = 0;
}
bufferTime += BUFFER_PADDING;
return bufferTime;
}