fix: cover art on auto-advance + native back-button overlay routing

Issue 1 (MusicService): wrap DefaultHttpDataSource in CacheBitmapLoader so
Media3 notification artwork is fetched once and served from memory on every
subsequent auto-advance. warmArtworkCache() pre-loads current+next 3 tracks
on both onMediaItemTransition and onTimelineChanged (queue replace via setQueue).
Adds explicit media3-datasource dependency.

Issue 2 (back button): replace deprecated onKeyDown with OnBackPressedCallback.
WebBridge.setOverlayState(bool) tracks whether JS has an overlay open;
consumeBackPress() is called first — if true, MainActivity delegates to
window.NSPlayer.handleBack() which closes the topmost layer. Falls back to
webView.goBack() then moveTaskToBack(true) so the MusicService binding survives.
JS side: _syncOverlayState() + MutationObserver keep the native flag current;
handleBack covers NP overlay, queue panel, action sheet, all modals, sidebar.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
HoneyandClaude Sonnet 4.6 committed 2026-05-09 11:11:09 +02:00
1 parent 76ecfe2268
commit cf2921c56f
7 files changed
+178 -10

No files matched your search

+3 -1
View File
@@ -2,7 +2,7 @@ import { S } from './state.js';
import { esc } from './utils.js';
import { coverUrl } from './api.js';
// Circular imports — safe (only used inside function bodies)
import { playCurrent, _syncNpDirect, dlSongLocal, npToggleStar } from './player.js';
import { playCurrent, _syncNpDirect, dlSongLocal, npToggleStar, _syncOverlayState } from './player.js';
import { navigate } from './views.js';
import { openPlModal, showSongInfo } from './ui.js';
@@ -13,6 +13,7 @@ export function openNowPlaying() {
overlay.classList.add('open');
if(S.npQueueMode) switchNpTab('player');
syncNowPlaying();
_syncOverlayState();
if(!overlay._swipeAttached) {
overlay._swipeAttached = true;
let startY=0, startT=0, dragging=false;
@@ -42,6 +43,7 @@ export function closeNowPlaying() {
const overlay = document.getElementById('np-overlay');
overlay.style.transform = '';
overlay.classList.remove('open');
_syncOverlayState();
}
export function syncNowPlaying() {