fix: sync queue insert/append to native Android player
Both 'Als Nächstes einfügen' and 'Am Ende der Queue' updated S.queue in JS but never called NSBridge, so the native ExoPlayer ignored the change and kept playing the original next item. - Export nativeInsertAt(song, position) from player.js - Call it in showCtxMenu with the exact splice index for insert-next and -1 (append) for add-to-end Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
e893b7cc12
commit
68bec67880
2 files changed
+13
-3
No files matched your search
@@ -49,6 +49,12 @@ function _pushQueueIfBridge() {
|
|||||||
} catch (e) { console.warn('NSBridge.setQueue failed', e); }
|
} catch (e) { console.warn('NSBridge.setQueue failed', e); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Insert a single song into the native queue at the given index (-1 = append).
|
||||||
|
export function nativeInsertAt(song, position) {
|
||||||
|
if (!HAS_BRIDGE) return;
|
||||||
|
try { window.NSBridge.addToQueue(JSON.stringify(_trackToNative(song)), position); } catch(_) {}
|
||||||
|
}
|
||||||
|
|
||||||
// Convert a single Navidrome song to the NSBridge Track schema (used for addToQueue).
|
// Convert a single Navidrome song to the NSBridge Track schema (used for addToQueue).
|
||||||
function _trackToNative(s) {
|
function _trackToNative(s) {
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { esc, formatDur, toast } from './utils.js';
|
|||||||
import { api, coverUrl, ndAuth } from './api.js';
|
import { api, coverUrl, ndAuth } from './api.js';
|
||||||
import { THEMES, applyTheme, getCurrentThemeId } from './themes.js';
|
import { THEMES, applyTheme, getCurrentThemeId } from './themes.js';
|
||||||
// Circular imports — safe (only used inside function bodies)
|
// Circular imports — safe (only used inside function bodies)
|
||||||
import { playQueue, dlSongLocal, toggleStar, togglePlay, renderQueue, syncNpStar, updateStarBtn, npToggleStar, playCurrent, _syncNpDirect, setPlayIcon } from './player.js';
|
import { playQueue, dlSongLocal, toggleStar, togglePlay, renderQueue, syncNpStar, updateStarBtn, npToggleStar, playCurrent, _syncNpDirect, setPlayIcon, nativeInsertAt } from './player.js';
|
||||||
import { navigate, loadPlaylists } from './views.js';
|
import { navigate, loadPlaylists } from './views.js';
|
||||||
|
|
||||||
// ─── SIDEBAR ───
|
// ─── SIDEBAR ───
|
||||||
@@ -115,11 +115,15 @@ export function showCtxMenu(e, song, list, idx) {
|
|||||||
const items = [
|
const items = [
|
||||||
{ icon: '▶', label: 'Abspielen', fn: () => playQueue(list, idx) },
|
{ icon: '▶', label: 'Abspielen', fn: () => playQueue(list, idx) },
|
||||||
{ icon: '+', label: 'Als Nächstes einfügen', fn: () => {
|
{ icon: '+', label: 'Als Nächstes einfügen', fn: () => {
|
||||||
S.queue.splice(S.qIdx+1, 0, {...song});
|
const insertIdx = S.qIdx + 1;
|
||||||
|
S.queue.splice(insertIdx, 0, {...song});
|
||||||
|
nativeInsertAt(song, insertIdx);
|
||||||
renderQueue(); toast('In Warteschlange eingefügt');
|
renderQueue(); toast('In Warteschlange eingefügt');
|
||||||
}},
|
}},
|
||||||
{ icon: '⬇', label: 'Am Ende der Queue', fn: () => {
|
{ icon: '⬇', label: 'Am Ende der Queue', fn: () => {
|
||||||
S.queue.push({...song}); renderQueue(); toast('Zur Queue hinzugefügt');
|
S.queue.push({...song});
|
||||||
|
nativeInsertAt(song, -1);
|
||||||
|
renderQueue(); toast('Zur Queue hinzugefügt');
|
||||||
}},
|
}},
|
||||||
{ sep: true },
|
{ sep: true },
|
||||||
{ icon: '🎶', label: 'Zu Playlist hinzufügen →', submenu: true, fn: () => openPlModal([song]) },
|
{ icon: '🎶', label: 'Zu Playlist hinzufügen →', submenu: true, fn: () => openPlModal([song]) },
|
||||||
|
|||||||
Reference in new issue
Block a user