hls.js 1.5.2-0.canary.9966 → 1.5.2-0.canary.9970

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.light.js CHANGED
@@ -525,7 +525,7 @@
525
525
  // Some browsers don't allow to use bind on console object anyway
526
526
  // fallback to default if needed
527
527
  try {
528
- newLogger.log("Debug logs enabled for \"" + context + "\" in hls.js version " + "1.5.2-0.canary.9966");
528
+ newLogger.log("Debug logs enabled for \"" + context + "\" in hls.js version " + "1.5.2-0.canary.9970");
529
529
  } catch (e) {
530
530
  /* log fn threw an exception. All logger methods are no-ops. */
531
531
  return createLogger();
@@ -1602,6 +1602,12 @@
1602
1602
  var val = readSint32(buffer, offset);
1603
1603
  return val < 0 ? 4294967296 + val : val;
1604
1604
  }
1605
+ function readUint64(buffer, offset) {
1606
+ var result = readUint32(buffer, offset);
1607
+ result *= Math.pow(2, 32);
1608
+ result += readUint32(buffer, offset + 4);
1609
+ return result;
1610
+ }
1605
1611
  function readSint32(buffer, offset) {
1606
1612
  return buffer[offset] << 24 | buffer[offset + 1] << 16 | buffer[offset + 2] << 8 | buffer[offset + 3];
1607
1613
  }
@@ -1664,15 +1670,14 @@
1664
1670
  var index = 8;
1665
1671
  var timescale = readUint32(sidx, index);
1666
1672
  index += 4;
1667
-
1668
- // TODO: parse earliestPresentationTime and firstOffset
1669
- // usually zero in our case
1670
1673
  var earliestPresentationTime = 0;
1671
1674
  var firstOffset = 0;
1672
1675
  if (version === 0) {
1673
- index += 8;
1676
+ earliestPresentationTime = readUint32(sidx, index += 4);
1677
+ firstOffset = readUint32(sidx, index += 4);
1674
1678
  } else {
1675
- index += 16;
1679
+ earliestPresentationTime = readUint64(sidx, index += 8);
1680
+ firstOffset = readUint64(sidx, index += 8);
1676
1681
  }
1677
1682
 
1678
1683
  // skip reserved
@@ -2122,17 +2127,24 @@
2122
2127
  }
