mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-05-26 00:55:16 -07:00
feat(config): add configuration window (#70)
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import type { SubtitleCue } from '../../types';
|
||||
|
||||
export function selectAutoplayStartupCue(
|
||||
cues: SubtitleCue[],
|
||||
currentTimeSeconds: number,
|
||||
lookaheadSeconds: number,
|
||||
): SubtitleCue | null {
|
||||
const currentTime = Math.max(0, Number.isFinite(currentTimeSeconds) ? currentTimeSeconds : 0);
|
||||
const lookahead = Math.max(0, Number.isFinite(lookaheadSeconds) ? lookaheadSeconds : 0);
|
||||
const latestStartTime = currentTime + lookahead;
|
||||
|
||||
for (const cue of cues) {
|
||||
if (!cue.text.trim()) {
|
||||
continue;
|
||||
}
|
||||
if (cue.startTime <= currentTime && cue.endTime > currentTime) {
|
||||
return cue;
|
||||
}
|
||||
}
|
||||
|
||||
for (const cue of cues) {
|
||||
if (!cue.text.trim()) {
|
||||
continue;
|
||||
}
|
||||
if (cue.startTime >= currentTime && cue.startTime <= latestStartTime) {
|
||||
return cue;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
Reference in New Issue
Block a user