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.
@@ -1072,7 +1072,7 @@ function createHlsAdPlayer(contentVideo, options) {
1072
1072
  }
1073
1073
  function fetchAndParsePod(vastTagUrl) {
1074
1074
  return _async_to_generator(function() {
1075
- var vastXml, parser, xmlDoc, adElements, ads, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, adElement, parsed, resolved, error, err;
1075
+ var vastXml, trimmedXml, parser, xmlDoc, adElements, ads, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, adElement, parsed, resolved, error, err;
1076
1076
  return _ts_generator(this, function(_state) {
1077
1077
  switch(_state.label){
1078
1078
  case 0:
@@ -1082,11 +1082,19 @@ function createHlsAdPlayer(contentVideo, options) {
1082
1082
  ];
1083
1083
  case 1:
1084
1084
  vastXml = _state.sent();
1085
- console.log("[HlsAdPlayer] Pod VAST XML received");
1085
+ console.log("[HlsAdPlayer] Pod VAST XML received (length=".concat(vastXml.length, ")"));
1086
+ trimmedXml = vastXml.trim();
1087
+ if (trimmedXml.length === 0) {
1088
+ console.warn("[HlsAdPlayer] Pod VAST response body is empty (no fill)");
1089
+ return [
1090
+ 2,
1091
+ []
1092
+ ];
1093
+ }
1086
1094
  parser = new DOMParser();
1087
1095
  xmlDoc = parser.parseFromString(vastXml, "text/xml");
1088
1096
  if (xmlDoc.querySelector("parsererror")) {
1089
- console.error("[HlsAdPlayer] Pod VAST XML parsing error (malformed)");
1097
+ console.error("[HlsAdPlayer] Pod VAST XML parsing error (malformed). Content (first 2000 chars):", vastXml.substring(0, 2e3));
1090
1098
  return [
1091
1099
  2,
1092
1100
  []
@@ -1094,7 +1102,7 @@ function createHlsAdPlayer(contentVideo, options) {
1094
1102
  }
1095
1103
  adElements = Array.from(xmlDoc.querySelectorAll("Ad"));
1096
1104
  if (adElements.length === 0) {
1097
- console.warn("[HlsAdPlayer] No <Ad> elements found in pod VAST response");
1105
+ console.warn("[HlsAdPlayer] No <Ad> elements found in pod VAST response (no fill). Content (first 2000 chars):", vastXml.substring(0, 2e3));
1098
1106
  return [
1099
1107
  2,
1100
1108
  []
@@ -6469,6 +6477,7 @@ var HlsEngine = /*#__PURE__*/ function() {
6469
6477
  this.bufferedSegmentsCount = 0;
6470
6478
  this.shouldAutoplayAfterBuffering = false;
6471
6479
  this.hasInitialBufferCompleted = false;
6480
+ this.latencyProfileApplied = false;
6472
6481
  this.config = config;
6473
6482
  this.video = video;
6474
6483
  this.cueManager = cueManager;
@@ -6537,24 +6546,21 @@ var HlsEngine = /*#__PURE__*/ function() {
6537
6546
  key: "setupHls",
6538
6547
  value: function setupHls() {
6539
6548
  var _this = this;
6540
- this.hls = new import_hls2.default(_object_spread_props(_object_spread({
6549
+ this.hls = new import_hls2.default({
6541
6550
  enableWorker: true,
6542
6551
  backBufferLength: 30,
6543
6552
  liveDurationInfinity: true,
6544
6553
  lowLatencyMode: !!this.config.lowLatencyMode,
6545
- maxLiveSyncPlaybackRate: this.config.lowLatencyMode ? 1.5 : 1
6546
- }, this.config.lowLatencyMode ? {
6547
- liveSyncDuration: 2
6548
- } : {}), {
6554
+ maxLiveSyncPlaybackRate: 1.1,
6549
6555
  maxBufferLength: 30,
6550
6556
  maxMaxBufferLength: 600,
6551
6557
  maxBufferSize: 60 * 1e3 * 1e3,
6552
- maxBufferHole: 0.5,
6558
+ maxBufferHole: 1,
6553
6559
  highBufferWatchdogPeriod: 2,
6554
- nudgeOffset: 0.1,
6555
- nudgeMaxRetry: 3,
6560
+ nudgeOffset: 0.2,
6561
+ nudgeMaxRetry: 5,
6556
6562
  startPosition: -1
6557
- }));
6563
+ });
6558
6564
  this.hls.on(import_hls2.default.Events.MEDIA_ATTACHED, function() {
6559
6565
  var _this_hls;
6560
6566
  (_this_hls = _this.hls) === null || _this_hls === void 0 ? void 0 : _this_hls.loadSource(_this.config.src);
@@ -6578,6 +6584,8 @@ var HlsEngine = /*#__PURE__*/ function() {
6578
6584
  this.bufferedSegmentsCount = 0;
6579
6585
  this.hasInitialBufferCompleted = false;
6580
6586
  this.shouldAutoplayAfterBuffering = !!this.config.autoplay;
6587
+ this.latencyProfileApplied = false;
6588
+ this.detectedLowLatencyStream = void 0;
6581
6589
  minSegments = (_this_config_minSegmentsBeforePlay = this.config.minSegmentsBeforePlay) !== null && _this_config_minSegmentsBeforePlay !== void 0 ? _this_config_minSegmentsBeforePlay : 2;
6582
6590
  if (this.debug) {
6583
6591
  console.log("[StormcloudVideoPlayer] Waiting for", minSegments, "segments to buffer before playback");
@@ -6608,6 +6616,7 @@ var HlsEngine = /*#__PURE__*/ function() {
6608
6616
  }).call(_this);
6609
6617
  });
6610
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);
6611
6620
  if (_this.callbacks.isInAdBreak() || _this.callbacks.hasPendingAdBreak()) {
6612
6621
  return;
6613
6622
  }
@@ -6881,6 +6890,70 @@ var HlsEngine = /*#__PURE__*/ function() {
6881
6890
  this.hls.attachMedia(this.video);
6882
6891
  }
6883
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
+ },
6884
6957
  {
6885
6958
  key: "onId3Tag",
6886
6959
  value: function onId3Tag(tag) {
@@ -9366,6 +9439,12 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
9366
9439
  return this.hlsEngine.isLiveStream;
9367
9440
  }
9368
9441
  },
9442
+ {
9443
+ key: "isLowLatencyStream",
9444
+ value: function isLowLatencyStream() {
9445
+ return this.hlsEngine.isLowLatencyStream();
9446
+ }
9447
+ },
9369
9448
  {
9370
9449
  key: "videoElement",
9371
9450
  get: function get() {