I tried plugging a SeekBar
into my video app, but it doesn't seem to ever reach the end of the bar. Here's the code:
videoSeekBar = (SeekBar) activity.findViewById(R.id.videoPlayerSeek);
videoDuration = player.getDuration();
videoSeekBar.setMax(videoDuration);
videoSeekBar.setProgress(0);
// Start lengthy operation in a background thread
new Thread(new Runnable() {
public void run() {
while (videoPlayProgress < videoDuration) {
videoPlayProgress = player.getCurrentPosition();
// Update the progress bar
handler.post(new Runnable() {
public void run() {
videoSeekBar.setProgress(videoPlayProgress);
}
});
}
}
}).start();
Then, I have an OnCompleteListener
attached to the MediaPlayer. When it is called,
player.getCurrentPosition()
returns 6209
player.getDuration()
returns 6592
Which can't be right. At this point, the slider status indicator isn't quite at the end of the slider bar, but there's a slight gap. The shorter the video's length, the bigger the gap.