hls.js 1.5.19 → 1.5.20

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
@@ -411,7 +411,7 @@ function enableLogs(debugConfig, id) {
411
411
  // Some browsers don't allow to use bind on console object anyway
412
412
  // fallback to default if needed
413
413
  try {
414
- exportedLogger.log(`Debug logs enabled for "${id}" in hls.js version ${"1.5.19"}`);
414
+ exportedLogger.log(`Debug logs enabled for "${id}" in hls.js version ${"1.5.20"}`);
415
415
  } catch (e) {
416
416
  exportedLogger = fakeLogger;
417
417
  }
@@ -6823,11 +6823,10 @@ function matchesOption(option, track, matchPredicate) {
6823
6823
  name,
6824
6824
  lang,
6825
6825
  assocLang,
6826
- characteristics,
6827
6826
  default: isDefault
6828
6827
  } = option;
6829
6828
  const forced = option.forced;
6830
- return (groupId === undefined || track.groupId === groupId) && (name === undefined || track.name === name) && (lang === undefined || track.lang === 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));
6829
+ return (groupId === undefined || track.groupId === groupId) && (name === undefined || track.name === name) && (lang === undefined || track.lang === 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));
6831
6830
  }
6832
6831
  function characteristicsMatch(characteristicsA, characteristicsB = '') {
6833
6832
  const arrA = characteristicsA.split(',');
@@ -15701,30 +15700,6 @@ class TransmuxerInterface {
15701
15700
  }
15702
15701
  }
15703
15702
 
15704
- function subtitleOptionsIdentical(trackList1, trackList2) {
15705
- if (trackList1.length !== trackList2.length) {
15706
- return false;
15707
- }
15708
- for (let i = 0; i < trackList1.length; i++) {
15709
- if (!mediaAttributesIdentical(trackList1[i].attrs, trackList2[i].attrs)) {
15710
- return false;
15711
- }
15712
- }
15713
- return true;
15714
- }
15715
- function mediaAttributesIdentical(attrs1, attrs2, customAttributes) {
15716
- // Media options with the same rendition ID must be bit identical
15717
- const stableRenditionId = attrs1['STABLE-RENDITION-ID'];
15718
- if (stableRenditionId && !customAttributes) {
15719
- return stableRenditionId === attrs2['STABLE-RENDITION-ID'];
15720
- }
15721
- // When rendition ID is not present, compare attributes
15722
- return !(customAttributes || ['LANGUAGE', 'NAME', 'CHARACTERISTICS', 'AUTOSELECT', 'DEFAULT', 'FORCED', 'ASSOC-LANGUAGE']).some(subtitleAttribute => attrs1[subtitleAttribute] !== attrs2[subtitleAttribute]);
15723
- }
15724
- function subtitleTrackMatchesTextTrack(subtitleTrack, textTrack) {
15725
- return textTrack.label.toLowerCase() === subtitleTrack.name.toLowerCase() && (!textTrack.language || textTrack.language.toLowerCase() === (subtitleTrack.lang || '').toLowerCase());
15726
- }
15727
-
15728
15703
  const TICK_INTERVAL$2 = 100; // how often to tick in ms
15729
15704
 
