fix: lock screen audio + notification — audioSession once, deferred metadata, SW artwork cache

- Set navigator.audioSession.type='playback' only once (guarded flag) — repeated
  reassignment was resetting the OS audio session and triggering Doze network cuts
- Defer updateMediaSession() until after play() resolves, not before audio.src swap —
  new MediaMetadata during HAVE_NOTHING state caused Samsung to close/reopen notification
- Fix silent bug: updatePlayerUI(s, true) now actually skips MediaSession (added param)
- 10s safety guards now attempt play() instead of just resetting _trackChanging flag
- SW v40: cache-first for getCoverArt with token-stripped keys — artwork served from
  cache even when Doze blocks network, survives session restarts with new auth tokens
- Pre-warm next track artwork 2s after song starts (earlier than 30s-remaining trigger)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
HoneyandClaude Sonnet 4.6 committed 2026-05-04 18:37:23 +02:00
1 parent ec13124d99
commit d355129134
3 files changed
+93 -20

No files matched your search

-2
View File
@@ -127,8 +127,6 @@ window.addEventListener('load', () => {
S.audio.addEventListener('ended', onEnded);
S.audio.addEventListener('play', () => {
S._trackChanging = false;
// Tell OS this is a music playback app — keeps background network alive (Doze mode)
try { if(navigator.audioSession) navigator.audioSession.type = 'playback'; } catch {}
absInterrupt();
setPlayIcon(true);
document.getElementById('player-art').classList.add('spinning');