Skip to content

Commit 3a445ce

Browse files
committed
simsalabim
1 parent 882e79c commit 3a445ce

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

MyMusicClientSveltePwa/src/lib/scripts/playbackService.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,17 @@ export function initializePlaybackService() {
109109

110110
audioElement.addEventListener("error", (e) => {
111111
console.error("Error loading audio:", e);
112+
// Retry
113+
audioElement.load();
114+
isLoading.set(true);
112115
});
116+
117+
audioElement.addEventListener("abort", (e) => {
118+
console.error("Abort loading audio:", e);
119+
// Retry
120+
audioElement.load();
121+
isLoading.set(true);
122+
})
113123
}
114124

115125
export function nextSong() {
@@ -143,10 +153,10 @@ export function playOrPauseSong(songId) {
143153
songIndex = playlistSongs.findIndex((song) => song.id === songId);
144154
audioElement.src = getPlaybackUrl(song.source_id);
145155
audioElement.load();
156+
isLoading.set(true);
146157
currentSong.set(playlistSongs.find((song) => song.id === songId));
147158
isPlaying.set(false); // set to false since this is a new song
148159
setCurrentSongIndex(songIndex);
149-
isLoading.set(true);
150160
}
151161
else if (get(isPlaying)) {
152162
audioElement.pause();

0 commit comments

Comments
 (0)