music box fixes
This commit is contained in:
@@ -465,12 +465,17 @@ body {
|
||||
}
|
||||
|
||||
// ── State application ──
|
||||
let lastTrackIndex = null;
|
||||
// Dedupe by file URI, not s.index. MPD's status.song (s.index) is the
|
||||
// queue position and shifts mid-playback when the queue is reordered
|
||||
// (consume mode removes the prior track → later indices shift down,
|
||||
// mpc shuffle reshuffles, etc.) — using it caused duplicate "now: …"
|
||||
// lines for a single playthrough.
|
||||
let lastTrackFile = null;
|
||||
function applyState(s) {
|
||||
if (lastTrackIndex !== null && s.index !== lastTrackIndex && s.title) {
|
||||
if (lastTrackFile !== null && s.file && s.file !== lastTrackFile && s.title) {
|
||||
logBeforePins(`[audio] now: ${s.title}`);
|
||||
}
|
||||
lastTrackIndex = s.index;
|
||||
if (s.file) lastTrackFile = s.file;
|
||||
|
||||
npTitle.textContent = s.title || '—';
|
||||
npTime.textContent = `[${fmtClock(s.currentTime)} / ${fmtClock(s.duration)}]`;
|
||||
|
||||
@@ -662,10 +662,10 @@ body {
|
||||
}
|
||||
|
||||
function renderState(s) {
|
||||
if (lastTrackIndex !== null && s.index !== lastTrackIndex && s.title) {
|
||||
if (lastTrackFile !== null && s.file && s.file !== lastTrackFile && s.title) {
|
||||
logBeforePins(`[audio] now: ${s.title}`);
|
||||
}
|
||||
lastTrackIndex = s.index;
|
||||
if (s.file) lastTrackFile = s.file;
|
||||
|
||||
// Terminal pinned block
|
||||
npTitle.textContent = s.title || '—';
|
||||
@@ -829,7 +829,10 @@ body {
|
||||
}
|
||||
|
||||
// ── State application ──
|
||||
let lastTrackIndex = null;
|
||||
// Dedupe by file URI, not s.index — MPD's status.song shifts mid-playback
|
||||
// when the queue is reordered (consume mode, mpc shuffle, etc.), which
|
||||
// would otherwise cause duplicate "now: …" lines for one playthrough.
|
||||
let lastTrackFile = null;
|
||||
function applyState(s) {
|
||||
pendingState = s;
|
||||
if (!bootStarted) {
|
||||
|
||||
@@ -249,12 +249,13 @@ body {
|
||||
pruneTerminal();
|
||||
}
|
||||
|
||||
let lastTrackIndex = null;
|
||||
// Dedupe by file URI, not s.index — see music-box/index.html for context.
|
||||
let lastTrackFile = null;
|
||||
function applyState(s) {
|
||||
if (lastTrackIndex !== null && s.index !== lastTrackIndex && s.title) {
|
||||
if (lastTrackFile !== null && s.file && s.file !== lastTrackFile && s.title) {
|
||||
logBeforePins(`[audio] now: ${s.title}`);
|
||||
}
|
||||
lastTrackIndex = s.index;
|
||||
if (s.file) lastTrackFile = s.file;
|
||||
|
||||
npTitle.textContent = s.title || '—';
|
||||
npTime.textContent = `[${fmtClock(s.currentTime)} / ${fmtClock(s.duration)}]`;
|
||||
|
||||
Reference in New Issue
Block a user