How to get buffering percent of VideoView on Android
10,641
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.
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.
Author by
brian
Updated on June 14, 2022Comments
-
brian almost 2 years
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?
-
brian over 11 yearsBut I don't need progressbar, I only need the percent number.
-
pilcrowpipe over 11 yearsThis is incorrect. Implementing onBufferingUpdate in a subclassed VideoView does nothing.
-
Rakki s about 9 yearsI have implemented it in my activity itself, but it does not call back again.
-
Rakki s about 9 yearsI have asked as separate question in the following link stackoverflow.com/questions/29029597/…
-
cV2 about 9 yearsokay, sorry currently not into this topic, probably there is some way to setup the buffer for auto playing at some %. good luck.
-
Rakki s about 9 yearsNo actually i have added the call back function for the buffer listener in that code but it's not called that's my issues ... i know the way to start play after some percentage.