Connecting SeekBark to MediaPlayer isn't working
I've been following a tutorial to implement a SeekBar to my app but it
isn't working. Here's how I'm trying to do it.
Run() method:
public void run(){
int currentPosition = 0;
int total = player.getDuration();
sBar.setMax(total);
while (player.isPlaying()) {
try {
Thread.sleep(1000);
currentPosition = player.getCurrentPosition();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
sBar.setProgress(currentPosition);
}
}
sBar is seekbar, I declared a global variable.
Now the problem is that there was nowhere mentioned in the tutorial where
to then call this run method? I tried calling it right after the
MediaPlayer is started but it isn't working.
No comments:
Post a Comment