fix(web): NowPlaying showed a stale cover after rapid skips
The NP overlay only refreshed its cover while open, so skipping with it closed left the <img> on the last-opened song; reopening briefly showed that old cover until the current one loaded. Now the NP cover element is kept pointed at the current song even while closed (loads in the background), so opening it always shows the right artwork. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
46e252b494
commit
7cba39dfaf
1 file changed
+8
-2
@@ -527,9 +527,15 @@ export function updatePlayerUI(s, _skipMediaSession = false) {
|
||||
} catch {}
|
||||
_syncNpDirect(s);
|
||||
_updatePlayingHighlights();
|
||||
// Preload the hi-res NP cover now so opening the overlay is instant
|
||||
// Keep the NP cover element pointing at the CURRENT song even while the overlay is closed,
|
||||
// so opening it after rapid skips never shows a stale cover (it also preloads in the background).
|
||||
const _npCv = coverUrl(s.coverArt, 1024);
|
||||
if (_npCv && _npCv !== _npBgLastUrl) { const _pre = new Image(); _pre.src = _npCv; }
|
||||
const _npCover = document.getElementById('np-cover');
|
||||
const _npImg = _npCover?.querySelector('img');
|
||||
if (_npCv) {
|
||||
if (_npImg) { if (_npImg.src !== _npCv) _npImg.src = _npCv; }
|
||||
else if (_npCover) _npCover.innerHTML = `<img src="${_npCv}" style="width:100%;height:100%;object-fit:cover">`;
|
||||
}
|
||||
// Pre-warm the next song's 1024 cover so auto-advance NP swap is instant from cache
|
||||
const _nextForPreload = S.qIdx + 1 < S.queue.length ? S.queue[S.qIdx + 1] : null;
|
||||
if (_nextForPreload?.coverArt) {
|
||||
|
||||
Reference in new issue
Block a user