Fix Spotify flashing display issue (#54)

- Implement proper significant change detection for Spotify polling
- Only trigger significant changes for title, artist, album_art_url, is_playing changes
- Progress updates (progress_ms) are now non-significant and won't cause flashing
- Matches the logic used for YouTube Music polling
- Prevents unnecessary album art re-fetching and display clearing every 2 seconds
This commit is contained in:
Chuck
2025-09-19 22:33:01 -04:00
committed by GitHub
parent 31ec0018be
commit 1dcda5613a

View File

@@ -371,11 +371,33 @@ class MusicManager:
with self.track_info_lock:
if simplified_info_poll != self.current_track_info:
# Check for significant changes (same logic as YTM)
significant_change_detected = False
if self.current_track_info is None and simplified_info_poll.get('title') != 'Nothing Playing':
significant_change_detected = True
logger.debug("Polling Spotify: First valid track data, marking as significant.")
elif self.current_track_info is not None and (
simplified_info_poll.get('title') != self.current_track_info.get('title') or
simplified_info_poll.get('artist') != self.current_track_info.get('artist') or
simplified_info_poll.get('album_art_url') != self.current_track_info.get('album_art_url') or
simplified_info_poll.get('is_playing') != self.current_track_info.get('is_playing')
):
significant_change_detected = True
logger.debug("Polling Spotify: Significant change (title/artist/art/is_playing) detected.")
else:
logger.debug("Polling Spotify: Only progress changed, not significant.")
self.current_track_info = simplified_info_poll
self.current_source = MusicSource.SPOTIFY
significant_change_for_callback = True # Spotify poll changes always considered significant
significant_change_for_callback = significant_change_detected
simplified_info_for_callback = simplified_info_poll.copy()
if significant_change_detected:
self._needs_immediate_full_refresh = True # Reset display state
logger.info("Polling Spotify: Significant change detected.")
else:
logger.debug("Polling Spotify: Minor update (progress only), no full refresh needed.")
# Handle album art for Spotify if needed (similar to _process_ytm_data_update)
old_album_art_url = self.current_track_info.get('album_art_url_prev_spotify') # Need a way to store prev
new_album_art_url = simplified_info_poll.get('album_art_url')
@@ -384,7 +406,6 @@ class MusicManager:
self.last_album_art_url = new_album_art_url
self.current_track_info['album_art_url_prev_spotify'] = new_album_art_url
logger.debug(f"Polling Spotify: Active track - {spotify_track.get('item', {}).get('name')}")
else:
logger.debug("Polling Spotify: No change in simplified track info.")