diff --git a/src/nowplaying.js b/src/nowplaying.js index 67b0c15..0bc6cba 100644 --- a/src/nowplaying.js +++ b/src/nowplaying.js @@ -8,6 +8,15 @@ import { openPlModal, showSongInfo } from './ui.js'; // ─── NOW PLAYING OVERLAY ─── export function openNowPlaying() { + // On Android, onTrackChanged is async — query native for the current index + // before rendering so we never show the previous song for a flash. + if (typeof window.NSBridge !== 'undefined') { + try { + const state = JSON.parse(window.NSBridge.getState() || '{}'); + if (typeof state.currentIndex === 'number' && state.currentIndex >= 0 && state.currentIndex < S.queue.length) + S.qIdx = state.currentIndex; + } catch {} + } S.npOpen = true; const overlay = document.getElementById('np-overlay'); overlay.classList.add('open');