Cache music as mp3 files on startup

This commit is contained in:
SirBlob committed 2026-11-01 01:27:47 -04:00
1 parent c819436481
commit 33c9daa58b
11 files changed
+158 -15

No files matched your search

+9 -1
View File
@@ -14,6 +14,8 @@ class MusicPlayer {
history = $state<number[]>([]);
repeat = $state(false);
audioElement: HTMLAudioElement | null = null;
private failedTrackCount = 0;
private loading = false;
@@ -108,7 +110,13 @@ class MusicPlayer {
}
seek(seconds: number) {
this.startOffset = Math.max(0, Math.min(Math.floor(seconds), this.duration - 1));
const targetSeconds = Math.max(0, Math.min(Math.floor(seconds), this.duration - 1));
if (this.currentTrack?.cached && this.audioElement) {
this.audioElement.currentTime = targetSeconds;
this.paused = false;
return;
}
this.startOffset = targetSeconds;
this.elapsedSinceStart = 0;
this.streamKey += 1;
this.paused = false;