stormcloud-video-player 0.8.52 → 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.
package/lib/index.cjs CHANGED
@@ -1299,7 +1299,7 @@ function createHlsAdPlayer(contentVideo, options) {
1299
1299
  }
1300
1300
  function fetchAndParsePod(vastTagUrl) {
1301
1301
  return _async_to_generator(function() {
1302
- var vastXml, parser, xmlDoc, adElements, ads, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, adElement, parsed, resolved, error, err;
1302
+ var vastXml, trimmedXml, parser, xmlDoc, adElements, ads, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, adElement, parsed, resolved, error, err;
1303
1303
  return _ts_generator(this, function(_state) {
1304
1304
  switch(_state.label){
1305
1305
  case 0:
@@ -1309,11 +1309,19 @@ function createHlsAdPlayer(contentVideo, options) {
1309
1309
  ];
1310
1310
  case 1:
1311
1311
  vastXml = _state.sent();
1312
- console.log("[HlsAdPlayer] Pod VAST XML received");
1312
+ console.log("[HlsAdPlayer] Pod VAST XML received (length=".concat(vastXml.length, ")"));
1313
+ trimmedXml = vastXml.trim();
1314
+ if (trimmedXml.length === 0) {
1315
+ console.warn("[HlsAdPlayer] Pod VAST response body is empty (no fill)");
1316
+ return [
1317
+ 2,
1318
+ []
1319
+ ];
1320
+ }
1313
1321
  parser = new DOMParser();
1314
1322
  xmlDoc = parser.parseFromString(vastXml, "text/xml");
1315
1323
  if (xmlDoc.querySelector("parsererror")) {
1316
- console.error("[HlsAdPlayer] Pod VAST XML parsing error (malformed)");
1324
+ console.error("[HlsAdPlayer] Pod VAST XML parsing error (malformed). Content (first 2000 chars):", vastXml.substring(0, 2e3));
1317
1325
  return [
1318
1326
  2,
1319
1327
  []
@@ -1321,7 +1329,7 @@ function createHlsAdPlayer(contentVideo, options) {
1321
1329
  }
1322
1330
  adElements = Array.from(xmlDoc.querySelectorAll("Ad"));
1323
1331
  if (adElements.length === 0) {
1324
- console.warn("[HlsAdPlayer] No <Ad> elements found in pod VAST response");
1332
+ console.warn("[HlsAdPlayer] No <Ad> elements found in pod VAST response (no fill). Content (first 2000 chars):", vastXml.substring(0, 2e3));
1325
1333
  return [
1326
1334
  2,
1327
1335
  []
@@ -6717,6 +6725,7 @@ var HlsEngine = /*#__PURE__*/ function() {
6717
6725
  this.bufferedSegmentsCount = 0;
6718
6726
  this.shouldAutoplayAfterBuffering = false;
6719
6727
  this.hasInitialBufferCompleted = false;
6728
+ this.latencyProfileApplied = false;
6720
6729
  this.config = config;
6721
6730
  this.video = video;
6722
6731
  this.cueManager = cueManager;
@@ -6785,24 +6794,21 @@ var HlsEngine = /*#__PURE__*/ function() {
6785
6794
  key: "setupHls",
6786
6795
  value: function setupHls() {
6787
6796
  var _this = this;
6788
- this.hls = new import_hls2.default(_object_spread_props(_object_spread({
6797
+ this.hls = new import_hls2.default({
6789
6798
  enableWorker: true,
6790
6799
  backBufferLength: 30,
6791
6800
  liveDurationInfinity: true,
6792
6801
  lowLatencyMode: !!this.config.lowLatencyMode,
6793
- maxLiveSyncPlaybackRate: this.config.lowLatencyMode ? 1.5 : 1
6794
- }, this.config.lowLatencyMode ? {
6795
- liveSyncDuration: 2
6796
- } : {}), {
6802
+ maxLiveSyncPlaybackRate: 1.1,
6797
6803
  maxBufferLength: 30,
6798
6804
  maxMaxBufferLength: 600,
6799
6805
  maxBufferSize: 60 * 1e3 * 1e3,
6800
- maxBufferHole: 0.5,
6806
+ maxBufferHole: 1,
6801
6807
  highBufferWatchdogPeriod: 2,
6802
- nudgeOffset: 0.1,
6803
- nudgeMaxRetry: 3,
6808
+ nudgeOffset: 0.2,
6809
+ nudgeMaxRetry: 5,
6804
6810
  startPosition: -1
6805
- }));
6811
+ });
6806
6812
  this.hls.on(import_hls2.default.Events.MEDIA_ATTACHED, function() {
6807
6813
  var _this_hls;
6808
6814
  (_this_hls = _this.hls) === null || _this_hls === void 0 ? void 0 : _this_hls.loadSource(_this.config.src);
@@ -6826,6 +6832,8 @@ var HlsEngine = /*#__PURE__*/ function() {
6826
6832
  this.bufferedSegmentsCount = 0;
6827
6833
  this.hasInitialBufferCompleted = false;
6828
6834
  this.shouldAutoplayAfterBuffering = !!this.config.autoplay;
6835
+ this.latencyProfileApplied = false;
6836
+ this.detectedLowLatencyStream = void 0;
6829
6837
  minSegments = (_this_config_minSegmentsBeforePlay = this.config.minSegmentsBeforePlay) !== null && _this_config_minSegmentsBeforePlay !== void 0 ? _this_config_minSegmentsBeforePlay : 2;
6830
6838
  if (this.debug) {
6831
6839
  console.log("[StormcloudVideoPlayer] Waiting for", minSegments, "segments to buffer before playback");
@@ -6856,6 +6864,7 @@ var HlsEngine = /*#__PURE__*/ function() {
6856
6864
  }).call(_this);
6857
6865
  });
6858
6866
  this.hls.on(import_hls2.default.Events.LEVEL_LOADED, function(_evt, data) {
6867
+ _this.applyStreamLatencyProfile(data === null || data === void 0 ? void 0 : data.details);
6859
6868
  if (_this.callbacks.isInAdBreak() || _this.callbacks.hasPendingAdBreak()) {
6860
6869
  return;
6861
6870
  }
@@ -7129,6 +7138,70 @@ var HlsEngine = /*#__PURE__*/ function() {
7129
7138
  this.hls.attachMedia(this.video);
7130
7139
  }
7131
7140
  },
7141
+ {
7142
+ key: "isLowLatencyStream",
7143
+ value: function isLowLatencyStream() {
7144
+ return this.detectedLowLatencyStream;
7145
+ }
7146
+ },
7147
+ {
7148
+ key: "applyStreamLatencyProfile",
7149
+ value: function applyStreamLatencyProfile(details) {
7150
+ if (this.latencyProfileApplied || !this.hls) {
7151
+ return;
7152
+ }
7153
+ if (!details) {
7154
+ return;
7155
+ }
7156
+ if (details.live !== true) {
7157
+ this.latencyProfileApplied = true;
7158
+ this.detectedLowLatencyStream = false;
7159
+ return;
7160
+ }
7161
+ var isLowLatencyManifest = this.isLowLatencyManifest(details);
7162
+ var useLowLatency = isLowLatencyManifest && !!this.config.lowLatencyMode;
7163
+ this.detectedLowLatencyStream = useLowLatency;
7164
+ this.latencyProfileApplied = true;
7165
+ var cfg = this.hls.config;
7166
+ if (useLowLatency) {
7167
+ cfg.maxLiveSyncPlaybackRate = 1.5;
7168
+ cfg.maxBufferHole = 0.5;
7169
+ delete cfg.liveSyncDuration;
7170
+ } else {
7171
+ cfg.maxLiveSyncPlaybackRate = 1.1;
7172
+ cfg.maxBufferHole = 1;
7173
+ delete cfg.liveSyncDuration;
7174
+ cfg.liveSyncDurationCount = 3;
7175
+ }
7176
+ if (this.debug) {
7177
+ var _details_targetduration;
7178
+ console.log("[StormcloudVideoPlayer] Live latency profile: ".concat(useLowLatency ? "LL-HLS (low latency)" : "standard live (stability)"), {
7179
+ isLowLatencyManifest: isLowLatencyManifest,
7180
+ lowLatencyModeRequested: !!this.config.lowLatencyMode,
7181
+ canBlockReload: details.canBlockReload,
7182
+ partTarget: details.partTarget,
7183
+ partHoldBack: details.partHoldBack,
7184
+ partListLength: Array.isArray(details.partList) ? details.partList.length : 0,
7185
+ targetDuration: (_details_targetduration = details.targetduration) !== null && _details_targetduration !== void 0 ? _details_targetduration : details.targetDuration,
7186
+ maxLiveSyncPlaybackRate: cfg.maxLiveSyncPlaybackRate,
7187
+ maxBufferHole: cfg.maxBufferHole
7188
+ });
7189
+ }
7190
+ }
7191
+ },
7192
+ {
7193
+ key: "isLowLatencyManifest",
7194
+ value: function isLowLatencyManifest(details) {
7195
+ if (!details) {
7196
+ return false;
7197
+ }
7198
+ var hasParts = Array.isArray(details.partList) && details.partList.length > 0;
7199
+ var hasPartTarget = typeof details.partTarget === "number" && details.partTarget > 0;
7200
+ var hasPartHoldBack = typeof details.partHoldBack === "number" && details.partHoldBack > 0;
7201
+ var canBlockReload = details.canBlockReload === true;
7202
+ return hasParts || hasPartTarget || hasPartHoldBack || canBlockReload;
7203
+ }
7204
+ },
7132
7205
  {
7133
7206
  key: "onId3Tag",
7134
7207
  value: function onId3Tag(tag) {
@@ -9614,6 +9687,12 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
9614
9687
  return this.hlsEngine.isLiveStream;
9615
9688
  }
9616
9689
  },
9690
+ {
9691
+ key: "isLowLatencyStream",
9692
+ value: function isLowLatencyStream() {
9693
+ return this.hlsEngine.isLowLatencyStream();
9694
+ }
9695
+ },
9617
9696
  {
9618
9697
  key: "videoElement",
9619
9698
  get: function get() {