Skip to content

Commit d8b20c7

Browse files
committed
fix: restore loading state clearing and properly stop audio on close
1 parent 16a80d5 commit d8b20c7

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

web/src/context/AudioContext.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ export function AudioProvider({ children, allTracks }: { children: React.ReactNo
3838
audioRef.current.src = track.url;
3939
audioRef.current.load();
4040
audioRef.current.play()
41+
.then(() => {
42+
// Clear loading when play promise resolves
43+
setIsLoading(false);
44+
})
4145
.catch(e => {
4246
console.error("Playback failed:", e);
4347
setIsLoading(false);
@@ -143,6 +147,7 @@ export function AudioProvider({ children, allTracks }: { children: React.ReactNo
143147
const closePlayer = () => {
144148
if (audioRef.current) {
145149
audioRef.current.pause();
150+
audioRef.current.src = ''; // Clear the source to fully stop
146151
audioRef.current.currentTime = 0;
147152
}
148153
setIsPlaying(false);

0 commit comments

Comments
 (0)