fix(player): sync volume from backend playback events

Update the local volume state when receiving playback events from the
backend. This ensures the volume slider reflects changes made via
remote control or other external sources.
This commit is contained in:
vicrodh committed 2026-02-03 09:14:52 -06:00
1 parent b0ddf2d020
commit 6b85086b0a
1 file changed
+11 -1
+11 -1
View File
@@ -462,7 +462,10 @@ async function handlePlaybackEvent(event: PlaybackEvent): Promise<void> {
// Update playback state from event
currentTime = event.position;
isPlaying = event.is_playing;
console.log('[Player] Updated to external track:', queueTrack.title, 'isPlaying:', isPlaying);
// Sync volume from backend
volume = Math.round(event.volume * 100);
persistVolume(volume);
console.log('[Player] Updated to external track:', queueTrack.title, 'isPlaying:', isPlaying, 'volume:', volume);
notifyListeners();
} else {
console.warn('[Player] Queue track mismatch or null:', queueTrack?.id, 'vs event:', event.track_id);
@@ -482,6 +485,13 @@ async function handlePlaybackEvent(event: PlaybackEvent): Promise<void> {
currentTime = event.position;
isPlaying = event.is_playing;
// Update volume from backend (e.g., changed via remote control or system)
const eventVolume = Math.round(event.volume * 100);
if (eventVolume !== volume) {
volume = eventVolume;
persistVolume(volume);
}
// Update track with actual stream quality (issue #34)
// The backend now sends the real sample rate and bit depth from the decoded stream
if (event.sample_rate && event.sample_rate > 0) {