Skip to content Skip to sidebar Skip to footer

Android Mediaplayer : How Do I Show A Progress Dialog While Buffering Audio

Im trying to play an mp3 audio from url. But when having slow network, player seems like not responding while buffering. So i need to add a progress dialog while buffering . Is it

Solution 1:

You can show a seekbar, something like :

// In your onCreate(), add below at last .......
.
.
.
seekbar.setMax(mMediaPlayer.getDuration());
mMediaPlayer.setOnBufferingUpdateListener(new MediaPlayer.OnBufferingUpdateListener() {
    publicvoidonBufferingUpdate(MediaPlayer mp, int percent) 
    {
        double ratio = percent / 100.0;
        bufferingLevel = (int)(mp.getDuration() * ratio);

        seekBar.setSecondaryProgress(bufferingLevel);
    }

}); 

Hope this helps !

Post a Comment for "Android Mediaplayer : How Do I Show A Progress Dialog While Buffering Audio"