我做一個應用程序中使用的MediaPlayer到流從谷歌驅動MP3:上更新時間funtionMediaPlayer的時間返回0時流的MP3
:(https://drive.google.com/uc?export=download&id=0B50eyu1h_Rc1bENYOU1iSjFWaVk特異):
private Runnable mUpdateTimeTask = new Runnable() {
public void run() {
long totalDuration = mp.getDuration();
long currentDuration = mp.getCurrentPosition();
// Displaying time completed playing
songCurrentDurationLabel.setText(""+utils.milliSecondsToTimer(totalDuration - currentDuration));
// Updating progress bar
int progress = (int)(utils.getProgressPercentage(currentDuration, totalDuration));
//Log.d("Progress", ""+progress);
songProgressBar.setProgress(progress);
// Running this thread after 100 milliseconds
mHandler.postDelayed(this, 100);
}
};
我看到長totalDuration = mp.getDuration()
總是儘管媒體播放器已播放,但仍返回0。
如何獲得媒體的長度?
getCurrentPosition()返回正確的值? –
是的,它有價值 – phongvan