How to create a thread that will check the song position every second and move the seekbar based on the song position. i used the blow code it's play only two songs..then it's turn away from my applicatin
public class setp implements MediaPlayer.OnPreparedListener
{
public void onPrepared(MediaPlayer mps) {
// TODO Auto-generated method stub
seekbar.setMax(mp.getDuration());
new Thread(new Runnable() {
public void run() {
while(mp!=null && mp.getCurrentPosition()<mp.getDuration())
{
seekbar.setProgress(mp.getCurrentPosition());
Message msg=new Message();
int millis = mp.getCurrentPosition();
msg.obj=millis/1000;
try {
Thread.sleep(100);
}
catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}).start();
}