I'm using Video view to stream an HLS stream from wowza media server. I want to show the overall buffering just as in YouTube player, what i did is this and I'm able to access seek-bar object and i debugged the code it's not null
videoView.setOnPreparedListener(new OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
int topContainerId = getResources().getIdentifier("mediacontroller_progress", "id", "android");
seekbar = (SeekBar) mediaController.findViewById(topContainerId);
mp.setOnBufferingUpdateListener(new OnBufferingUpdateListener() {
@Override
public void onBufferingUpdate(MediaPlayer mp, int percent) {
if (percent<seekbar.getMax()) {
seekbar.setSecondaryProgress(percent);
}
}
});
}
});
The problem is i can't see any secondary progress in Media controller seekbar. If any clarification required required please write in comments. Help is really appreciated.
Here is the runnable class. Runnable timerRunnable = new Runnable() { public void run() { // Get mediaplayer time and set the value // This will trigger itself every one second. updateHandler. postDelayed(this, 1000); } };
Well according to android.developers.com, A SeekBar is an extension of ProgressBar that adds a draggable thumb. The user can touch the thumb and drag left or right to set the current progress level or use the arrow keys. Placing focusable widgets to the left or right of a SeekBar is discouraged.
Use below code and you're goog to go
videoView.setOnPreparedListener(new OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
int topContainerId = getResources().getIdentifier("mediacontroller_progress", "id", "android");
seekbar = (SeekBar) mediaController.findViewById(topContainerId);
mp.setOnBufferingUpdateListener(new OnBufferingUpdateListener() {
@Override
public void onBufferingUpdate(MediaPlayer mp, int percent) {
if (percent<seekbar.getMax()) {
seekbar.setSecondaryProgress(percent/100);
}
}
});
}
});
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