fix: cover art caching, skip desync, notification tap opens now playing
- api.js: cache coverUrl() per id+size so WebView HTTP cache can work;
previously each call generated a new random salt/token → unique URL →
no cache hits → images re-fetched on every render
- player.js: replace _nsBridge('next')/'prev' with explicit seekToIndex
in nextSong/prevSong so native always jumps to the exact same index JS
computed; 'next'/'prev' relied on native's internal pointer being in sync
which caused 'UI shows new song but audio plays old one' when they drifted
- MusicService: set setSessionActivity PendingIntent on MediaSession so
tapping the playback notification opens the app
- MainActivity: handle open_now_playing extra in onCreate (cold start)
and onNewIntent (app already running) to show the Now Playing screen
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
66099c12f0
commit
ba382aa6d9
4 files changed
+58
-5
No files matched your search
+11
-1
@@ -16,6 +16,11 @@ export async function api(method, extra='') {
|
||||
return r;
|
||||
}
|
||||
export function streamUrl(id) { return apiUrl('stream', `&id=${id}&format=raw`); }
|
||||
|
||||
// Stable per-session cache so the same id+size always produces the same URL.
|
||||
// Consistent URLs let WebView's HTTP cache work — without this every render
|
||||
// generates a new token (random salt) and the image is re-fetched every time.
|
||||
const _coverUrlCache = new Map();
|
||||
export async function getLyricsBySongId(songId) {
|
||||
try {
|
||||
const r = await api('getLyricsBySongId', `&id=${songId}`);
|
||||
@@ -23,7 +28,12 @@ export async function getLyricsBySongId(songId) {
|
||||
} catch { return []; }
|
||||
}
|
||||
export function downloadUrl(id) { return apiUrl('download', `&id=${id}`); }
|
||||
export function coverUrl(id, size=300) { return id ? apiUrl('getCoverArt', `&id=${id}&size=${size}`) : null; }
|
||||
export function coverUrl(id, size=300) {
|
||||
if (!id) return null;
|
||||
const key = `${id}:${size}`;
|
||||
if (!_coverUrlCache.has(key)) _coverUrlCache.set(key, apiUrl('getCoverArt', `&id=${id}&size=${size}`));
|
||||
return _coverUrlCache.get(key);
|
||||
}
|
||||
|
||||
// ─── NAVIDROME REST AUTH ───
|
||||
export async function ndAuth() {
|
||||
|
||||
Reference in new issue
Block a user