fix: volume slider

This commit is contained in:
2025-10-04 15:05:06 -04:00
parent 7c64818db1
commit e5c8ce1c30
2 changed files with 8 additions and 2 deletions

View File

@@ -25,7 +25,6 @@
function handleVolumeChange(volume: number) {
playback.setVolume(volume);
audioPlayer.setVolume(volume);
}
function formatTime(seconds: number): string {

View File

@@ -137,9 +137,10 @@ export const audioPlayer = new AudioPlayer();
if (typeof window !== 'undefined') {
let prevTrack: Track | null = null;
let prevIsPlaying = false;
let prevVolume = 1;
playback.subscribe(state => {
const { currentTrack, isPlaying } = state;
const { currentTrack, isPlaying, volume } = state;
// Track changed
if (currentTrack && currentTrack !== prevTrack) {
@@ -160,5 +161,11 @@ if (typeof window !== 'undefined') {
}
prevIsPlaying = isPlaying;
}
// Volume changed
if (volume !== prevVolume) {
audioPlayer.setVolume(volume);
prevVolume = volume;
}
});
}