diff --git a/src/parse-stream.js b/src/parse-stream.js index 8890680..18f83e5 100644 --- a/src/parse-stream.js +++ b/src/parse-stream.js @@ -3,6 +3,8 @@ */ import Stream from '@videojs/vhs-utils/es/stream.js'; +const TAB = String.fromCharCode(0x09); + /** * "forgiving" attribute list psuedo-grammar: * attributes -> keyvalue (',' keyvalue)* @@ -442,6 +444,26 @@ export default class ParseStream extends Stream { this.trigger('data', event); return; } + match = (/^#EXT-X-SKIP:(.*)$/).exec(newLine); + if (match && match[1]) { + event = { + type: 'tag', + tagType: 'skip' + }; + event.attributes = parseAttributes(match[1]); + + if (event.attributes.hasOwnProperty('SKIPPED-SEGMENTS')) { + event.attributes['SKIPPED-SEGMENTS'] = parseInt(event.attributes['SKIPPED-SEGMENTS'], 10); + } + + if (event.attributes.hasOwnProperty('RECENTLY-REMOVED-DATERANGES')) { + event.attributes['RECENTLY-REMOVED-DATERANGES'] = + event.attributes['RECENTLY-REMOVED-DATERANGES'].split(TAB); + } + + this.trigger('data', event); + return; + } // unknown tag type this.trigger('data', { diff --git a/src/parser.js b/src/parser.js index de67f5f..1c4e36a 100644 --- a/src/parser.js +++ b/src/parser.js @@ -383,6 +383,9 @@ export default class Parser extends Stream { }, 'cue-in'() { currentUri.cueIn = entry.data; + }, + 'skip'() { + this.manifest.skip = entry.attributes; } })[entry.tagType] || noop).call(self); }, diff --git a/test/fixtures/m3u8/llhlsDelta.json b/test/fixtures/m3u8/llhlsDelta.json index 0528896..e68928e 100644 --- a/test/fixtures/m3u8/llhlsDelta.json +++ b/test/fixtures/m3u8/llhlsDelta.json @@ -29,5 +29,12 @@ "uri": "fileSequence272.mp4" } ], + "skip": { + "SKIPPED-SEGMENTS": 3, + "RECENTLY-REMOVED-DATERANGES": [ + "foo", + "bar" + ] + }, "targetDuration": 4 }