stormcloud-video-player 0.8.53 → 0.8.54

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.
@@ -6477,6 +6477,7 @@ var HlsEngine = /*#__PURE__*/ function() {
6477
6477
  this.bufferedSegmentsCount = 0;
6478
6478
  this.shouldAutoplayAfterBuffering = false;
6479
6479
  this.hasInitialBufferCompleted = false;
6480
+ this.latencyProfileApplied = false;
6480
6481
  this.config = config;
6481
6482
  this.video = video;
6482
6483
  this.cueManager = cueManager;
@@ -6545,24 +6546,21 @@ var HlsEngine = /*#__PURE__*/ function() {
6545
6546
  key: "setupHls",
6546
6547
  value: function setupHls() {
6547
6548
  var _this = this;
6548
- this.hls = new import_hls2.default(_object_spread_props(_object_spread({
6549
+ this.hls = new import_hls2.default({
6549
6550
  enableWorker: true,
6550
6551
  backBufferLength: 30,
6551
6552
  liveDurationInfinity: true,
6552
6553
  lowLatencyMode: !!this.config.lowLatencyMode,
6553
- maxLiveSyncPlaybackRate: this.config.lowLatencyMode ? 1.5 : 1
6554
- }, this.config.lowLatencyMode ? {
6555
- liveSyncDuration: 2
6556
- } : {}), {
6554
+ maxLiveSyncPlaybackRate: 1.1,
6557
6555
  maxBufferLength: 30,
6558
6556
  maxMaxBufferLength: 600,
6559
6557
  maxBufferSize: 60 * 1e3 * 1e3,
6560
- maxBufferHole: 0.5,
6558
+ maxBufferHole: 1,
6561
6559
  highBufferWatchdogPeriod: 2,
6562
- nudgeOffset: 0.1,
6563
- nudgeMaxRetry: 3,
6560
+ nudgeOffset: 0.2,
6561
+ nudgeMaxRetry: 5,
6564
6562
  startPosition: -1
6565
- }));
6563
+ });
6566
6564
  this.hls.on(import_hls2.default.Events.MEDIA_ATTACHED, function() {
6567
6565
  var _this_hls;
6568
6566
  (_this_hls = _this.hls) === null || _this_hls === void 0 ? void 0 : _this_hls.loadSource(_this.config.src);
@@ -6586,6 +6584,8 @@ var HlsEngine = /*#__PURE__*/ function() {
6586
6584
  this.bufferedSegmentsCount = 0;
6587
6585
  this.hasInitialBufferCompleted = false;
6588
6586
  this.shouldAutoplayAfterBuffering = !!this.config.autoplay;
6587
+ this.latencyProfileApplied = false;
6588
+ this.detectedLowLatencyStream = void 0;
6589
6589
  minSegments = (_this_config_minSegmentsBeforePlay = this.config.minSegmentsBeforePlay) !== null && _this_config_minSegmentsBeforePlay !== void 0 ? _this_config_minSegmentsBeforePlay : 2;
6590
6590
  if (this.debug) {
6591
6591
  console.log("[StormcloudVideoPlayer] Waiting for", minSegments, "segments to buffer before playback");
@@ -6616,6 +6616,7 @@ var HlsEngine = /*#__PURE__*/ function() {
6616
6616
  }).call(_this);
6617
6617
  });
6618
6618
  this.hls.on(import_hls2.default.Events.LEVEL_LOADED, function(_evt, data) {
6619
+ _this.applyStreamLatencyProfile(data === null || data === void 0 ? void 0 : data.details);
6619
6620
  if (_this.callbacks.isInAdBreak() || _this.callbacks.hasPendingAdBreak()) {
6620
6621
  return;
6621
6622
  }
@@ -6889,6 +6890,70 @@ var HlsEngine = /*#__PURE__*/ function() {
6889
6890
  this.hls.attachMedia(this.video);
6890
6891
  }
6891
6892
  },
6893
+ {
6894
+ key: "isLowLatencyStream",
6895
+ value: function isLowLatencyStream() {
6896
+ return this.detectedLowLatencyStream;
6897
+ }
6898
+ },
6899
+ {
6900
+ key: "applyStreamLatencyProfile",
6901
+ value: function applyStreamLatencyProfile(details) {
6902
+ if (this.latencyProfileApplied || !this.hls) {
6903
+ return;
6904
+ }
6905
+ if (!details) {
6906
+ return;
6907
+ }
6908
+ if (details.live !== true) {
6909
+ this.latencyProfileApplied = true;
6910
+ this.detectedLowLatencyStream = false;
6911
+ return;
6912
+ }
6913
+ var isLowLatencyManifest = this.isLowLatencyManifest(details);
6914
+ var useLowLatency = isLowLatencyManifest && !!this.config.lowLatencyMode;
6915
+ this.detectedLowLatencyStream = useLowLatency;
6916
+ this.latencyProfileApplied = true;
6917
+ var cfg = this.hls.config;
6918
+ if (useLowLatency) {
6919
+ cfg.maxLiveSyncPlaybackRate = 1.5;
6920
+ cfg.maxBufferHole = 0.5;
6921
+ delete cfg.liveSyncDuration;
6922
+ } else {
6923
+ cfg.maxLiveSyncPlaybackRate = 1.1;
6924
+ cfg.maxBufferHole = 1;
6925
+ delete cfg.liveSyncDuration;
6926
+ cfg.liveSyncDurationCount = 3;
6927
+ }
6928
+ if (this.debug) {
6929
+ var _details_targetduration;
6930
+ console.log("[StormcloudVideoPlayer] Live latency profile: ".concat(useLowLatency ? "LL-HLS (low latency)" : "standard live (stability)"), {
6931
+ isLowLatencyManifest: isLowLatencyManifest,
6932
+ lowLatencyModeRequested: !!this.config.lowLatencyMode,
6933
+ canBlockReload: details.canBlockReload,
6934
+ partTarget: details.partTarget,
6935
+ partHoldBack: details.partHoldBack,
6936
+ partListLength: Array.isArray(details.partList) ? details.partList.length : 0,
6937
+ targetDuration: (_details_targetduration = details.targetduration) !== null && _details_targetduration !== void 0 ? _details_targetduration : details.targetDuration,
6938
+ maxLiveSyncPlaybackRate: cfg.maxLiveSyncPlaybackRate,
6939
+ maxBufferHole: cfg.maxBufferHole
6940
+ });
6941
+ }
6942
+ }
6943
+ },
6944
+ {
6945
+ key: "isLowLatencyManifest",
6946
+ value: function isLowLatencyManifest(details) {
6947
+ if (!details) {
6948
+ return false;
6949
+ }
6950
+ var hasParts = Array.isArray(details.partList) && details.partList.length > 0;
6951
+ var hasPartTarget = typeof details.partTarget === "number" && details.partTarget > 0;
6952
+ var hasPartHoldBack = typeof details.partHoldBack === "number" && details.partHoldBack > 0;
6953
+ var canBlockReload = details.canBlockReload === true;
6954
+ return hasParts || hasPartTarget || hasPartHoldBack || canBlockReload;
6955
+ }
6956
+ },
6892
6957
  {
6893
6958
  key: "onId3Tag",
6894
6959
  value: function onId3Tag(tag) {
@@ -9374,6 +9439,12 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
9374
9439
  return this.hlsEngine.isLiveStream;
9375
9440
  }
9376
9441
  },
9442
+ {
9443
+ key: "isLowLatencyStream",
9444
+ value: function isLowLatencyStream() {
9445
+ return this.hlsEngine.isLowLatencyStream();
9446
+ }
9447
+ },
9377
9448
  {
9378
9449
  key: "videoElement",
9379
9450
  get: function get() {