2013-05-27 63 views
0

我有一個seekbar應該從url流式傳輸,但它不會自動移動,但是當你按下seekbar時,它會把你帶到你應該在的地方。和我的班級不會啓動run()函數!Seekbar不移動

public void run() { 
// TODO Auto-generated method stub 
int currentPosition = 0; 
int total = mediaPlayer.getDuration(); 
seekprogress.setMax(total); 
while (mediaPlayer != null && currentPosition <total) { 
    try { 
     Thread.sleep(100); 
     currentPosition = mediaPlayer.getCurrentPosition(); 
    } catch (InterruptedException e) { 
     return; 
    } catch (Exception e) { 
     return; 
    } 
    seekprogress.setProgress(currentPosition); 
} 

}

+0

請參閱此鏈接http://stackoverflow.com/questions/6805449/audio-seekbar-thread-problem?rq=1 –

回答

0

可以更新只能從UI線程的UI元素。使用runOnUiThread