Solid player bar, gradient sliders and smooth progress

This commit is contained in:
2026-09-23 21:48:39 +02:00
parent bf19bb31f9
commit 26bb8a50a3
5 changed files with 29 additions and 8 deletions
+11 -2
View File
@@ -208,10 +208,19 @@ class PlayerState {
});
}
#tickProgress = () => {
#clockTime = 0;
#clockStamp = 0;
#tickProgress = (now: number) => {
const audio = this.#audio;
if (!audio) return;
this.progress = audio.currentTime;
if (audio.currentTime !== this.#clockTime) {
this.#clockTime = audio.currentTime;
this.#clockStamp = now;
}
const elapsed = Math.min(0.25, (now - this.#clockStamp) / 1000);
const smooth = this.#clockTime + (audio.paused ? 0 : elapsed * audio.playbackRate);
this.progress = Math.min(smooth, Number.isFinite(audio.duration) ? audio.duration : smooth);
this.#rafId = requestAnimationFrame(this.#tickProgress);
};