I need to get the progress time of the video that is played in \"VideoView\"(ie the time shown in the left hand side in progress bar).
Any help will really be apprec
I accomplished it such way
private void playVideo() {
setViewNotVisibility();
final String videoSource = "android.resource://" + getPackageName() + File.separator + R.raw.moviiegood;
videoView.setKeepScreenOn(true);
videoView.setVideoURI(Uri.parse(videoSource));
videoView.setMediaController(null);
videoView.setOnCompletionListener(myVideoViewCompletionListener);
videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
startVideo();
setDuration();
timerCounter();
}
}
);
}
private Timer timer;
private void timerCounter(){
timer = new Timer();
TimerTask task = new TimerTask() {
@Override
public void run() {
runOnUiThread(new Runnable() {
@Override
public void run() {
updateUI();
}
});
}
};
timer.schedule(task, 0, 1000);
}
private int duration = 0;
private void setDuration(){
duration = videoView.getDuration();
}
private void updateUI(){
if (pbVideoView.getProgress() >= 100) {
timer.cancel();
}
int current = videoView.getCurrentPosition();
int progress = current * 100 / duration;
pbVideoView.setProgress(progress);
}
If you have a questions feel free to ask