android 播放音乐卡顿,Android MediaPlayer getCurrentPosition()导致音频卡顿
我用这种方法来计算进度’public static int getProgressPercentage(long currentDuration,long totalDuration) {Double percentage = (double) 0;long currentSeconds = (int) (currentDuration / 1000);long totalSeconds = (i
·
我用这种方法来计算进度’
public static int getProgressPercentage(long currentDuration,
long totalDuration) {
Double percentage = (double) 0;
long currentSeconds = (int) (currentDuration / 1000);
long totalSeconds = (int) (totalDuration / 1000);
// calculating percentage
percentage = (((double) currentSeconds) / totalSeconds) * 100;
// return percentage
return percentage.intValue();
}
注意:mPlayer.getCurrentPosition()不准确.报告了一些错误.我有一个问题,即当前位置高于totalDuration.
更多推荐
已为社区贡献3条内容
所有评论(0)