Try this :
total width(unit) / total file length(milliseconds) = result(unit/milliseconds)
then move your draw by result
per milliseconds
Edit:
My suggestion is:
1- Set SeekBar max=100; and min=0;
2- Convert media lenght to percent by use this method:
public int getProgressPercentage(long currentDuration, long totalDuration){
Double percentage = (double) 0;
long currentSeconds = (int) (currentDuration);
long totalSeconds = (int) (totalDuration);
// calculating percentage
percentage =(((double)currentSeconds)/totalSeconds)*100;
// return percentage
return percentage.intValue();
}
then use this persent in SeekBar like setProgress(getProgressPercentage(long currentDuration, long totalDuration));
3- Implements OnSeekBarChangeListener
and use its progress
parameter to draw your graph:
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromTouch) {
// Here use int progress to draw graph. It is percent
// Current width = 400*percent/100 = result;
// draw until result value;
}
/**
* When user starts moving the progress handler
* */
@Override
public void onStartTrackingTouch(SeekBar seekBar) {}
/**
* When user stops moving the progress hanlder
* */
@Override
public void onStopTrackingTouch(SeekBar seekBar) {}
Hope this helped you.