Search in sources :

Example 1 with ETAPart

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;
    });
}
Also used : Time(org.fagu.fmv.utils.time.Time) ETAPart(org.fagu.fmv.textprogressbar.part.ETAPart)

Aggregations

ETAPart (org.fagu.fmv.textprogressbar.part.ETAPart)1 Time (org.fagu.fmv.utils.time.Time)1