roundProgress method
Returns a "rounded" progress value according to the frameRate
Implementation
double roundProgress(double progress, {required FrameRate frameRate}) {
var fps = frameRate.resolveFps(this.frameRate);
if (fps == null) {
return progress;
}
var noOffsetDurationFrames = durationFrames + 0.01;
var totalFrameCount = (noOffsetDurationFrames / this.frameRate) * fps;
var frameIndex = (totalFrameCount * progress).toInt();
var roundedProgress = frameIndex / totalFrameCount;
assert(
roundedProgress >= 0 && roundedProgress <= 1,
'Progress is $roundedProgress',
);
return roundedProgress;
}