Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/text/vtt_text_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,6 @@ shaka.text.VttTextParser = class {
// Only use 'X-TIMESTAMP-MAP' with HLS.
if (blocks[0].includes('X-TIMESTAMP-MAP')) {
offset = this.computeHlsOffset_(blocks[0], time);
} else if (time.periodStart && time.vttOffset == time.periodStart) {
// In the case where X-TIMESTAMP-MAP is not used and it is HLS, we
// should not use offset unless segment-relative times are used.
offset = 0;
}
}

Expand Down Expand Up @@ -398,6 +394,10 @@ shaka.text.VttTextParser = class {
start += timeOffset;
end += timeOffset;

if (start < 0) {
start = 0;
}

// Get the payload.
const payload = text.slice(1).join('\n').trim();

Expand Down
12 changes: 6 additions & 6 deletions test/hls/hls_parser_integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,12 @@ describe('HlsParser', () => {

const cues = video.textTracks[0].cues;
expect(cues.length).toBe(3);
expect(cues[0].startTime).toBeCloseTo(0.6, 0);
expect(cues[0].endTime).toBeCloseTo(2.88, 0);
expect(cues[1].startTime).toBeCloseTo(2.88, 0);
expect(cues[1].endTime).toBeCloseTo(6.36, 0);
expect(cues[2].startTime).toBeCloseTo(6.36, 0);
expect(cues[2].endTime).toBeCloseTo(10.68, 0);
expect(cues[0].startTime).toBeCloseTo(0, 0);
expect(cues[0].endTime).toBeCloseTo(1.48, 0);
expect(cues[1].startTime).toBeCloseTo(1.48, 0);
expect(cues[1].endTime).toBeCloseTo(4.96, 0);
expect(cues[2].startTime).toBeCloseTo(4.96, 0);
expect(cues[2].endTime).toBeCloseTo(9.28, 0);

await player.unload();
});
Expand Down
Loading