Skip to content

Commit

Permalink
playlist-loader: parses playlists with #EXT-X-PROGRAM-DATE-TIME after…
Browse files Browse the repository at this point in the history
… #EXTINF before fragment URL

related to https://github.com/dailymotion/hls.js/issues/460
  • Loading branch information
mangui committed Jun 9, 2016
1 parent fe0e38a commit 82c18aa
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/loader/playlist-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,10 @@ class PlaylistLoader extends EventHandler {
case 'PROGRAM-DATE-TIME':
programDateTime = new Date(Date.parse(result[1]));
tagList.push(result);
if (frag && !frag.url && result.length >= 3) {
frag.url = this.resolve(result[2], baseurl);
frag.programDateTime = programDateTime;
}
break;
default:
tagList.push(result);
Expand Down
25 changes: 25 additions & 0 deletions tests/unit/loader/playlist-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -440,4 +440,29 @@ http://dummy.url.com/hls/live/segment/segment_022916_164500865_719935.ts`;
assert.strictEqual(result.fragments[8].url, 'http://dummy.url.com/hls/live/segment/segment_022916_164500865_719934.ts');
});

it('parses playlists with #EXT-X-PROGRAM-DATE-TIME after #EXTINF before fragment URL', () => {
var level = `#EXTM3U
#EXT-X-VERSION:2
#EXT-X-TARGETDURATION:10
#EXT-X-MEDIA-SEQUENCE:69844067
#EXTINF:10, no desc
#EXT-X-PROGRAM-DATE-TIME:2016-05-27T16:34:44Z
Rollover38803/20160525T064049-01-69844067.ts
#EXTINF:10, no desc
#EXT-X-PROGRAM-DATE-TIME:2016-05-27T16:34:54Z
Rollover38803/20160525T064049-01-69844068.ts
#EXTINF:10, no desc
#EXT-X-PROGRAM-DATE-TIME:2016-05-27T16:35:04Z
Rollover38803/20160525T064049-01-69844069.ts
`;
var result = new PlaylistLoader({on : function() { }}).parseLevelPlaylist(level, 'http://video.example.com/disc.m3u8',0);
assert.strictEqual(result.fragments.length, 3);
assert.strictEqual(result.totalduration, 30);
assert.strictEqual(result.fragments[0].url, 'http://video.example.com/Rollover38803/20160525T064049-01-69844067.ts');
assert.strictEqual(result.fragments[0].programDateTime.getTime(), 1464366884000);
assert.strictEqual(result.fragments[1].url, 'http://video.example.com/Rollover38803/20160525T064049-01-69844068.ts');
assert.strictEqual(result.fragments[1].programDateTime.getTime(), 1464366894000);
assert.strictEqual(result.fragments[2].url, 'http://video.example.com/Rollover38803/20160525T064049-01-69844069.ts');
assert.strictEqual(result.fragments[2].programDateTime.getTime(), 1464366904000);
});
});

0 comments on commit 82c18aa

Please sign in to comment.