Skip to content

Commit f9ec2ed

Browse files
committed
revert: restore working audio player before Media Session API changes
1 parent d8b20c7 commit f9ec2ed

1 file changed

Lines changed: 5 additions & 12 deletions

File tree

web/src/context/AudioContext.tsx

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,12 @@ export function AudioProvider({ children, allTracks }: { children: React.ReactNo
3434

3535
const playTrack = useCallback((track: Track) => {
3636
if (audioRef.current) {
37-
setIsLoading(true);
37+
setIsLoading(true); // Set loading immediately
3838
audioRef.current.src = track.url;
39-
audioRef.current.load();
40-
audioRef.current.play()
41-
.then(() => {
42-
// Clear loading when play promise resolves
43-
setIsLoading(false);
44-
})
45-
.catch(e => {
46-
console.error("Playback failed:", e);
47-
setIsLoading(false);
48-
});
39+
audioRef.current.play().catch(e => {
40+
console.error("Playback failed:", e);
41+
setIsLoading(false);
42+
});
4943
setCurrentTrack(track);
5044
setIsPlaying(true);
5145
}
@@ -147,7 +141,6 @@ export function AudioProvider({ children, allTracks }: { children: React.ReactNo
147141
const closePlayer = () => {
148142
if (audioRef.current) {
149143
audioRef.current.pause();
150-
audioRef.current.src = ''; // Clear the source to fully stop
151144
audioRef.current.currentTime = 0;
152145
}
153146
setIsPlaying(false);

0 commit comments

Comments
 (0)