2012-09-11 3 views
0

나는 오디오 플레이어를 만들었으며, 내 프로젝트에 기간 작업을위한 수업을 가지고 있습니다. totalDuration이 반대 방향으로 계산되었는지 어떻게 확인할 수 있습니까?변경 기간 android audio player

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; 
} 
} 

답변

0

당신이하려는 일을 파악하기가 어렵습니다. 아마도 더 나은 설명을 위해 질문을 편집 할 수 있습니까? currentDuration을 totalDuration에서 0으로 카운트 다운 시키시겠습니까?

나는 당신이 할 수 있습니다 생각 :

currentDuration = (int) totalDuration - ((((double)progress)/100) * totalDuration);