stormcloud-video-player 0.3.67 → 0.3.68

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/lib/index.cjs CHANGED
@@ -2002,7 +2002,7 @@ function createHlsAdPlayer(contentVideo, options) {
2002
2002
  }
2003
2003
  var adElement = xmlDoc.querySelector("Ad");
2004
2004
  if (!adElement) {
2005
- console.warn("[HlsAdPlayer] No Ad element found in VAST XML");
2005
+ console.warn("[HlsAdPlayer] No Ad element found in VAST XML (no fill). Content (first 2000 chars):", xmlString.substring(0, 2e3));
2006
2006
  return null;
2007
2007
  }
2008
2008
  var adId = adElement.getAttribute("id") || "unknown";
@@ -2098,7 +2098,7 @@ function createHlsAdPlayer(contentVideo, options) {
2098
2098
  }
2099
2099
  function fetchAndParseVastAd(vastTagUrl) {
2100
2100
  return _async_to_generator(function() {
2101
- var response, vastXml;
2101
+ var response, vastXml, trimmedXml;
2102
2102
  return _ts_generator(this, function(_state) {
2103
2103
  switch(_state.label){
2104
2104
  case 0:
@@ -2124,8 +2124,16 @@ function createHlsAdPlayer(contentVideo, options) {
2124
2124
  ];
2125
2125
  case 2:
2126
2126
  vastXml = _state.sent();
2127
- console.log("[HlsAdPlayer] VAST XML received");
2127
+ console.log("[HlsAdPlayer] VAST XML received (length=".concat(vastXml.length, ")"));
2128
2128
  console.log("[HlsAdPlayer] VAST XML content (first 2000 chars):", vastXml.substring(0, 2e3));
2129
+ trimmedXml = vastXml.trim();
2130
+ if (trimmedXml.length === 0) {
2131
+ console.warn("[HlsAdPlayer] VAST response body is empty (no fill)");
2132
+ return [
2133
+ 2,
2134
+ null
2135
+ ];
2136
+ }
2129
2137
  return [
2130
2138
  2,
2131
2139
  parseVastXml(vastXml)
@@ -3586,6 +3594,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3586
3594
  this.preloadPoolActive = false;
3587
3595
  this.preloadPoolLoopRunning = false;
3588
3596
  this.adDetectSentForCurrentBreak = false;
3597
+ this.latencyProfileApplied = false;
3589
3598
  this.continuousFetchLoopRunning = false;
3590
3599
  initializePolyfills();
3591
3600
  var browserOverrides = getBrowserConfigOverrides();
@@ -3702,24 +3711,21 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3702
3711
  2
3703
3712
  ];
3704
3713
  case 7:
3705
- this.hls = new import_hls2.default(_object_spread_props(_object_spread({
3714
+ this.hls = new import_hls2.default({
3706
3715
  enableWorker: true,
3707
3716
  backBufferLength: 30,
3708
3717
  liveDurationInfinity: true,
3709
3718
  lowLatencyMode: !!this.config.lowLatencyMode,
3710
- maxLiveSyncPlaybackRate: this.config.lowLatencyMode ? 1.5 : 1
3711
- }, this.config.lowLatencyMode ? {
3712
- liveSyncDuration: 2
3713
- } : {}), {
3719
+ maxLiveSyncPlaybackRate: 1.1,
3714
3720
  maxBufferLength: 30,
3715
3721
  maxMaxBufferLength: 600,
3716
3722
  maxBufferSize: 60 * 1e3 * 1e3,
3717
- maxBufferHole: 0.5,
3723
+ maxBufferHole: 1,
3718
3724
  highBufferWatchdogPeriod: 2,
3719
- nudgeOffset: 0.1,
3720
- nudgeMaxRetry: 3,
3725
+ nudgeOffset: 0.2,
3726
+ nudgeMaxRetry: 5,
3721
3727
  startPosition: -1
3722
- }));
3728
+ });
3723
3729
  this.hls.on(import_hls2.default.Events.MEDIA_ATTACHED, function() {
3724
3730
  var _this_hls;
3725
3731
  (_this_hls = _this.hls) === null || _this_hls === void 0 ? void 0 : _this_hls.loadSource(_this.config.src);
@@ -3763,6 +3769,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3763
3769
  this.bufferedSegmentsCount = 0;
3764
3770
  this.hasInitialBufferCompleted = false;
3765
3771
  this.shouldAutoplayAfterBuffering = !!this.config.autoplay;
3772
+ this.latencyProfileApplied = false;
3773
+ this.detectedLowLatencyStream = void 0;
3766
3774
  minSegments = (_this_config_minSegmentsBeforePlay = this.config.minSegmentsBeforePlay) !== null && _this_config_minSegmentsBeforePlay !== void 0 ? _this_config_minSegmentsBeforePlay : 2;
3767
3775
  if (this.config.debugAdTiming) {
3768
3776
  console.log("[StormcloudVideoPlayer] Waiting for", minSegments, "segments to buffer before playback");
@@ -3792,6 +3800,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3792
3800
  }).call(_this);
3793
3801
  });
3794
3802
  this.hls.on(import_hls2.default.Events.LEVEL_LOADED, function(_evt, data) {
3803
+ _this.applyStreamLatencyProfile(data === null || data === void 0 ? void 0 : data.details);
3795
3804
  if (_this.inAdBreak || _this.pendingAdBreak) {
3796
3805
  return;
3797
3806
  }
@@ -4071,6 +4080,64 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4071
4080
  }).call(this);
4072
4081
  }
4073
4082
  },
4083
+ {
4084
+ key: "applyStreamLatencyProfile",
4085
+ value: function applyStreamLatencyProfile(details) {
4086
+ if (this.latencyProfileApplied || !this.hls) {
4087
+ return;
4088
+ }
4089
+ if (!details) {
4090
+ return;
4091
+ }
4092
+ if (details.live !== true) {
4093
+ this.latencyProfileApplied = true;
4094
+ this.detectedLowLatencyStream = false;
4095
+ return;
4096
+ }
4097
+ var isLowLatencyManifest = this.isLowLatencyManifest(details);
4098
+ var useLowLatency = isLowLatencyManifest && !!this.config.lowLatencyMode;
4099
+ this.detectedLowLatencyStream = useLowLatency;
4100
+ this.latencyProfileApplied = true;
4101
+ var cfg = this.hls.config;
4102
+ if (useLowLatency) {
4103
+ cfg.maxLiveSyncPlaybackRate = 1.5;
4104
+ cfg.maxBufferHole = 0.5;
4105
+ delete cfg.liveSyncDuration;
4106
+ } else {
4107
+ cfg.maxLiveSyncPlaybackRate = 1.1;
4108
+ cfg.maxBufferHole = 1;
4109
+ delete cfg.liveSyncDuration;
4110
+ cfg.liveSyncDurationCount = 3;
4111
+ }
4112
+ if (this.config.debugAdTiming) {
4113
+ var _details_targetduration;
4114
+ console.log("[StormcloudVideoPlayer] Live latency profile: ".concat(useLowLatency ? "LL-HLS (low latency)" : "standard live (stability)"), {
4115
+ isLowLatencyManifest: isLowLatencyManifest,
4116
+ lowLatencyModeRequested: !!this.config.lowLatencyMode,
4117
+ canBlockReload: details.canBlockReload,
4118
+ partTarget: details.partTarget,
4119
+ partHoldBack: details.partHoldBack,
4120
+ partListLength: Array.isArray(details.partList) ? details.partList.length : 0,
4121
+ targetDuration: (_details_targetduration = details.targetduration) !== null && _details_targetduration !== void 0 ? _details_targetduration : details.targetDuration,
4122
+ maxLiveSyncPlaybackRate: cfg.maxLiveSyncPlaybackRate,
4123
+ maxBufferHole: cfg.maxBufferHole
4124
+ });
4125
+ }
4126
+ }
4127
+ },
4128
+ {
4129
+ key: "isLowLatencyManifest",
4130
+ value: function isLowLatencyManifest(details) {
4131
+ if (!details) {
4132
+ return false;
4133
+ }
4134
+ var hasParts = Array.isArray(details.partList) && details.partList.length > 0;
4135
+ var hasPartTarget = typeof details.partTarget === "number" && details.partTarget > 0;
4136
+ var hasPartHoldBack = typeof details.partHoldBack === "number" && details.partHoldBack > 0;
4137
+ var canBlockReload = details.canBlockReload === true;
4138
+ return hasParts || hasPartTarget || hasPartHoldBack || canBlockReload;
4139
+ }
4140
+ },
4074
4141
  {
4075
4142
  key: "attachImaEventListeners",
4076
4143
  value: function attachImaEventListeners() {
@@ -6059,6 +6126,12 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6059
6126
  return !!(this.config.allowNativeHls && !((_this_config_showCustomControls = this.config.showCustomControls) !== null && _this_config_showCustomControls !== void 0 ? _this_config_showCustomControls : false));
6060
6127
  }
6061
6128
  },
6129
+ {
6130
+ key: "isLowLatencyStream",
6131
+ value: function isLowLatencyStream() {
6132
+ return this.detectedLowLatencyStream;
6133
+ }
6134
+ },
6062
6135
  {
6063
6136
  key: "shouldContinueLiveStreamDuringAds",
6064
6137
  value: function shouldContinueLiveStreamDuringAds() {