fix: Samsung notification stays alive; retry play() on background rejection

- Set playbackState='playing' explicitly before MediaMetadata swap so
  Samsung One UI never sees a gap where state is ambiguous during skip
- Add retry loop (500ms→1s→2s→4s→8s) in playCurrent() catch — handles
  Android Doze rejecting play() in background; stops retrying if the
  song changes mid-flight (AbortError)
- Fix error handler: set _trackChanging=true before audio.load() so
  the load()'s pause event can't slip past the Samsung notification guard

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
HoneyandClaude Sonnet 4.6 committed 2026-05-03 22:29:30 +02:00
1 parent 33dc07ed5d
commit 3f5a5a4c43
2 files changed
+22 -2

No files matched your search

+6 -1
View File
@@ -152,7 +152,12 @@ window.addEventListener('load', () => {
_errRetries++;
const delay = Math.min(1000 * Math.pow(2, _errRetries - 1), 8000); // 1s, 2s, 4s, 8s
clearTimeout(_errTimer);
_errTimer = setTimeout(() => { S.audio.load(); S.audio.play().catch(() => {}); }, delay);
_errTimer = setTimeout(() => {
if(!S.queue[S.qIdx]) return;
S._trackChanging = true; // prevent load()'s pause event from dismissing Samsung notification
S.audio.load();
S.audio.play().catch(() => { S._trackChanging = false; });
}, delay);
});
S.audio.volume = 0.5;