update now playing screen

This commit is contained in:
Boof2015
2026-07-12 16:53:40 -04:00
parent 804e47a7ca
commit 34e9cde5bc
26 changed files with 1482 additions and 447 deletions
Binary file not shown.
+10
View File
@@ -3,6 +3,7 @@ import test from 'node:test';
import type { LyricsLine, LyricsPayload } from './types.ts';
import {
findActiveSyncedLineIndex,
getActiveSyncedLyricsLine,
getCompensatedLyricsTime,
getLyricsLineSeekTimeSeconds,
getLyricsMetaChipText,
@@ -48,6 +49,15 @@ test('a long instrumental gap inserts a synthetic gap row and neutralizes', () =
const timing = resolveSyncedLyricsTiming(withGap, 6);
assert.equal(timing.activeLineIndex, -1);
assert.equal(timing.isNeutral, true);
assert.equal(getActiveSyncedLyricsLine(withGap, 6), null);
});
test('compact lyric peek resolves the raw active cue', () => {
assert.equal(getActiveSyncedLyricsLine(lines(), 1.2)?.text, 'B');
assert.equal(
getActiveSyncedLyricsLine([{ timestampMs: 5000, text: 'later' }], 1),
null
);
});
test('translation selection honors the language priority list', () => {
+14
View File
@@ -29,6 +29,8 @@ export function getLyricsPayloadSourceLabel(payload: LyricsPayload): string {
export const LYRICS_INFERRED_GAP_THRESHOLD_MS = 10_000;
export const LYRICS_POST_LINE_HOLD_MS = 4_000;
/** Shared display compensation for the full lyrics view and compact lyric peek. */
export const LYRICS_DISPLAY_LEAD_MS = 350;
export interface RenderableSyncedLine {
line: LyricsLine;
@@ -406,6 +408,18 @@ export function findActiveSyncedLineIndex(
return resolveSyncedLyricsTiming(lines, currentTimeSeconds, options).activeLineIndex;
}
/** The raw active lyric cue, or null while playback is in a neutral gap. */
export function getActiveSyncedLyricsLine(
lines: LyricsLine[],
currentTimeSeconds: number,
options: SyncedLyricsTimingOptions = {}
): LyricsLine | null {
const timing = resolveSyncedLyricsTiming(lines, currentTimeSeconds, options);
if (timing.isNeutral || timing.activeCueIndex < 0) return null;
const line = lines[timing.activeCueIndex] ?? null;
return line && isRenderableSyncedLine(line) ? line : null;
}
/**
* The "MANUAL XLRC • SYNCED" style status chip. Trimmed from the desktop
* variant so it takes only the pieces the mobile band has, not the full Track.