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.
@@ -1122,7 +1122,7 @@ function createHlsAdPlayer(contentVideo, options) {
1122
1122
  }
1123
1123
  function fetchAndParsePod(vastTagUrl) {
1124
1124
  return _async_to_generator(function() {
1125
- var vastXml, parser, xmlDoc, adElements, ads, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, adElement, parsed, resolved, error, err;
1125
+ var vastXml, trimmedXml, parser, xmlDoc, adElements, ads, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, adElement, parsed, resolved, error, err;
1126
1126
  return _ts_generator(this, function(_state) {
1127
1127
  switch(_state.label){
1128
1128
  case 0:
@@ -1132,11 +1132,19 @@ function createHlsAdPlayer(contentVideo, options) {
1132
1132
  ];
1133
1133
  case 1:
1134
1134
  vastXml = _state.sent();
1135
- console.log("[HlsAdPlayer] Pod VAST XML received");
1135
+ console.log("[HlsAdPlayer] Pod VAST XML received (length=".concat(vastXml.length, ")"));
1136
+ trimmedXml = vastXml.trim();
1137
+ if (trimmedXml.length === 0) {
1138
+ console.warn("[HlsAdPlayer] Pod VAST response body is empty (no fill)");
1139
+ return [
1140
+ 2,
1141
+ []
1142
+ ];
1143
+ }
1136
1144
  parser = new DOMParser();
1137
1145
  xmlDoc = parser.parseFromString(vastXml, "text/xml");
1138
1146
  if (xmlDoc.querySelector("parsererror")) {
1139
- console.error("[HlsAdPlayer] Pod VAST XML parsing error (malformed)");
1147
+ console.error("[HlsAdPlayer] Pod VAST XML parsing error (malformed). Content (first 2000 chars):", vastXml.substring(0, 2e3));
1140
1148
  return [
1141
1149
  2,
1142
1150
  []
@@ -1144,7 +1152,7 @@ function createHlsAdPlayer(contentVideo, options) {
1144
1152
  }
1145
1153
  adElements = Array.from(xmlDoc.querySelectorAll("Ad"));
1146
1154
  if (adElements.length === 0) {
1147
- console.warn("[HlsAdPlayer] No <Ad> elements found in pod VAST response");
1155
+ console.warn("[HlsAdPlayer] No <Ad> elements found in pod VAST response (no fill). Content (first 2000 chars):", vastXml.substring(0, 2e3));
1148
1156
  return [
1149
1157
  2,
1150
1158
  []
@@ -6519,6 +6527,7 @@ var HlsEngine = /*#__PURE__*/ function() {
6519
6527
  this.bufferedSegmentsCount = 0;
6520
6528
  this.shouldAutoplayAfterBuffering = false;
6521
6529
  this.hasInitialBufferCompleted = false;
6530
+ this.latencyProfileApplied = false;
6522
6531
  this.config = config;
6523
6532
  this.video = video;
6524
6533
  this.cueManager = cueManager;
@@ -6587,24 +6596,21 @@ var HlsEngine = /*#__PURE__*/ function() {
6587
6596
  key: "setupHls",
6588
6597
  value: function setupHls() {
6589
6598
  var _this = this;
6590
- this.hls = new import_hls2.default(_object_spread_props(_object_spread({
6599
+ this.hls = new import_hls2.default({
6591
6600
  enableWorker: true,
6592
6601
  backBufferLength: 30,
6593
6602
  liveDurationInfinity: true,
6594
6603
  lowLatencyMode: !!this.config.lowLatencyMode,
6595
- maxLiveSyncPlaybackRate: this.config.lowLatencyMode ? 1.5 : 1
6596
- }, this.config.lowLatencyMode ? {
6597
- liveSyncDuration: 2
6598
- } : {}), {
6604
+ maxLiveSyncPlaybackRate: 1.1,
6599
6605
  maxBufferLength: 30,
6600
6606
  maxMaxBufferLength: 600,
6601
6607
  maxBufferSize: 60 * 1e3 * 1e3,
6602
- maxBufferHole: 0.5,
6608
+ maxBufferHole: 1,
6603
6609
  highBufferWatchdogPeriod: 2,
6604
- nudgeOffset: 0.1,
6605
- nudgeMaxRetry: 3,
6610
+ nudgeOffset: 0.2,
6611
+ nudgeMaxRetry: 5,
6606
6612
  startPosition: -1
6607
- }));
6613
+ });
6608
6614
  this.hls.on(import_hls2.default.Events.MEDIA_ATTACHED, function() {
6609
6615
  var _this_hls;
6610
6616
  (_this_hls = _this.hls) === null || _this_hls === void 0 ? void 0 : _this_hls.loadSource(_this.config.src);
@@ -6628,6 +6634,8 @@ var HlsEngine = /*#__PURE__*/ function() {
6628
6634
  this.bufferedSegmentsCount = 0;
6629
6635
  this.hasInitialBufferCompleted = false;
6630
6636
  this.shouldAutoplayAfterBuffering = !!this.config.autoplay;
6637
+ this.latencyProfileApplied = false;
6638
+ this.detectedLowLatencyStream = void 0;
6631
6639
  minSegments = (_this_config_minSegmentsBeforePlay = this.config.minSegmentsBeforePlay) !== null && _this_config_minSegmentsBeforePlay !== void 0 ? _this_config_minSegmentsBeforePlay : 2;
6632
6640
  if (this.debug) {
6633
6641
  console.log("[StormcloudVideoPlayer] Waiting for", minSegments, "segments to buffer before playback");
@@ -6658,6 +6666,7 @@ var HlsEngine = /*#__PURE__*/ function() {
6658
6666
  }).call(_this);
6659
6667
  });
6660
6668
  this.hls.on(import_hls2.default.Events.LEVEL_LOADED, function(_evt, data) {
6669
+ _this.applyStreamLatencyProfile(data === null || data === void 0 ? void 0 : data.details);
6661
6670
  if (_this.callbacks.isInAdBreak() || _this.callbacks.hasPendingAdBreak()) {
6662
6671
  return;
6663
6672
  }
@@ -6931,6 +6940,70 @@ var HlsEngine = /*#__PURE__*/ function() {
6931
6940
  this.hls.attachMedia(this.video);
6932
6941
  }
6933
6942
  },
6943
+ {
6944
+ key: "isLowLatencyStream",
6945
+ value: function isLowLatencyStream() {
6946
+ return this.detectedLowLatencyStream;
6947
+ }
6948
+ },
6949
+ {
6950
+ key: "applyStreamLatencyProfile",
6951
+ value: function applyStreamLatencyProfile(details) {
6952
+ if (this.latencyProfileApplied || !this.hls) {
6953
+ return;
6954
+ }
6955
+ if (!details) {
6956
+ return;
6957
+ }
6958
+ if (details.live !== true) {
6959
+ this.latencyProfileApplied = true;
6960
+ this.detectedLowLatencyStream = false;
6961
+ return;
6962
+ }
6963
+ var isLowLatencyManifest = this.isLowLatencyManifest(details);
6964
+ var useLowLatency = isLowLatencyManifest && !!this.config.lowLatencyMode;
6965
+ this.detectedLowLatencyStream = useLowLatency;
6966
+ this.latencyProfileApplied = true;
6967
+ var cfg = this.hls.config;
6968
+ if (useLowLatency) {
6969
+ cfg.maxLiveSyncPlaybackRate = 1.5;
6970
+ cfg.maxBufferHole = 0.5;
6971
+ delete cfg.liveSyncDuration;
6972
+ } else {
6973
+ cfg.maxLiveSyncPlaybackRate = 1.1;
6974
+ cfg.maxBufferHole = 1;
6975
+ delete cfg.liveSyncDuration;
6976
+ cfg.liveSyncDurationCount = 3;
6977
+ }
6978
+ if (this.debug) {
6979
+ var _details_targetduration;
6980
+ console.log("[StormcloudVideoPlayer] Live latency profile: ".concat(useLowLatency ? "LL-HLS (low latency)" : "standard live (stability)"), {
6981
+ isLowLatencyManifest: isLowLatencyManifest,
6982
+ lowLatencyModeRequested: !!this.config.lowLatencyMode,
6983
+ canBlockReload: details.canBlockReload,
6984
+ partTarget: details.partTarget,
6985
+ partHoldBack: details.partHoldBack,
6986
+ partListLength: Array.isArray(details.partList) ? details.partList.length : 0,
6987
+ targetDuration: (_details_targetduration = details.targetduration) !== null && _details_targetduration !== void 0 ? _details_targetduration : details.targetDuration,
6988
+ maxLiveSyncPlaybackRate: cfg.maxLiveSyncPlaybackRate,
6989
+ maxBufferHole: cfg.maxBufferHole
6990
+ });
6991
+ }
6992
+ }
6993
+ },
6994
+ {
6995
+ key: "isLowLatencyManifest",
6996
+ value: function isLowLatencyManifest(details) {
6997
+ if (!details) {
6998
+ return false;
6999
+ }
7000
+ var hasParts = Array.isArray(details.partList) && details.partList.length > 0;
7001
+ var hasPartTarget = typeof details.partTarget === "number" && details.partTarget > 0;
7002
+ var hasPartHoldBack = typeof details.partHoldBack === "number" && details.partHoldBack > 0;
7003
+ var canBlockReload = details.canBlockReload === true;
7004
+ return hasParts || hasPartTarget || hasPartHoldBack || canBlockReload;
7005
+ }
7006
+ },
6934
7007
  {
6935
7008
  key: "onId3Tag",
6936
7009
  value: function onId3Tag(tag) {
@@ -9416,6 +9489,12 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
9416
9489
  return this.hlsEngine.isLiveStream;
9417
9490
  }
9418
9491
  },
9492
+ {
9493
+ key: "isLowLatencyStream",
9494
+ value: function isLowLatencyStream() {
9495
+ return this.hlsEngine.isLowLatencyStream();
9496
+ }
9497
+ },
9419
9498
  {
9420
9499
  key: "videoElement",
9421
9500
  get: function get() {