fix: player bar instant update + stop music on app close
player.js: move NSBridge.setQueue() into requestAnimationFrame so the updatePlayerUI DOM changes are committed and painted before the blocking @JavascriptInterface call. setQueue serializes a large JSON payload and blocks the JS/Blink main thread while Java parses it — deferring it one frame ensures the player bar visually updates immediately on tap. MusicService: onTaskRemoved now calls player.stop() + stopSelf() so swiping the app from recents stops playback instead of leaving it running in the background. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
7084fc4118
commit
8e752fa892
2 files changed
+12
-5
No files matched your search
+10
-3
@@ -244,9 +244,16 @@ export function playQueue(songs, startIdx) {
|
||||
const s = S.queue[S.qIdx];
|
||||
if (s) { updatePlayerUI(s, true); onNpSongChange(s.id); }
|
||||
renderQueue();
|
||||
try {
|
||||
window.NSBridge.setQueue(JSON.stringify(buildTrackList()), startIdx, true);
|
||||
} catch (e) { console.warn('NSBridge.setQueue failed', e); }
|
||||
// Build the track list now (before rAF) while S.queue is current.
|
||||
const trackListJson = JSON.stringify(buildTrackList());
|
||||
// Defer the NSBridge call to AFTER the current render frame so the
|
||||
// updatePlayerUI DOM changes are committed and visible before the
|
||||
// @JavascriptInterface call (which blocks the JS thread while Java
|
||||
// parses the JSON and creates MediaItems).
|
||||
requestAnimationFrame(() => {
|
||||
try { window.NSBridge.setQueue(trackListJson, startIdx, true); }
|
||||
catch (e) { console.warn('NSBridge.setQueue failed', e); }
|
||||
});
|
||||
if (S.radioMode) fillRadioQueue();
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user