Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add program-date-time tag info to parsed segments #27

Merged
merged 2 commits into from
Feb 23, 2018
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
13 changes: 11 additions & 2 deletions src/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,17 @@ 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add a TODO notice for the next major version to remove this

// 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;
}

currentUri.dateTimeString = entry.dateTimeString;
currentUri.dateTimeObject = entry.dateTimeObject;
},
targetduration() {
if (!isFinite(entry.duration) || entry.duration < 0) {
Expand Down
9 changes: 9 additions & 0 deletions test/fixtures/m3u8/dateTime.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 4 additions & 1 deletion test/fixtures/m3u8/dateTime.m3u8
Original file line number Diff line number Diff line change
@@ -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