use of org.fagu.fmv.textprogressbar.part.ETAPart in project fmv by f-agu.
the class ByDuration method etaPart.
/**
* @return
*/
@Override
public Part etaPart() {
double durTotal = duration.toSeconds();
long startTime = System.currentTimeMillis();
return new ETAPart(status -> {
Time time = progress.getTime();
if (time != null) {
double currentSeconds = time.toSeconds();
if (currentSeconds > 0) {
double remainSeconds = durTotal - currentSeconds;
int milliseconds = (int) (remainSeconds * (int) (System.currentTimeMillis() - startTime) / currentSeconds);
return milliseconds / 1000;
}
}
return null;
});
}