@@ -501,6 +501,27 @@ function parseMasterPlaylist(lines: Line[], params: Record<string, any>): Master
501501 return playlist ;
502502}
503503
504+ function parseDateRange ( attributes ) {
505+ const attrs : Record < string , any > = { } ;
506+ for ( const key of Object . keys ( attributes ) ) {
507+ if ( key . startsWith ( 'SCTE35-' ) || key . startsWith ( 'X-' ) ) {
508+ attrs [ key ] = attributes [ key ] ;
509+ }
510+ }
511+ const dateRange = new DateRange ( {
512+ id : attributes [ 'ID' ] ,
513+ classId : attributes [ 'CLASS' ] ,
514+ start : attributes [ 'START-DATE' ] ,
515+ cue : attributes [ 'CUE' ] ,
516+ end : attributes [ 'END-DATE' ] ,
517+ duration : attributes [ 'DURATION' ] ,
518+ plannedDuration : attributes [ 'PLANNED-DURATION' ] ,
519+ endOnNext : attributes [ 'END-ON-NEXT' ] ,
520+ attributes : attrs
521+ } ) ;
522+ return dateRange ;
523+ }
524+
504525function parseSegment ( lines : Line [ ] , uri : string , start : number , end : number , mediaSequenceNumber : number , discontinuitySequence : number , params : Record < string , any > ) : Segment {
505526 const segment = new Segment ( { uri, mediaSequenceNumber, discontinuitySequence} ) ;
506527 let mapHint = false ;
@@ -558,23 +579,7 @@ function parseSegment(lines: Line[], uri: string, start: number, end: number, me
558579 } else if ( name === 'EXT-X-PROGRAM-DATE-TIME' ) {
559580 segment . programDateTime = value ;
560581 } else if ( name === 'EXT-X-DATERANGE' ) {
561- const attrs : Record < string , any > = { } ;
562- for ( const key of Object . keys ( attributes ) ) {
563- if ( key . startsWith ( 'SCTE35-' ) || key . startsWith ( 'X-' ) ) {
564- attrs [ key ] = attributes [ key ] ;
565- }
566- }
567- segment . dateRange = new DateRange ( {
568- id : attributes [ 'ID' ] ,
569- classId : attributes [ 'CLASS' ] ,
570- start : attributes [ 'START-DATE' ] ,
571- cue : attributes [ 'CUE' ] ,
572- end : attributes [ 'END-DATE' ] ,
573- duration : attributes [ 'DURATION' ] ,
574- plannedDuration : attributes [ 'PLANNED-DURATION' ] ,
575- endOnNext : attributes [ 'END-ON-NEXT' ] ,
576- attributes : attrs
577- } ) ;
582+ segment . dateRange = parseDateRange ( attributes ) ;
578583 } else if ( name === 'EXT-X-CUE-OUT' ) {
579584 segment . markers . push ( new SpliceInfo ( {
580585 type : 'OUT' ,
@@ -783,6 +788,9 @@ function parseMediaPlaylist(lines: Line[], params: Record<string, any>): MediaPl
783788 } else if ( name === 'EXT-X-DEFINE' ) {
784789 playlist . defines ||= [ ] ;
785790 playlist . defines . push ( attributes ) ;
791+ } else if ( name === 'EXT-X-DATERANGE' ) {
792+ const dateRange = parseDateRange ( attributes ) ;
793+ playlist . dateRanges . push ( dateRange ) ;
786794 } else if ( typeof line === 'string' ) {
787795 // uri
788796 if ( segmentStart === - 1 ) {
0 commit comments