namespace MusicBridge.Agent.Media; internal static class TimelineMath { public static double Position(double position, double start, double end, bool playing, DateTimeOffset updatedAt, DateTimeOffset now, double rate) { if (playing && updatedAt > DateTimeOffset.UnixEpoch && updatedAt <= now && double.IsFinite(rate)) position += (now - updatedAt).TotalSeconds * rate; position = Math.Max(start, position); return end > start ? Math.Min(end, position) : position; } public static (double Min, double Max) SeekRange(double start, double end, double min, double max) => (Math.Max(start, min), end > start ? Math.Min(end, max) : max); }