From 74447f58a5fc6be7b9575fe1ac340972369bb7ab Mon Sep 17 00:00:00 2001 From: Matthew Neil Date: Wed, 5 Jul 2017 15:29:56 -0400 Subject: [PATCH 1/2] add program-date-time tag info to parsed segments --- src/parser.js | 12 ++++++++++-- test/fixtures/m3u8/dateTime.js | 9 +++++++++ test/fixtures/m3u8/dateTime.m3u8 | 5 ++++- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/parser.js b/src/parser.js index aea81d5..98b1e40 100644 --- a/src/parser.js +++ b/src/parser.js @@ -267,8 +267,16 @@ export default class Parser extends Stream { this.manifest.discontinuityStarts.push(uris.length); }, 'program-date-time'() { - this.manifest.dateTimeString = entry.dateTimeString; - this.manifest.dateTimeObject = entry.dateTimeObject; + if (typeof this.manifest.dateTimeString === 'undefined') { + // PROGRAM-DATE-TIME is a media-segment tag, but for backwards + // compatibility, we add the first occurance of the PROGRAM-DATE-TIME tag + // to the manifest object + this.manifest.dateTimeString = entry.dateTimeString; + this.manifest.dateTimeObject = entry.dateTimeObject; + } + + currentUri.dateTimeString = entry.dateTimeString; + currentUri.dateTimeObject = entry.dateTimeObject; }, targetduration() { if (!isFinite(entry.duration) || entry.duration < 0) { diff --git a/test/fixtures/m3u8/dateTime.js b/test/fixtures/m3u8/dateTime.js index b7e1166..ac8b3c5 100644 --- a/test/fixtures/m3u8/dateTime.js +++ b/test/fixtures/m3u8/dateTime.js @@ -4,6 +4,15 @@ "playlistType": "VOD", "segments": [ { + "dateTimeString": "2016-06-22T09:20:16.166-04:00", + "dateTimeObject": new Date("2016-06-22T09:20:16.166-04:00"), + "duration": 10, + "timeline": 0, + "uri": "hls_450k_video.ts" + }, + { + "dateTimeString": "2016-06-22T09:20:26.166-04:00", + "dateTimeObject": new Date("2016-06-22T09:20:26.166-04:00"), "duration": 10, "timeline": 0, "uri": "hls_450k_video.ts" diff --git a/test/fixtures/m3u8/dateTime.m3u8 b/test/fixtures/m3u8/dateTime.m3u8 index 53434c3..f3b8f6c 100644 --- a/test/fixtures/m3u8/dateTime.m3u8 +++ b/test/fixtures/m3u8/dateTime.m3u8 @@ -1,9 +1,12 @@ #EXTM3U #EXT-X-PLAYLIST-TYPE:VOD #EXT-X-MEDIA-SEQUENCE:0 -#EXT-X-PROGRAM-DATE-TIME:2016-06-22T09:20:16.166-04:00 #EXT-X-ALLOW-CACHE:NO #EXT-X-TARGETDURATION:10 +#EXT-X-PROGRAM-DATE-TIME:2016-06-22T09:20:16.166-04:00 +#EXTINF:10 +hls_450k_video.ts +#EXT-X-PROGRAM-DATE-TIME:2016-06-22T09:20:26.166-04:00 #EXTINF:10 hls_450k_video.ts #EXT-X-ENDLIST From cbb37628b02760fe15747eedfae740d8f2114979 Mon Sep 17 00:00:00 2001 From: Matthew Neil Date: Wed, 11 Oct 2017 11:06:24 -0400 Subject: [PATCH 2/2] update comment --- src/parser.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/parser.js b/src/parser.js index 98b1e40..ded9eca 100644 --- a/src/parser.js +++ b/src/parser.js @@ -269,8 +269,9 @@ export default class Parser extends Stream { 'program-date-time'() { if (typeof this.manifest.dateTimeString === 'undefined') { // PROGRAM-DATE-TIME is a media-segment tag, but for backwards - // compatibility, we add the first occurance of the PROGRAM-DATE-TIME tag + // compatibility, we add the first occurence of the PROGRAM-DATE-TIME tag // to the manifest object + // TODO: Consider removing this in future major version this.manifest.dateTimeString = entry.dateTimeString; this.manifest.dateTimeObject = entry.dateTimeObject; }