我创建一个应用程序使用MediaPlayer从谷歌驱动程序流式传输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。
如何获得媒体的长度?