fix(android): instant cold-start resume + play button icon flicker

WebBridge: skip setMediaItems/prepare when the track is already buffered
from the cold-start pre-warm, so resuming the last song is instant (~0s)
instead of re-buffering from scratch (~10s).

Player: show pause icon during buffering (isPlaying=false, isBuffering=true)
so the button doesn't flash back to "play" between tracks. Also optimistically
set _nativePlaying=true and call setPlayIcon immediately on playCurrent so the
icon updates before the native callback round-trip.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
HoneyandClaude Sonnet 4.6 committed 2026-06-08 20:08:56 +02:00
1 parent 76efa393ea
commit 60e89fe3b6
2 files changed
+21 -7

No files matched your search

+7 -2
View File
@@ -189,9 +189,12 @@ window.NSPlayer = {
_nativePlaying = state.isPlaying;
if (!state.isPlaying && !state.isBuffering) _cancelScrobble();
if (state.isPlaying && S.previewCurrent) stopPreview(false);
// Show pause icon while buffering (isPlaying=false but isBuffering=true) so the
// button doesn't flash "play" during the brief re-buffer between tracks.
const showPlaying = state.isPlaying || state.isBuffering;
if (state.isPlaying !== prev) {
setPlayIcon(state.isPlaying);
document.getElementById('player-art')?.classList.toggle('spinning', state.isPlaying);
setPlayIcon(showPlaying);
document.getElementById('player-art')?.classList.toggle('spinning', showPlaying);
if (navigator.mediaSession)
navigator.mediaSession.playbackState = state.isPlaying ? 'playing' : 'paused';
}
@@ -374,8 +377,10 @@ export function playCurrent() {
if (HAS_BRIDGE) {
S._trackChanging = true;
_nativePlaying = true;
_resetProgressUI();
updatePlayerUI(s, true);
setPlayIcon(true);
onNpSongChange(s.id);
renderQueue();
try { window.NSBridge.setQueue(_nativeSingle(s), 0, true); } catch(_) {}