0

オーディオ プレーヤーを作成し、プロジェクトに期間を操作するためのクラスを作成しました。totalDuration が逆方向にカウントされたことを確認するにはどうすればよいでしょうか?

public class Utilities {
public String milliSecondsToTimer(long milliseconds){
    String finalTimerString = "";
    String secondsString = "";
    // Convert total duration into time
    int hours = (int)( milliseconds / (1000*60*60));
    int minutes = (int)(milliseconds % (1000*60*60)) / (1000*60);
    int seconds = (int) ((milliseconds % (1000*60*60)) % (1000*60) / 1000);
    // Add hours if there
    if(hours > 0){
        finalTimerString = hours + ":";
    }
    // Prepending 0 to seconds if it is one digit
    if(seconds < 10){
        secondsString = "0" + seconds;
    }else{
        secondsString = "" + seconds;}
    finalTimerString = finalTimerString + minutes + ":" + secondsString;
    // return timer string
    return finalTimerString;
}

public 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();
}

public int progressToTimer(int progress, int totalDuration) {
    int currentDuration = 0;
    totalDuration = (int) (totalDuration / 1000);
    currentDuration = (int) ((((double)progress) / 100) * totalDuration);
    // return current duration in milliseconds
    return currentDuration * 1000;
}
}
4

1 に答える 1

0

あなたが何をしようとしているのかを理解するのは難しいです。おそらく、質問を編集して説明を改善できますか?currentDuration を totalDuration から 0 までカウントダウンしますか?

私はあなたがこれを望むかもしれないと思う:

currentDuration = (int) totalDuration - ((((double)progress) / 100) * totalDuration);
于 2012-09-11T15:57:30.120 に答える