@@ -152,6 +152,14 @@ shaka.hls.HlsParser = class {
152152 */
153153 this . lowestSyncTime_ = Infinity ;
154154
155+ /**
156+ * Flag to indicate if any of the media playlists use
157+ * EXT-X-PROGRAM-DATE-TIME.
158+ *
159+ * @private {boolean}
160+ */
161+ this . usesProgramDateTime_ = false ;
162+
155163 /**
156164 * Whether the streams have previously been "finalized"; that is to say,
157165 * whether we have loaded enough streams to know information about the asset
@@ -621,9 +629,10 @@ shaka.hls.HlsParser = class {
621629 * Align the streams by sequence number by dropping early segments. Then
622630 * offset the streams to begin at presentation time 0.
623631 * @param {!Array.<!shaka.hls.HlsParser.StreamInfo> } streamInfos
632+ * @param {boolean= } force
624633 * @private
625634 */
626- syncStreamsWithSequenceNumber_ ( streamInfos ) {
635+ syncStreamsWithSequenceNumber_ ( streamInfos , force = false ) {
627636 // We assume that, when this is first called, we have enough info to
628637 // determine how to use the program date times (e.g. we have both a video
629638 // and an audio, and all other videos and audios match those).
@@ -678,7 +687,7 @@ shaka.hls.HlsParser = class {
678687 this . minSequenceNumber_ ) ;
679688
680689 for ( const streamInfo of streamInfos ) {
681- if ( ! this . ignoreManifestProgramDateTimeFor_ ( streamInfo . type ) ) {
690+ if ( ! this . ignoreManifestProgramDateTimeFor_ ( streamInfo . type ) && ! force ) {
682691 continue ;
683692 }
684693 const segmentIndex = streamInfo . stream . segmentIndex ;
@@ -2752,8 +2761,12 @@ shaka.hls.HlsParser = class {
27522761 }
27532762 }
27542763 this . notifySegmentsForStreams_ ( streamInfos . map ( ( s ) => s . stream ) ) ;
2755- if ( this . config_ . hls . ignoreManifestProgramDateTime ) {
2756- this . syncStreamsWithSequenceNumber_ ( streamInfos ) ;
2764+ const liveWithNoProgramaDateTime =
2765+ this . isLive_ ( ) && ! this . usesProgramDateTime_ ;
2766+ if ( this . config_ . hls . ignoreManifestProgramDateTime ||
2767+ liveWithNoProgramaDateTime ) {
2768+ this . syncStreamsWithSequenceNumber_ (
2769+ streamInfos , liveWithNoProgramaDateTime ) ;
27572770 } else {
27582771 this . syncStreamsWithProgramDateTime_ ( streamInfos ) ;
27592772 if ( this . config_ . hls . ignoreManifestProgramDateTimeForTypes . length > 0 ) {
@@ -3626,6 +3639,7 @@ shaka.hls.HlsParser = class {
36263639 syncTime = shaka . util . TXml . parseDate ( dateTimeTag . value ) ;
36273640 goog . asserts . assert ( syncTime != null ,
36283641 'EXT-X-PROGRAM-DATE-TIME format not valid' ) ;
3642+ this . usesProgramDateTime_ = true ;
36293643 }
36303644 }
36313645
0 commit comments