fix(audio-player): playback speed silently reverted to 1x on every reload
restorePosition() swaps the <audio> element's src (manifest track for multi-file books, whole file for single-file, plain URL on offline start), and loading new media resets playbackRate to the element default. init() had applied the persisted speed before any src existed, so after the swap every load actually played at 1x while the Speed pill still showed the stored value — pick 1.5x, reload, and audio was back at 1x. The seekTo() src-swap path already re-applied the rate; the initial load paths now do the same (manifest branch + offline-catch branch). Surfaced by the phase-1 speed-list browser check: button label and audio.playbackRate disagreed after reload.
This commit is contained in:
1 parent
6508abc00f
commit
408a972665
1 file changed
+6
@@ -323,6 +323,11 @@ Alpine.data("audioReader", () => ({
|
||||
const audio = this.audio();
|
||||
if (audio && !audio.getAttribute("src") && this.tracks[0]) {
|
||||
audio.setAttribute("src", this.tracks[0].url);
|
||||
// Setting src resets playbackRate to the element default —
|
||||
// re-apply, mirroring the seekTo() src-swap path. Without this
|
||||
// the pill said 1.5× while audio actually played at 1× after
|
||||
// every reload (surfaced by the speed-list browser check).
|
||||
audio.playbackRate = this.speed;
|
||||
}
|
||||
}
|
||||
if (progress.ok) {
|
||||
@@ -351,6 +356,7 @@ Alpine.data("audioReader", () => ({
|
||||
if (audio && !audio.getAttribute("src") && this.fileUrl) {
|
||||
this.tracks = [{ url: this.fileUrl, start: 0, end: 0 }];
|
||||
audio.setAttribute("src", this.fileUrl);
|
||||
audio.playbackRate = this.speed;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user