mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-12-04 05:39:57 -05:00
videos: address review — tighten auto-caption detection
- Require `line === 'auto'` in the auto-caption signature so a cue that is deliberately placed (e.g. `line:0` for top-edge) is left alone even if it is also `align:start position:0%`. YouTube auto-captions never set `line`. - For lazily-loaded language tracks, only detach the cuechange listener after the cue list is actually populated, in case a cuechange fires before cues load. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
16c457ebcb
commit
15787104fd
2 changed files with 23 additions and 7 deletions
|
|
@ -37,6 +37,19 @@ describe('centerAutoCaptions', () => {
|
|||
expect(track.cues[1].line).toBe(0);
|
||||
});
|
||||
|
||||
test('does not touch a left/bottom cue that was deliberately given a line', () => {
|
||||
// align:start + position:0 but an explicit line -> intentional placement, not the auto-caption
|
||||
// signature (YouTube never sets line). Must be left alone.
|
||||
const track = makeTrack([
|
||||
{align: 'start', position: 0, line: 0},
|
||||
]);
|
||||
|
||||
const changed = centerAutoCaptions(track);
|
||||
|
||||
expect(changed).toBe(0);
|
||||
expect(track.cues[0]).toEqual({align: 'start', position: 0, line: 0});
|
||||
});
|
||||
|
||||
test('handles a track with no cues yet (mode disabled)', () => {
|
||||
expect(centerAutoCaptions({cues: null})).toBe(0);
|
||||
expect(centerAutoCaptions(null)).toBe(0);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue