0
我試圖在我的視頻應用中插入SeekBar
,但它似乎沒有達到酒吧的盡頭。這裏的代碼:正確使用Android的SeekBar?
videoSeekBar = (SeekBar) activity.findViewById(R.id.videoPlayerSeek);
videoDuration = player.getDuration();
videoSeekBar.setMax(videoDuration);
videoSeekBar.setProgress(0);
// Start lengthy operation in a background thread
new Thread(new Runnable() {
public void run() {
while (videoPlayProgress < videoDuration) {
videoPlayProgress = player.getCurrentPosition();
// Update the progress bar
handler.post(new Runnable() {
public void run() {
videoSeekBar.setProgress(videoPlayProgress);
}
});
}
}
}).start();
然後,我有一個OnCompleteListener
附加到MediaPlayer。當它被調用時,
player.getCurrentPosition()
收益6209
player.getDuration()
收益6592
不能是正確的。此時,滑塊狀態指示器並不完全位於滑塊欄的末端,但存在一個小小的差距。視頻的長度越短,差距越大。
這裏的一切都比我寫的答案要好。 – LeffelMania 2011-04-28 21:33:24
嗨CommonsWare你的帖子是相當有幫助的。但是我需要讓視頻在搜索欄更改時順利移動。在我的情況下,當我移動搜索欄視頻停止並跳轉到最新位置。請指導我。 – Som 2012-11-21 14:04:00