15730
15705
  class AudioStreamController extends BaseStreamController {
@@ -15973,11 +15948,7 @@ class AudioStreamController extends BaseStreamController {
15973
15948
  if (bufferInfo === null) {
15974
15949
  return;
15975
15950
  }
15976
- const {
15977
- bufferedTrack,
15978
- switchingTrack
15979
- } = this;
15980
- if (!switchingTrack && this._streamEnded(bufferInfo, trackDetails)) {
15951
+ if (!this.switchingTrack && this._streamEnded(bufferInfo, trackDetails)) {
15981
15952
  hls.trigger(Events.BUFFER_EOS, {
15982
15953
  type: 'audio'
15983
15954
  });
@@ -15989,13 +15960,10 @@ class AudioStreamController extends BaseStreamController {
15989
15960
  const maxBufLen = this.getMaxBufferLength(mainBufferInfo == null ? void 0 : mainBufferInfo.len);
15990
15961
  const fragments = trackDetails.fragments;
15991
15962
  const start = fragments[0].start;
15992
- let targetBufferTime = this.flushing ? this.getLoadPosition() : bufferInfo.end;
15993
- if (switchingTrack && media) {
15994
- const pos = this.getLoadPosition();
15995
- // STABLE
15996
- if (bufferedTrack && !mediaAttributesIdentical(switchingTrack.attrs, bufferedTrack.attrs)) {
15997
- targetBufferTime = pos;
15998
- }
15963
+ const loadPosition = this.getLoadPosition();
15964
+ const targetBufferTime = this.flushing ? loadPosition : bufferInfo.end;
15965
+ if (this.switchingTrack && media) {
15966
+ const pos = loadPosition;
15999
15967
  // if currentTime (pos) is less than alt audio playlist start time, it means that alt audio is ahead of currentTime
16000
15968
  if (trackDetails.PTSKnown && pos < start) {
16001
15969
  // if everything is buffered from pos to start or if audio buffer upfront, let's seek to start
@@ -16007,7 +15975,7 @@ class AudioStreamController extends BaseStreamController {
16007
15975
  }
16008
15976
 
16009
15977
  // if buffer length is less than maxBufLen, or near the end, find a fragment to load
16010
- if (bufferLen >= maxBufLen && !switchingTrack && targetBufferTime < fragments[fragments.length - 1].start) {
15978
+ if (bufferLen >= maxBufLen && !this.switchingTrack && targetBufferTime < fragments[fragments.length - 1].start) {
16011
15979
  return;
16012
15980
  }
16013
15981
  let frag = this.getNextFragment(targetBufferTime, trackDetails);
@@ -16488,16 +16456,27 @@ class AudioStreamController extends BaseStreamController {
16488
16456
  }
16489
16457
  }
16490
16458
  flushAudioIfNeeded(switchingTrack) {
16491
- const {
16492
- media,
16493
- bufferedTrack
16494
- } = this;
16495
- const bufferedAttributes = bufferedTrack == null ? void 0 : bufferedTrack.attrs;
16496
- const switchAttributes = switchingTrack.attrs;
16497
- if (media && bufferedAttributes && (bufferedAttributes.CHANNELS !== switchAttributes.CHANNELS || bufferedTrack.name !== switchingTrack.name || bufferedTrack.lang !== switchingTrack.lang)) {
16498
- this.log('Switching audio track : flushing all audio');
16499
- super.flushMainBuffer(0, Number.POSITIVE_INFINITY, 'audio');
16500
- this.bufferedTrack = null;
16459
+ if (this.media && this.bufferedTrack) {
16460
+ const {
16461
+ name,
16462
+ lang,
16463
+ assocLang,
16464
+ characteristics,
16465
+ audioCodec,
16466
+ channels
16467
+ } = this.bufferedTrack;
16468
+ if (!matchesOption({
16469
+ name,
16470
+ lang,
16471
+ assocLang,
16472
+ characteristics,
16473
+ audioCodec,
16474
+ channels
16475
+ }, switchingTrack, audioMatchPredicate)) {
16476
+ this.log('Switching audio track : flushing all audio');
16477
+ super.flushMainBuffer(0, Number.POSITIVE_INFINITY, 'audio');
16478
+ this.bufferedTrack = null;
16479
+ }
16501
16480
  }
16502
16481
  }
16503
16482
  completeAudioSwitch(switchingTrack) {
@@ -16511,6 +16490,30 @@ class AudioStreamController extends BaseStreamController {
16511
16490
  }
16512
16491
  }
16513
16492
 
16493
+ function subtitleOptionsIdentical(trackList1, trackList2) {
16494
+ if (trackList1.length !== trackList2.length) {
16495
+ return false;
16496
+ }
16497
+ for (let i = 0; i < trackList1.length; i++) {
16498
+ if (!mediaAttributesIdentical(trackList1[i].attrs, trackList2[i].attrs)) {
16499
+ return false;
16500
+ }
16501
+ }
16502
+ return true;
16503
+ }
16504
+ function mediaAttributesIdentical(attrs1, attrs2, customAttributes) {
16505
+ // Media options with the same rendition ID must be bit identical
16506
+ const stableRenditionId = attrs1['STABLE-RENDITION-ID'];
16507
+ if (stableRenditionId && !customAttributes) {
16508
+ return stableRenditionId === attrs2['STABLE-RENDITION-ID'];
16509
+ }
16510
+ // When rendition ID is not present, compare attributes
16511
+ return !(customAttributes || ['LANGUAGE', 'NAME', 'CHARACTERISTICS', 'AUTOSELECT', 'DEFAULT', 'FORCED', 'ASSOC-LANGUAGE']).some(subtitleAttribute => attrs1[subtitleAttribute] !== attrs2[subtitleAttribute]);
16512
+ }
16513
+ function subtitleTrackMatchesTextTrack(subtitleTrack, textTrack) {
16514
+ return textTrack.label.toLowerCase() === subtitleTrack.name.toLowerCase() && (!textTrack.language || textTrack.language.toLowerCase() === (subtitleTrack.lang || '').toLowerCase());
16515
+ }
16516
+
16514
16517
  class AudioTrackController extends BasePlaylistController {
16515
16518
  constructor(hls) {
16516
16519
  super(hls, '[audio-track-controller]');
@@ -27844,7 +27847,7 @@ class Hls {
27844
27847
  * Get the video-dev/hls.js package version.
27845
27848
  */
27846
27849
  static get version() {
27847
- return "1.5.19";
27850
+ return "1.5.20";
27848
27851
  }
27849
27852
 
27850
27853
  /**