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.
@@ -21,6 +21,8 @@ declare class HlsEngine {
21
21
  private bufferedSegmentsCount;
22
22
  private shouldAutoplayAfterBuffering;
23
23
  private hasInitialBufferCompleted;
24
+ private detectedLowLatencyStream;
25
+ private latencyProfileApplied;
24
26
  private readonly config;
25
27
  private readonly video;
26
28
  private readonly cueManager;
@@ -31,6 +33,9 @@ declare class HlsEngine {
31
33
  shouldUseNativeHls(getStreamType: () => "hls" | "other"): boolean;
32
34
  setupNativeHls(): Promise<void>;
33
35
  setupHls(): void;
36
+ isLowLatencyStream(): boolean | undefined;
37
+ private applyStreamLatencyProfile;
38
+ private isLowLatencyManifest;
34
39
  private onId3Tag;
35
40
  private processFragmentScte35Payload;
36
41
  getLiveSyncPosition(): number | undefined;
@@ -6440,6 +6440,7 @@ var HlsEngine = /*#__PURE__*/ function() {
6440
6440
  this.bufferedSegmentsCount = 0;
6441
6441
  this.shouldAutoplayAfterBuffering = false;
6442
6442
  this.hasInitialBufferCompleted = false;
6443
+ this.latencyProfileApplied = false;
6443
6444
  this.config = config;
6444
6445
  this.video = video;
6445
6446
  this.cueManager = cueManager;
@@ -6508,24 +6509,21 @@ var HlsEngine = /*#__PURE__*/ function() {
6508
6509
  key: "setupHls",
6509
6510
  value: function setupHls() {
6510
6511
  var _this = this;
6511
- this.hls = new import_hls2.default(_object_spread_props(_object_spread({
6512
+ this.hls = new import_hls2.default({
6512
6513
  enableWorker: true,
6513
6514
  backBufferLength: 30,
6514
6515
  liveDurationInfinity: true,
6515
6516
  lowLatencyMode: !!this.config.lowLatencyMode,
6516
- maxLiveSyncPlaybackRate: this.config.lowLatencyMode ? 1.5 : 1
6517
- }, this.config.lowLatencyMode ? {
6518
- liveSyncDuration: 2
6519
- } : {}), {
6517
+ maxLiveSyncPlaybackRate: 1.1,
6520
6518
  maxBufferLength: 30,
6521
6519
  maxMaxBufferLength: 600,
6522
6520
  maxBufferSize: 60 * 1e3 * 1e3,
6523
- maxBufferHole: 0.5,
6521
+ maxBufferHole: 1,
6524
6522
  highBufferWatchdogPeriod: 2,
6525
- nudgeOffset: 0.1,
6526
- nudgeMaxRetry: 3,
6523
+ nudgeOffset: 0.2,
6524
+ nudgeMaxRetry: 5,
6527
6525
  startPosition: -1
6528
- }));
6526
+ });
6529
6527
  this.hls.on(import_hls2.default.Events.MEDIA_ATTACHED, function() {
6530
6528
  var _this_hls;
6531
6529
  (_this_hls = _this.hls) === null || _this_hls === void 0 ? void 0 : _this_hls.loadSource(_this.config.src);
@@ -6549,6 +6547,8 @@ var HlsEngine = /*#__PURE__*/ function() {
6549
6547
  this.bufferedSegmentsCount = 0;
6550
6548
  this.hasInitialBufferCompleted = false;
6551
6549
  this.shouldAutoplayAfterBuffering = !!this.config.autoplay;
6550
+ this.latencyProfileApplied = false;
6551
+ this.detectedLowLatencyStream = void 0;
6552
6552
  minSegments = (_this_config_minSegmentsBeforePlay = this.config.minSegmentsBeforePlay) !== null && _this_config_minSegmentsBeforePlay !== void 0 ? _this_config_minSegmentsBeforePlay : 2;
6553
6553
  if (this.debug) {
6554
6554
  console.log("[StormcloudVideoPlayer] Waiting for", minSegments, "segments to buffer before playback");
@@ -6579,6 +6579,7 @@ var HlsEngine = /*#__PURE__*/ function() {
6579
6579
  }).call(_this);
6580
6580
  });
6581
6581
  this.hls.on(import_hls2.default.Events.LEVEL_LOADED, function(_evt, data) {
6582
+ _this.applyStreamLatencyProfile(data === null || data === void 0 ? void 0 : data.details);
6582
6583
  if (_this.callbacks.isInAdBreak() || _this.callbacks.hasPendingAdBreak()) {
6583
6584
  return;
6584
6585
  }
@@ -6852,6 +6853,70 @@ var HlsEngine = /*#__PURE__*/ function() {
6852
6853
  this.hls.attachMedia(this.video);
6853
6854
  }
6854
6855
  },
6856
+ {
6857
+ key: "isLowLatencyStream",
6858
+ value: function isLowLatencyStream() {
6859
+ return this.detectedLowLatencyStream;
6860
+ }
6861
+ },
6862
+ {
6863
+ key: "applyStreamLatencyProfile",
6864
+ value: function applyStreamLatencyProfile(details) {
6865
+ if (this.latencyProfileApplied || !this.hls) {
6866
+ return;
6867
+ }
6868
+ if (!details) {
6869
+ return;
6870
+ }
6871
+ if (details.live !== true) {
6872
+ this.latencyProfileApplied = true;
6873
+ this.detectedLowLatencyStream = false;
6874
+ return;
6875
+ }
6876
+ var isLowLatencyManifest = this.isLowLatencyManifest(details);
6877
+ var useLowLatency = isLowLatencyManifest && !!this.config.lowLatencyMode;
6878
+ this.detectedLowLatencyStream = useLowLatency;
6879
+ this.latencyProfileApplied = true;
6880
+ var cfg = this.hls.config;
6881
+ if (useLowLatency) {
6882
+ cfg.maxLiveSyncPlaybackRate = 1.5;
6883
+ cfg.maxBufferHole = 0.5;
6884
+ delete cfg.liveSyncDuration;
6885
+ } else {
6886
+ cfg.maxLiveSyncPlaybackRate = 1.1;
6887
+ cfg.maxBufferHole = 1;
6888
+ delete cfg.liveSyncDuration;
6889
+ cfg.liveSyncDurationCount = 3;
6890
+ }
6891
+ if (this.debug) {
6892
+ var _details_targetduration;
6893
+ console.log("[StormcloudVideoPlayer] Live latency profile: ".concat(useLowLatency ? "LL-HLS (low latency)" : "standard live (stability)"), {
6894
+ isLowLatencyManifest: isLowLatencyManifest,
6895
+ lowLatencyModeRequested: !!this.config.lowLatencyMode,
6896
+ canBlockReload: details.canBlockReload,
6897
+ partTarget: details.partTarget,
6898
+ partHoldBack: details.partHoldBack,
6899
+ partListLength: Array.isArray(details.partList) ? details.partList.length : 0,
6900
+ targetDuration: (_details_targetduration = details.targetduration) !== null && _details_targetduration !== void 0 ? _details_targetduration : details.targetDuration,
6901
+ maxLiveSyncPlaybackRate: cfg.maxLiveSyncPlaybackRate,
6902
+ maxBufferHole: cfg.maxBufferHole
6903
+ });
6904
+ }
6905
+ }
6906
+ },
6907
+ {
6908
+ key: "isLowLatencyManifest",
6909
+ value: function isLowLatencyManifest(details) {
6910
+ if (!details) {
6911
+ return false;
6912
+ }
6913
+ var hasParts = Array.isArray(details.partList) && details.partList.length > 0;
6914
+ var hasPartTarget = typeof details.partTarget === "number" && details.partTarget > 0;
6915
+ var hasPartHoldBack = typeof details.partHoldBack === "number" && details.partHoldBack > 0;
6916
+ var canBlockReload = details.canBlockReload === true;
6917
+ return hasParts || hasPartTarget || hasPartHoldBack || canBlockReload;
6918
+ }
6919
+ },
6855
6920
  {
6856
6921
  key: "onId3Tag",
6857
6922
  value: function onId3Tag(tag) {
@@ -9337,6 +9402,12 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
9337
9402
  return this.hlsEngine.isLiveStream;
9338
9403
  }
9339
9404
  },
9405
+ {
9406
+ key: "isLowLatencyStream",
9407
+ value: function isLowLatencyStream() {
9408
+ return this.hlsEngine.isLowLatencyStream();
9409
+ }
9410
+ },
9340
9411
  {
9341
9412
  key: "videoElement",
9342
9413
  get: function get() {