diff --git a/src/nowplaying.js b/src/nowplaying.js index d591e67..b37e3b2 100644 --- a/src/nowplaying.js +++ b/src/nowplaying.js @@ -8,21 +8,6 @@ import { openPlModal, showSongInfo } from './ui.js'; // ─── NOW PLAYING OVERLAY ─── export function openNowPlaying() { - // On Android, verify the snapshot index before using it — the MediaController - // snapshot can lag behind ExoPlayer by one track on auto-advance. Only accept - // it when the song ID at that position matches (i.e. snapshot is not stale). - if (typeof window.NSBridge !== 'undefined') { - try { - const state = JSON.parse(window.NSBridge.getState() || '{}'); - const snapIdx = state.currentIndex; - const snapId = state.currentId || ''; - if (typeof snapIdx === 'number' && snapIdx >= 0 && snapIdx < S.queue.length) { - const expected = S.queue[snapIdx]; - if (!snapId || !expected?.id || String(snapId) === String(expected.id)) - S.qIdx = snapIdx; - } - } catch {} - } S.npOpen = true; const overlay = document.getElementById('np-overlay'); overlay.classList.add('open'); diff --git a/src/player.js b/src/player.js index dd8a8a0..cc4e30c 100644 --- a/src/player.js +++ b/src/player.js @@ -3,7 +3,7 @@ import { esc, formatDur, toast } from './utils.js'; import { api, streamUrl, coverUrl, downloadUrl, dispTitle, dispArtist, dispArtistParts, dispAlbum } from './api.js'; // views.js/ui.js circular imports — safe (only used inside function bodies) import { loadRecommendations } from './views.js'; -import { updateLyricsHighlight, onNpSongChange } from './nowplaying.js'; +import { updateLyricsHighlight, onNpSongChange, syncNowPlaying } from './nowplaying.js'; // ─── NATIVE BRIDGE DETECTION ─────────────────────────────────────────────── // True when running inside the NovaSonic Android wrapper (NSBridge injected before loadUrl). @@ -203,6 +203,7 @@ window.NSPlayer = { const s = S.queue[S.qIdx]; if (!s) return; updatePlayerUI(s, true); + syncNowPlaying(); onNpSongChange(s.id); if (indexChanged) renderQueue(); // Schedule scrobble — fires after 12s of uninterrupted playback.