2123
2128
  if (videoDuration === 0 && audioDuration === 0) {
2124
2129
  // If duration samples are not available in the traf use sidx subsegment_duration
2130
+ var sidxMinStart = Infinity;
2131
+ var sidxMaxEnd = 0;
2125
2132
  var sidxDuration = 0;
2126
2133
  var sidxs = findBox(data, ['sidx']);
2127
2134
  for (var _i2 = 0; _i2 < sidxs.length; _i2++) {
2128
2135
  var sidx = parseSegmentIndex(sidxs[_i2]);
2129
2136
  if (sidx != null && sidx.references) {
2130
- sidxDuration += sidx.references.reduce(function (dur, ref) {
2137
+ sidxMinStart = Math.min(sidxMinStart, sidx.earliestPresentationTime / sidx.timescale);
2138
+ var subSegmentDuration = sidx.references.reduce(function (dur, ref) {
2131
2139
  return dur + ref.info.duration || 0;
2132
2140
  }, 0);
2141
+ sidxMaxEnd = Math.max(sidxMaxEnd, subSegmentDuration + sidx.earliestPresentationTime / sidx.timescale);
2142
+ sidxDuration = sidxMaxEnd - sidxMinStart;
2133
2143
  }
2134
2144
  }
2135
- return sidxDuration;
2145
+ if (sidxDuration && isFiniteNumber(sidxDuration)) {
2146
+ return sidxDuration;
2147
+ }
2136
2148
  }
2137
2149
  if (videoDuration) {
2138
2150
  return videoDuration;
@@ -7021,8 +7033,11 @@
7021
7033
  return nextABRAutoLevel;
7022
7034
  },
7023
7035
  set: function set(nextLevel) {
7024
- var value = Math.max(this.hls.minAutoLevel, nextLevel);
7025
- if (this._nextAutoLevel != value) {
7036
+ var _this$hls3 = this.hls,
7037
+ maxAutoLevel = _this$hls3.maxAutoLevel,
7038
+ minAutoLevel = _this$hls3.minAutoLevel;
7039
+ var value = Math.min(Math.max(nextLevel, minAutoLevel), maxAutoLevel);
7040
+ if (this._nextAutoLevel !== value) {
7026
7041
  this.nextAutoLevelKey = '';
7027
7042
  this._nextAutoLevel = value;
7028
7043
  }
@@ -7509,6 +7524,7 @@
7509
7524
  _this2.resetBuffer(type);
7510
7525
  });
7511
7526
  this._initSourceBuffer();
7527
+ this.hls.resumeBuffering();
7512
7528
  };
7513
7529
  _proto.resetBuffer = function resetBuffer(type) {
7514
7530
  var sb = this.sourceBuffer[type];
@@ -12279,6 +12295,7 @@
12279
12295
  _this.startFragRequested = false;
12280
12296
  _this.decrypter = void 0;
12281
12297
  _this.initPTS = [];
12298
+ _this.buffering = true;
12282
12299
  _this.onMediaSeeking = function () {
12283
12300
  var _assertThisInitialize = _assertThisInitialized(_this),
12284
12301
  config = _assertThisInitialize.config,
@@ -12382,6 +12399,12 @@
12382
12399
  this.clearNextTick();
12383
12400
  this.state = State.STOPPED;
12384
12401
  };
12402
+ _proto.pauseBuffering = function pauseBuffering() {
12403
+ this.buffering = false;
12404
+ };
12405
+ _proto.resumeBuffering = function resumeBuffering() {
12406
+ this.buffering = true;
12407
+ };
12385
12408
  _proto._streamEnded = function _streamEnded(bufferInfo, levelDetails) {
12386
12409
  // If playlist is live, there is another buffered range after the current range, nothing buffered, media is detached,
12387
12410
  // of nothing loading/loaded return false
@@ -19244,7 +19267,8 @@
19244
19267
  }
19245
19268
  // set new level to playlist loader : this will trigger start level load
19246
19269
  // hls.nextLoadLevel remains until it is set to a new value or until a new frag is successfully loaded
19247
- this.level = hls.nextLoadLevel = startLevel;
19270
+ hls.nextLoadLevel = startLevel;
19271
+ this.level = hls.loadLevel;
19248
19272
  this.loadedmetadata = false;
19249
19273
  }
19250
19274
  // if startPosition undefined but lastCurrentTime set, set startPosition to last currentTime
@@ -19329,7 +19353,7 @@
19329
19353
  if (this.altAudio && this.audioOnly) {
19330
19354
  return;
19331
19355
  }
19332
- if (!(levels != null && levels[level])) {
19356
+ if (!this.buffering || !(levels != null && levels[level])) {
19333
19357
  return;
19334
19358
  }
19335
19359
  var levelInfo = levels[level];
@@ -20307,7 +20331,6 @@
20307
20331
  this.logger = void 0;
20308
20332
  this.coreComponents = void 0;
20309
20333
  this.networkControllers = void 0;
20310
- this.started = false;
20311
20334
  this._emitter = new EventEmitter();
20312
20335
  this._autoLevelCapping = -1;
20313
20336
  this._maxHdcpLevel = null;
@@ -20538,7 +20561,6 @@
20538
20561
  startPosition = -1;
20539
20562
  }
20540
20563
  this.logger.log("startLoad(" + startPosition + ")");
20541
- this.started = true;
20542
20564
  this.networkControllers.forEach(function (controller) {
20543
20565
  controller.startLoad(startPosition);
20544
20566
  });
@@ -20549,33 +20571,30 @@
20549
20571
  */;
20550
20572
  _proto.stopLoad = function stopLoad() {
20551
20573
  this.logger.log('stopLoad');
20552
- this.started = false;
20553
20574
  this.networkControllers.forEach(function (controller) {
20554
20575
  controller.stopLoad();
20555
20576
  });
20556
20577
  }
20557
20578
 
20558
20579
  /**
20559
- * Resumes stream controller segment loading if previously started.
20580
+ * Resumes stream controller segment loading after `pauseBuffering` has been called.
20560
20581
  */;
20561
20582
  _proto.resumeBuffering = function resumeBuffering() {
20562
- if (this.started) {
20563
- this.networkControllers.forEach(function (controller) {
20564
- if ('fragmentLoader' in controller) {
20565
- controller.startLoad(-1);
20566
- }
20567
- });
20568
- }
20583
+ this.networkControllers.forEach(function (controller) {
20584
+ if (controller.resumeBuffering) {
20585
+ controller.resumeBuffering();
20586
+ }
20587
+ });
20569
20588
  }
20570
20589
 
20571
20590
  /**
20572
- * Stops stream controller segment loading without changing 'started' state like stopLoad().
20591
+ * Prevents stream controller from loading new segments until `resumeBuffering` is called.
20573
20592
  * This allows for media buffering to be paused without interupting playlist loading.
20574
20593
  */;
20575
20594
  _proto.pauseBuffering = function pauseBuffering() {
20576
20595
  this.networkControllers.forEach(function (controller) {
20577
- if ('fragmentLoader' in controller) {
20578
- controller.stopLoad();
20596
+ if (controller.pauseBuffering) {
20597
+ controller.pauseBuffering();
20579
20598
  }
20580
20599
  });
20581
20600
  }
@@ -21132,7 +21151,7 @@
21132
21151
  * Get the video-dev/hls.js package version.
21133
21152
  */
21134
21153
  function get() {
21135
- return "1.5.2-0.canary.9966";
21154
+ return "1.5.2-0.canary.9970";
21136
21155
  }
21137
21156
  }, {
21138
21157
  key: "Events",