seekBar.setMax(mediaPlayer.getDuration());
When a media player is playing,
seekBar.setProgress(mediaPlayer.getCurrentPosition());
But seekBar cannot search max,
mediaPlayer.setOnCompletionListener(new OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
LogUtil.d(TAG, "CurrentPosition = " + mp.getCurrentPosition(+ " -- Duration = " + mp.getDuration());
}
});
I found that mediaPlayer.getCurrentPosition () is always less than mediaPlayer.getDuration (). If I use seekBar.setProgress (mp.getDuration ()) when it is complete, the seekBar animation will not be smooth.
So why is getCurrentPosition () less than getDuration () when it is complete?
Sorry for my English.
source
share