mirror of
https://github.com/Boof2015/astra-mobile.git
synced 2026-08-20 04:30:54 +02:00
update now playing screen
This commit is contained in:
Binary file not shown.
@@ -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', () => {
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user