hls.js 1.6.0-beta.2.0.canary.10894 → 1.6.0-beta.2.0.canary.10896

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
@@ -402,7 +402,7 @@ function enableLogs(debugConfig, context, id) {
402
402
  // Some browsers don't allow to use bind on console object anyway
403
403
  // fallback to default if needed
404
404
  try {
405
- newLogger.log(`Debug logs enabled for "${context}" in hls.js version ${"1.6.0-beta.2.0.canary.10894"}`);
405
+ newLogger.log(`Debug logs enabled for "${context}" in hls.js version ${"1.6.0-beta.2.0.canary.10896"}`);
406
406
  } catch (e) {
407
407
  /* log fn threw an exception. All logger methods are no-ops. */
408
408
  return createLogger();
@@ -1234,11 +1234,10 @@ function matchesOption(option, track, matchPredicate) {
1234
1234
  name,
1235
1235
  lang,
1236
1236
  assocLang,
1237
- characteristics,
1238
1237
  default: isDefault
1239
1238
  } = option;
1240
1239
  const forced = option.forced;
1241
- return (groupId === undefined || track.groupId === groupId) && (name === undefined || track.name === name) && (lang === undefined || languagesMatch(lang, track.lang)) && (lang === undefined || track.assocLang === assocLang) && (isDefault === undefined || track.default === isDefault) && (forced === undefined || track.forced === forced) && (characteristics === undefined || characteristicsMatch(characteristics, track.characteristics)) && (matchPredicate === undefined || matchPredicate(option, track));
1240
+ return (groupId === undefined || track.groupId === groupId) && (name === undefined || track.name === name) && (lang === undefined || languagesMatch(lang, track.lang)) && (lang === undefined || track.assocLang === assocLang) && (isDefault === undefined || track.default === isDefault) && (forced === undefined || track.forced === forced) && (!('characteristics' in option) || characteristicsMatch(option.characteristics || '', track.characteristics)) && (matchPredicate === undefined || matchPredicate(option, track));
1242
1241
  }
1243
1242
  function languagesMatch(languageA, languageB = '--') {
1244
1243
  if (languageA.length === languageB.length) {
@@ -9835,7 +9834,7 @@ var eventemitter3 = {exports: {}};
9835
9834
  var eventemitter3Exports = eventemitter3.exports;
9836
9835
  var EventEmitter = /*@__PURE__*/getDefaultExportFromCjs(eventemitter3Exports);
9837
9836
 
9838
- const version = "1.6.0-beta.2.0.canary.10894";
9837
+ const version = "1.6.0-beta.2.0.canary.10896";
9839
9838
 
9840
9839
  // ensure the worker ends up in the bundle
9841
9840
  // If the worker should not be included this gets aliased to empty.js
@@ -16082,30 +16081,6 @@ class TransmuxerInterface {
16082
16081
  }
16083
16082
  }
16084
16083
 
16085
- function subtitleOptionsIdentical(trackList1, trackList2) {
16086
- if (trackList1.length !== trackList2.length) {
16087
- return false;
16088
- }
16089
- for (let i = 0; i < trackList1.length; i++) {
16090
- if (!mediaAttributesIdentical(trackList1[i].attrs, trackList2[i].attrs)) {
16091
- return false;
16092
- }
16093
- }
16094
- return true;
16095
- }
16096
- function mediaAttributesIdentical(attrs1, attrs2, customAttributes) {
16097
- // Media options with the same rendition ID must be bit identical
16098
- const stableRenditionId = attrs1['STABLE-RENDITION-ID'];
16099
- if (stableRenditionId && !customAttributes) {
16100
- return stableRenditionId === attrs2['STABLE-RENDITION-ID'];
16101
- }
16102
- // When rendition ID is not present, compare attributes
16103
- return !(customAttributes || ['LANGUAGE', 'NAME', 'CHARACTERISTICS', 'AUTOSELECT', 'DEFAULT', 'FORCED', 'ASSOC-LANGUAGE']).some(subtitleAttribute => attrs1[subtitleAttribute] !== attrs2[subtitleAttribute]);
16104
- }
16105
- function subtitleTrackMatchesTextTrack(subtitleTrack, textTrack) {
16106
- return textTrack.label.toLowerCase() === subtitleTrack.name.toLowerCase() && (!textTrack.language || textTrack.language.toLowerCase() === (subtitleTrack.lang || '').toLowerCase());
16107
- }
16108
-
16109
16084
  const TICK_INTERVAL$2 = 100; // how often to tick in ms
16110
16085
 
16111
16086
  class AudioStreamController extends BaseStreamController {
@@ -16369,11 +16344,7 @@ class AudioStreamController extends BaseStreamController {
16369
16344
  if (bufferInfo === null) {
16370
16345
  return;
16371
16346
  }
16372
- const {
16373
- bufferedTrack,
16374
- switchingTrack
16375
- } = this;
16376
- if (!switchingTrack && this._streamEnded(bufferInfo, trackDetails)) {
16347
+ if (!this.switchingTrack && this._streamEnded(bufferInfo, trackDetails)) {
16377
16348
  hls.trigger(Events.BUFFER_EOS, {
16378
16349
  type: 'audio'
16379
16350
  });
@@ -16385,13 +16356,9 @@ class AudioStreamController extends BaseStreamController {
16385
16356
  const fragments = trackDetails.fragments;
16386
16357
  const start = fragments[0].start;
16387
16358
  const loadPosition = this.getLoadPosition();
16388
- let targetBufferTime = this.flushing ? loadPosition : bufferInfo.end;
16389
- if (switchingTrack && media) {
16359
+ const targetBufferTime = this.flushing ? loadPosition : bufferInfo.end;
16360
+ if (this.switchingTrack && media) {
16390
16361
  const pos = loadPosition;
16391
- // STABLE
16392
- if (bufferedTrack && !mediaAttributesIdentical(switchingTrack.attrs, bufferedTrack.attrs)) {
16393
- targetBufferTime = pos;
16394
- }
16395
16362
  // if currentTime (pos) is less than alt audio playlist start time, it means that alt audio is ahead of currentTime
16396
16363
  if (trackDetails.PTSKnown && pos < start) {
16397
16364
  // if everything is buffered from pos to start or if audio buffer upfront, let's seek to start
@@ -16403,7 +16370,7 @@ class AudioStreamController extends BaseStreamController {
16403
16370
  }
16404
16371
 
16405
16372
  // if buffer length is less than maxBufLen, or near the end, find a fragment to load
16406
- if (bufferLen >= maxBufLen && !switchingTrack && targetBufferTime < fragments[fragments.length - 1].start) {
16373
+ if (bufferLen >= maxBufLen && !this.switchingTrack && targetBufferTime < fragments[fragments.length - 1].start) {
16407
16374
  return;
16408
16375
  }
16409
16376
  let frag = this.getNextFragment(targetBufferTime, trackDetails);
@@ -16897,20 +16864,31 @@ class AudioStreamController extends BaseStreamController {
16897
16864
  }
16898
16865
  }
16899
16866
  flushAudioIfNeeded(switchingTrack) {
16900
- const {
16901
- media,
16902
- bufferedTrack
16903
- } = this;
16904
- const bufferedAttributes = bufferedTrack == null ? undefined : bufferedTrack.attrs;
16905
- const switchAttributes = switchingTrack.attrs;
16906
- if (media && bufferedAttributes && (bufferedAttributes.CHANNELS !== switchAttributes.CHANNELS || bufferedTrack.name !== switchingTrack.name || bufferedTrack.lang !== switchingTrack.lang)) {
16907
- if (useAlternateAudio(switchingTrack.url, this.hls)) {
16908
- this.log('Switching audio track : flushing all audio');
16909
- super.flushMainBuffer(0, Number.POSITIVE_INFINITY, 'audio');
16910
- this.bufferedTrack = null;
16911
- } else {
16912
- // Main is being buffered. Set bufferedTrack so that it is flushed when switching back to alt-audio
16913
- this.bufferedTrack = switchingTrack;
16867
+ if (this.media && this.bufferedTrack) {
16868
+ const {
16869
+ name,
16870
+ lang,
16871
+ assocLang,
16872
+ characteristics,
16873
+ audioCodec,
16874
+ channels
16875
+ } = this.bufferedTrack;
16876
+ if (!matchesOption({
16877
+ name,
16878
+ lang,
16879
+ assocLang,
16880
+ characteristics,
16881
+ audioCodec,
16882
+ channels
16883
+ }, switchingTrack, audioMatchPredicate)) {
16884
+ if (useAlternateAudio(switchingTrack.url, this.hls)) {
16885
+ this.log('Switching audio track : flushing all audio');
16886
+ super.flushMainBuffer(0, Number.POSITIVE_INFINITY, 'audio');
16887
+ this.bufferedTrack = null;
16888
+ } else {
16889
+ // Main is being buffered. Set bufferedTrack so that it is flushed when switching back to alt-audio
16890
+ this.bufferedTrack = switchingTrack;
16891
+ }
16914
16892
  }
16915
16893
  }
16916
16894
  }
@@ -17182,6 +17160,30 @@ class BasePlaylistController extends Logger {
17182
17160
  }
17183
17161
  }
17184
17162
 
17163
+ function subtitleOptionsIdentical(trackList1, trackList2) {
17164
+ if (trackList1.length !== trackList2.length) {
17165
+ return false;
17166
+ }
17167
+ for (let i = 0; i < trackList1.length; i++) {
17168
+ if (!mediaAttributesIdentical(trackList1[i].attrs, trackList2[i].attrs)) {
17169
+ return false;
17170
+ }
17171
+ }
17172
+ return true;
17173
+ }
17174
+ function mediaAttributesIdentical(attrs1, attrs2, customAttributes) {
17175
+ // Media options with the same rendition ID must be bit identical
17176
+ const stableRenditionId = attrs1['STABLE-RENDITION-ID'];
17177
+ if (stableRenditionId && !customAttributes) {
17178
+ return stableRenditionId === attrs2['STABLE-RENDITION-ID'];
17179
+ }
17180
+ // When rendition ID is not present, compare attributes
17181
+ return !(customAttributes || ['LANGUAGE', 'NAME', 'CHARACTERISTICS', 'AUTOSELECT', 'DEFAULT', 'FORCED', 'ASSOC-LANGUAGE']).some(subtitleAttribute => attrs1[subtitleAttribute] !== attrs2[subtitleAttribute]);
17182
+ }
17183
+ function subtitleTrackMatchesTextTrack(subtitleTrack, textTrack) {
17184
+ return textTrack.label.toLowerCase() === subtitleTrack.name.toLowerCase() && (!textTrack.language || textTrack.language.toLowerCase() === (subtitleTrack.lang || '').toLowerCase());
17185
+ }
17186
+
17185
17187
  class AudioTrackController extends BasePlaylistController {
17186
17188
  constructor(hls) {
17187
17189
  super(hls, 'audio-track-controller');