hls.js 1.6.0-beta.1.0.canary.10818 → 1.6.0-beta.1.0.canary.10819

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/hls.mjs CHANGED
@@ -144,6 +144,7 @@ let Events = /*#__PURE__*/function (Events) {
144
144
  Events["INTERSTITIAL_ENDED"] = "hlsInterstitialEnded";
145
145
  Events["INTERSTITIALS_PRIMARY_RESUMED"] = "hlsInterstitialsPrimaryResumed";
146
146
  Events["PLAYOUT_LIMIT_REACHED"] = "hlsPlayoutLimitReached";
147
+ Events["EVENT_CUE_ENTER"] = "hlsEventCueEnter";
147
148
  return Events;
148
149
  }({});
149
150
 
@@ -400,7 +401,7 @@ function enableLogs(debugConfig, context, id) {
400
401
  // Some browsers don't allow to use bind on console object anyway
401
402
  // fallback to default if needed
402
403
  try {
403
- newLogger.log(`Debug logs enabled for "${context}" in hls.js version ${"1.6.0-beta.1.0.canary.10818"}`);
404
+ newLogger.log(`Debug logs enabled for "${context}" in hls.js version ${"1.6.0-beta.1.0.canary.10819"}`);
404
405
  } catch (e) {
405
406
  /* log fn threw an exception. All logger methods are no-ops. */
406
407
  return createLogger();
@@ -9835,7 +9836,7 @@ var eventemitter3 = {exports: {}};
9835
9836
  var eventemitter3Exports = eventemitter3.exports;
9836
9837
  var EventEmitter = /*@__PURE__*/getDefaultExportFromCjs(eventemitter3Exports);
9837
9838
 
9838
- const version = "1.6.0-beta.1.0.canary.10818";
9839
+ const version = "1.6.0-beta.1.0.canary.10819";
9839
9840
 
9840
9841
  // ensure the worker ends up in the bundle
9841
9842
  // If the worker should not be included this gets aliased to empty.js
@@ -22093,7 +22094,7 @@ function addCueToTrack(track, cue) {
22093
22094
  track.mode = mode;
22094
22095
  }
22095
22096
  }
22096
- function clearCurrentCues(track) {
22097
+ function clearCurrentCues(track, enterHandler) {
22097
22098
  // When track.mode is disabled, track.cues will be null.
22098
22099
  // To guarantee the removal of cues, we need to temporarily
22099
22100
  // change the mode to hidden
@@ -22103,6 +22104,9 @@ function clearCurrentCues(track) {
22103
22104
  }
22104
22105
  if (track.cues) {
22105
22106
  for (let i = track.cues.length; i--;) {
22107
+ if (enterHandler) {
22108
+ track.cues[i].removeEventListener('enter', enterHandler);
22109
+ }
22106
22110
  track.removeCue(track.cues[i]);
22107
22111
  }
22108
22112
  }
@@ -23790,6 +23794,7 @@ Schedule: ${scheduleItems.map(seg => segmentToString(seg))}`);
23790
23794
  hls.on(Events.AUDIO_TRACK_UPDATED, this.onAudioTrackUpdated, this);
23791
23795
  hls.on(Events.SUBTITLE_TRACK_SWITCH, this.onSubtitleTrackSwitch, this);
23792
23796
  hls.on(Events.SUBTITLE_TRACK_UPDATED, this.onSubtitleTrackUpdated, this);
23797
+ hls.on(Events.EVENT_CUE_ENTER, this.onInterstitialCueEnter, this);
23793
23798
  hls.on(Events.ASSET_LIST_LOADED, this.onAssetListLoaded, this);
23794
23799
  hls.on(Events.BUFFER_APPENDED, this.onBufferAppended, this);
23795
23800
  hls.on(Events.BUFFER_FLUSHED, this.onBufferFlushed, this);
@@ -23812,6 +23817,7 @@ Schedule: ${scheduleItems.map(seg => segmentToString(seg))}`);
23812
23817
  hls.off(Events.AUDIO_TRACK_UPDATED, this.onAudioTrackUpdated, this);
23813
23818
  hls.off(Events.SUBTITLE_TRACK_SWITCH, this.onSubtitleTrackSwitch, this);
23814
23819
  hls.off(Events.SUBTITLE_TRACK_UPDATED, this.onSubtitleTrackUpdated, this);
23820
+ hls.off(Events.EVENT_CUE_ENTER, this.onInterstitialCueEnter, this);
23815
23821
  hls.off(Events.ASSET_LIST_LOADED, this.onAssetListLoaded, this);
23816
23822
  hls.off(Events.BUFFER_CODECS, this.onBufferCodecs, this);
23817
23823
  hls.off(Events.BUFFER_APPENDED, this.onBufferAppended, this);
@@ -24267,6 +24273,9 @@ MediaSource ${JSON.stringify(attachMediaSourceData)} from ${logFromSource}`);
24267
24273
  }
24268
24274
  player.attachMedia(dataToAttach);
24269
24275
  }
24276
+ onInterstitialCueEnter() {
24277
+ this.onTimeupdate();
24278
+ }
24270
24279
  // Scheduling methods
24271
24280
  checkStart() {
24272
24281
  const schedule = this.schedule;
@@ -29649,6 +29658,12 @@ class ID3TrackController {
29649
29658
  this.media = null;
29650
29659
  this.dateRangeCuesAppended = {};
29651
29660
  this.removeCues = true;
29661
+ this.onEventCueEnter = () => {
29662
+ if (!this.hls) {
29663
+ return;
29664
+ }
29665
+ this.hls.trigger(Events.EVENT_CUE_ENTER, {});
29666
+ };
29652
29667
  this.hls = hls;
29653
29668
  this._registerListeners();
29654
29669
  }
@@ -29658,13 +29673,14 @@ class ID3TrackController {
29658
29673
  this.media = null;
29659
29674
  this.dateRangeCuesAppended = {};
29660
29675
  // @ts-ignore
29661
- this.hls = null;
29676
+ this.hls = this.onEventCueEnter = null;
29662
29677
  }
29663
29678
  _registerListeners() {
29664
29679
  const {
29665
29680
  hls
29666
29681
  } = this;
29667
29682
  hls.on(Events.MEDIA_ATTACHING, this.onMediaAttaching, this);
29683
+ hls.on(Events.MEDIA_ATTACHED, this.onMediaAttached, this);
29668
29684
  hls.on(Events.MEDIA_DETACHING, this.onMediaDetaching, this);
29669
29685
  hls.on(Events.MANIFEST_LOADING, this.onManifestLoading, this);
29670
29686
  hls.on(Events.FRAG_PARSING_METADATA, this.onFragParsingMetadata, this);
@@ -29677,6 +29693,7 @@ class ID3TrackController {
29677
29693
  hls
29678
29694
  } = this;
29679
29695
  hls.off(Events.MEDIA_ATTACHING, this.onMediaAttaching, this);
29696
+ hls.off(Events.MEDIA_ATTACHED, this.onMediaAttached, this);
29680
29697
  hls.off(Events.MEDIA_DETACHING, this.onMediaDetaching, this);
29681
29698
  hls.off(Events.MANIFEST_LOADING, this.onManifestLoading, this);
29682
29699
  hls.off(Events.FRAG_PARSING_METADATA, this.onFragParsingMetadata, this);
@@ -29684,7 +29701,6 @@ class ID3TrackController {
29684
29701
  hls.off(Events.LEVEL_UPDATED, this.onLevelUpdated, this);
29685
29702
  hls.off(Events.LEVEL_PTS_UPDATED, this.onLevelPtsUpdated, this);
29686
29703
  }
29687
-
29688
29704
  // Add ID3 metatadata text track.
29689
29705
  onMediaAttaching(event, data) {
29690
29706
  var _data$overrides;
@@ -29693,6 +29709,12 @@ class ID3TrackController {
29693
29709
  this.removeCues = false;
29694
29710
  }
29695
29711
  }
29712
+ onMediaAttached() {
29713
+ const details = this.hls.latestLevelDetails;
29714
+ if (details) {
29715
+ this.updateDateRangeCues(details);
29716
+ }
29717
+ }
29696
29718
  onMediaDetaching(event, data) {
29697
29719
  this.media = null;
29698
29720
  const transferringMedia = !!data.transferMedia;
@@ -29701,7 +29723,7 @@ class ID3TrackController {
29701
29723
  }
29702
29724
  if (this.id3Track) {
29703
29725
  if (this.removeCues) {
29704
- clearCurrentCues(this.id3Track);
29726
+ clearCurrentCues(this.id3Track, this.onEventCueEnter);
29705
29727
  }
29706
29728
  this.id3Track = null;
29707
29729
  }
@@ -29863,7 +29885,9 @@ class ID3TrackController {
29863
29885
  delete dateRangeCuesAppended[id];
29864
29886
  Object.keys(cues).forEach(key => {
29865
29887
  try {
29866
- id3Track.removeCue(cues[key]);
29888
+ const cue = cues[key];
29889
+ cue.removeEventListener('enter', this.onEventCueEnter);
29890
+ id3Track.removeCue(cue);
29867
29891
  } catch (e) {
29868
29892
  /* no-op */
29869
29893
  }
@@ -29936,14 +29960,20 @@ class ID3TrackController {
29936
29960
  if (isSCTE35Attribute(key)) {
29937
29961
  data = hexToArrayBuffer(data);
29938
29962
  }
29939
- const _cue = createCueWithDataFields(Cue, startTime, endTime, {
29963
+ const payload = {
29940
29964
  key,
29941
29965
  data
29942
- }, MetadataSchema.dateRange);
29966
+ };
29967
+ const _cue = createCueWithDataFields(Cue, startTime, endTime, payload, MetadataSchema.dateRange);
29943
29968
  if (_cue) {
29944
29969
  _cue.id = id;
29945
29970
  this.id3Track.addCue(_cue);
29946
29971
  cues[key] = _cue;
29972
+ if (this.hls.config.interstitialsController) {
29973
+ if (key === 'X-ASSET-LIST' || key === 'X-ASSET-URL') {
29974
+ _cue.addEventListener('enter', this.onEventCueEnter);
29975
+ }
29976
+ }
29947
29977
  }
29948
29978
  }
29949
29979
  }