Skip to content

Commit

Permalink
fix: Fix WebVTT parser failure on REGION blocks (shaka-project#4915)
Browse files Browse the repository at this point in the history
We do not yet support VTT region settings, but we should still not fail
when a region block appears in a VTT file.

Related to work on PR shaka-project#4767
  • Loading branch information
joeyparrish committed Jan 19, 2023
1 parent ed47c60 commit da84a2c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/text/vtt_text_parser.js
Expand Up @@ -337,8 +337,8 @@ shaka.text.VttTextParser = class {
return null;
}

// Skip style blocks.
if (text[0] == 'STYLE') {
// Skip style and region blocks.
if (text[0] == 'STYLE' || text[0] == 'REGION') {
return null;
}

Expand Down
16 changes: 16 additions & 0 deletions test/text/vtt_text_parser_unit.js
Expand Up @@ -1181,6 +1181,22 @@ describe('VttTextParser', () => {
{periodStart: 0, segmentStart: 0, segmentEnd: 0, vttOffset: 0});
});

it('does not fail on REGION blocks', () => {
verifyHelper(
[
{
startTime: 10, endTime: 20,
payload: 'test',
},
],
'WEBVTT\n\n' +
'REGION\n' +
'id:1\n\n' +
'00:00:10.000 --> 00:00:20.000\n' +
'test\n\n',
{periodStart: 0, segmentStart: 0, segmentEnd: 0, vttOffset: 0});
});

/**
* @param {!Array} cues
* @param {string} text
Expand Down

0 comments on commit da84a2c

Please sign in to comment.