如何创建一个线程,每秒会检查歌曲位置并根据歌曲位置移动搜索栏。我使用的打击代码是游戏只有两个songs..then这是从我的applicatin敬而远之线程在安卓媒体播放器上使用seekbar
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();
}
我有第二首歌playing..in这之后的厚望while循环条件while(mp!= null && mp.getCurrentPosition()
Palaniraja
2012-03-14 13:09:26
您应该与我们分享您的堆栈跟踪。我们并不擅长猜测...... – WarrenFaith 2012-03-14 13:15:53