My code as below:
Uri uri = Uri.parse(URL);
video.setVideoURI(uri);
video.start();
I use VideoView to play a stream video.
The video is a VideoView.
And I want to get the buffering percent like setOnBufferingUpdateListener in MediaPlayer.
MediaPlayer.setOnBufferingUpdateListener(new OnBufferingUpdateListener() {
@Override
public void onBufferingUpdate(MediaPlayer mp, int percent) {
//buffering is percent
}
});
How can I do it?
Implement this method for your VideoView:
public abstract void onBufferingUpdate (MediaPlayer mp, int percent)
mp is the MediaPlayer the update pertains to percent is the percentage (0-100) of the content that has been buffered or played thus far.
Source
You can add a progressbar before u start loading the Video, and then keep updating it inside this method. And once the buffering is complete (in onPreparedListener), just dismiss the progressbar.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With