I’m having a seeker bar for media player and I have implemented as below.
//SeekBar setup
progress = (SeekBar)findViewById(R.id.seekBarPlayer);
progress.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub
}
@Override
public void onProgressChanged(SeekBar seekBar, int progress,
boolean fromUser) {
if (fromUser) {
mediaPlayer.seekTo(progress);
Log.v(TAG,progress +"Seeking...");
}
}
});
//seekbar initiated after mediaplayer initiated
total = mediaPlayer.getDuration();
progress.setMax(total);
But my problem is seekBar doesn’t run as the music plays. It idles at one place, if I seek then the music seeks but it doesn’t run or make progress movment with the music. Can someone tell me what am I missing.
Thanks in advance for your time.
It is becoz you updated the progress bar in same thread in which media player runs. update your progress bar in UI (or different)thread.Look at this android: how do I use the progress bar?. Thnx.