mirror of
https://github.com/videojs/m3u8-parser.git
synced 2026-06-06 08:22:33 +00:00
Compare commits
2 commits
main
...
fix/dateTi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4500ab1185 | ||
|
|
2341b4fcd2 |
7 changed files with 38 additions and 0 deletions
|
|
@ -108,6 +108,8 @@ Manifest {
|
||||||
'CLOSED-CAPTIONS': {},
|
'CLOSED-CAPTIONS': {},
|
||||||
SUBTITLES: {}
|
SUBTITLES: {}
|
||||||
},
|
},
|
||||||
|
dateTimeString: string,
|
||||||
|
dateTimeObject: Date,
|
||||||
targetDuration: number,
|
targetDuration: number,
|
||||||
totalDuration: number,
|
totalDuration: number,
|
||||||
discontinuityStarts: [number],
|
discontinuityStarts: [number],
|
||||||
|
|
|
||||||
|
|
@ -356,6 +356,7 @@ export default class ParseStream extends Stream {
|
||||||
};
|
};
|
||||||
if (match[1]) {
|
if (match[1]) {
|
||||||
event.dateTimeString = match[1];
|
event.dateTimeString = match[1];
|
||||||
|
event.dateTimeObject = new Date(match[1]);
|
||||||
}
|
}
|
||||||
this.trigger('data', event);
|
this.trigger('data', event);
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -459,6 +459,17 @@ export default class Parser extends Stream {
|
||||||
this.manifest.discontinuityStarts.push(uris.length);
|
this.manifest.discontinuityStarts.push(uris.length);
|
||||||
},
|
},
|
||||||
'program-date-time'() {
|
'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 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;
|
||||||
|
|
||||||
const { lastProgramDateTime } = this;
|
const { lastProgramDateTime } = this;
|
||||||
|
|
||||||
this.lastProgramDateTime = new Date(entry.dateTimeString).getTime();
|
this.lastProgramDateTime = new Date(entry.dateTimeString).getTime();
|
||||||
|
|
|
||||||
6
test/fixtures/integration/dateTime.js
vendored
6
test/fixtures/integration/dateTime.js
vendored
|
|
@ -5,12 +5,16 @@ module.exports = {
|
||||||
playlistType: 'VOD',
|
playlistType: 'VOD',
|
||||||
segments: [
|
segments: [
|
||||||
{
|
{
|
||||||
|
dateTimeString: '2016-06-22T09:20:16.166-04:00',
|
||||||
|
dateTimeObject: new Date('2016-06-22T09:20:16.166-04:00'),
|
||||||
programDateTime: 1466601616166,
|
programDateTime: 1466601616166,
|
||||||
duration: 10,
|
duration: 10,
|
||||||
timeline: 0,
|
timeline: 0,
|
||||||
uri: 'hls_450k_video.ts'
|
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'),
|
||||||
programDateTime: 1466601626166,
|
programDateTime: 1466601626166,
|
||||||
duration: 10,
|
duration: 10,
|
||||||
timeline: 0,
|
timeline: 0,
|
||||||
|
|
@ -19,6 +23,8 @@ module.exports = {
|
||||||
],
|
],
|
||||||
targetDuration: 10,
|
targetDuration: 10,
|
||||||
endList: true,
|
endList: true,
|
||||||
|
dateTimeString: '2016-06-22T09:20:16.166-04:00',
|
||||||
|
dateTimeObject: new Date('2016-06-22T09:20:16.166-04:00'),
|
||||||
discontinuitySequence: 0,
|
discontinuitySequence: 0,
|
||||||
discontinuityStarts: []
|
discontinuityStarts: []
|
||||||
};
|
};
|
||||||
|
|
|
||||||
6
test/fixtures/integration/llhls.js
vendored
6
test/fixtures/integration/llhls.js
vendored
|
|
@ -1,5 +1,7 @@
|
||||||
module.exports = {
|
module.exports = {
|
||||||
allowCache: true,
|
allowCache: true,
|
||||||
|
dateTimeObject: new Date('2019-02-14T02:13:36.106Z'),
|
||||||
|
dateTimeString: '2019-02-14T02:13:36.106Z',
|
||||||
dateRanges: [],
|
dateRanges: [],
|
||||||
discontinuitySequence: 0,
|
discontinuitySequence: 0,
|
||||||
discontinuityStarts: [],
|
discontinuityStarts: [],
|
||||||
|
|
@ -37,6 +39,8 @@ module.exports = {
|
||||||
partTargetDuration: 0.33334,
|
partTargetDuration: 0.33334,
|
||||||
segments: [
|
segments: [
|
||||||
{
|
{
|
||||||
|
dateTimeObject: new Date('2019-02-14T02:13:36.106Z'),
|
||||||
|
dateTimeString: '2019-02-14T02:13:36.106Z',
|
||||||
programDateTime: 1550110416106,
|
programDateTime: 1550110416106,
|
||||||
duration: 4.00008,
|
duration: 4.00008,
|
||||||
map: {
|
map: {
|
||||||
|
|
@ -143,6 +147,8 @@ module.exports = {
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
dateTimeObject: new Date('2019-02-14T02:14:00.106Z'),
|
||||||
|
dateTimeString: '2019-02-14T02:14:00.106Z',
|
||||||
duration: 4.00008,
|
duration: 4.00008,
|
||||||
map: {
|
map: {
|
||||||
uri: 'init.mp4'
|
uri: 'init.mp4'
|
||||||
|
|
|
||||||
4
test/fixtures/integration/llhlsDelta.js
vendored
4
test/fixtures/integration/llhlsDelta.js
vendored
|
|
@ -1,5 +1,7 @@
|
||||||
module.exports = {
|
module.exports = {
|
||||||
allowCache: true,
|
allowCache: true,
|
||||||
|
dateTimeObject: new Date('2019-02-14T02:14:00.106Z'),
|
||||||
|
dateTimeString: '2019-02-14T02:14:00.106Z',
|
||||||
dateRanges: [],
|
dateRanges: [],
|
||||||
discontinuitySequence: 0,
|
discontinuitySequence: 0,
|
||||||
discontinuityStarts: [],
|
discontinuityStarts: [],
|
||||||
|
|
@ -110,6 +112,8 @@ module.exports = {
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
dateTimeObject: new Date('2019-02-14T02:14:00.106Z'),
|
||||||
|
dateTimeString: '2019-02-14T02:14:00.106Z',
|
||||||
duration: 4.00008,
|
duration: 4.00008,
|
||||||
programDateTime: 1550110440106,
|
programDateTime: 1550110440106,
|
||||||
timeline: 0,
|
timeline: 0,
|
||||||
|
|
|
||||||
|
|
@ -635,6 +635,10 @@ QUnit.test(
|
||||||
element.dateTimeString, '2016-06-22T09:20:16.166-04:00',
|
element.dateTimeString, '2016-06-22T09:20:16.166-04:00',
|
||||||
'dateTimeString is parsed'
|
'dateTimeString is parsed'
|
||||||
);
|
);
|
||||||
|
assert.deepEqual(
|
||||||
|
element.dateTimeObject, new Date('2016-06-22T09:20:16.166-04:00'),
|
||||||
|
'dateTimeObject is parsed'
|
||||||
|
);
|
||||||
|
|
||||||
manifest = '#EXT-X-PROGRAM-DATE-TIME:2016-06-22T09:20:16.16389Z\n';
|
manifest = '#EXT-X-PROGRAM-DATE-TIME:2016-06-22T09:20:16.16389Z\n';
|
||||||
this.lineStream.push(manifest);
|
this.lineStream.push(manifest);
|
||||||
|
|
@ -646,6 +650,10 @@ QUnit.test(
|
||||||
element.dateTimeString, '2016-06-22T09:20:16.16389Z',
|
element.dateTimeString, '2016-06-22T09:20:16.16389Z',
|
||||||
'dateTimeString is parsed'
|
'dateTimeString is parsed'
|
||||||
);
|
);
|
||||||
|
assert.deepEqual(
|
||||||
|
element.dateTimeObject, new Date('2016-06-22T09:20:16.16389Z'),
|
||||||
|
'dateTimeObject is parsed'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
QUnit.test('parses #EXT-X-STREAM-INF with common attributes', function(assert) {
|
QUnit.test('parses #EXT-X-STREAM-INF with common attributes', function(assert) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue