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.
@@ -39,6 +39,7 @@ declare class StormcloudVideoPlayer {
39
39
  getStreamType(): "hls" | "other";
40
40
  shouldShowNativeControls(): boolean;
41
41
  isLive(): boolean;
42
+ isLowLatencyStream(): boolean | undefined;
42
43
  get videoElement(): HTMLVideoElement;
43
44
  toggleMute(): void;
44
45
  toggleFullscreen(): Promise<void>;
@@ -1086,7 +1086,7 @@ function createHlsAdPlayer(contentVideo, options) {
1086
1086
  }
1087
1087
  function fetchAndParsePod(vastTagUrl) {
1088
1088
  return _async_to_generator(function() {
1089
- var vastXml, parser, xmlDoc, adElements, ads, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, adElement, parsed, resolved, error, err;
1089
+ var vastXml, trimmedXml, parser, xmlDoc, adElements, ads, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, adElement, parsed, resolved, error, err;
1090
1090
  return _ts_generator(this, function(_state) {
1091
1091
  switch(_state.label){
1092
1092
  case 0:
@@ -1096,11 +1096,19 @@ function createHlsAdPlayer(contentVideo, options) {
1096
1096
  ];
1097
1097
  case 1:
1098
1098
  vastXml = _state.sent();
1099
- console.log("[HlsAdPlayer] Pod VAST XML received");
1099
+ console.log("[HlsAdPlayer] Pod VAST XML received (length=".concat(vastXml.length, ")"));
1100
+ trimmedXml = vastXml.trim();
1101
+ if (trimmedXml.length === 0) {
1102
+ console.warn("[HlsAdPlayer] Pod VAST response body is empty (no fill)");
1103
+ return [
1104
+ 2,
1105
+ []
1106
+ ];
1107
+ }
1100
1108
  parser = new DOMParser();
1101
1109
  xmlDoc = parser.parseFromString(vastXml, "text/xml");
1102
1110
  if (xmlDoc.querySelector("parsererror")) {
1103
- console.error("[HlsAdPlayer] Pod VAST XML parsing error (malformed)");
1111
+ console.error("[HlsAdPlayer] Pod VAST XML parsing error (malformed). Content (first 2000 chars):", vastXml.substring(0, 2e3));
1104
1112
  return [
1105
1113
  2,
1106
1114
  []
@@ -1108,7 +1116,7 @@ function createHlsAdPlayer(contentVideo, options) {
1108
1116
  }
1109
1117
  adElements = Array.from(xmlDoc.querySelectorAll("Ad"));
1110
1118
  if (adElements.length === 0) {
1111
- console.warn("[HlsAdPlayer] No <Ad> elements found in pod VAST response");
1119
+ console.warn("[HlsAdPlayer] No <Ad> elements found in pod VAST response (no fill). Content (first 2000 chars):", vastXml.substring(0, 2e3));
1112
1120
  return [
1113
1121
  2,
1114
1122
  []
@@ -6483,6 +6491,7 @@ var HlsEngine = /*#__PURE__*/ function() {
6483
6491
  this.bufferedSegmentsCount = 0;
6484
6492
  this.shouldAutoplayAfterBuffering = false;
6485
6493
  this.hasInitialBufferCompleted = false;
6494
+ this.latencyProfileApplied = false;
6486
6495
  this.config = config;
6487
6496
  this.video = video;
6488
6497
  this.cueManager = cueManager;
@@ -6551,24 +6560,21 @@ var HlsEngine = /*#__PURE__*/ function() {
6551
6560
  key: "setupHls",
6552
6561
  value: function setupHls() {
6553
6562
  var _this = this;
6554
- this.hls = new import_hls2.default(_object_spread_props(_object_spread({
6563
+ this.hls = new import_hls2.default({
6555
6564
  enableWorker: true,
6556
6565
  backBufferLength: 30,
6557
6566
  liveDurationInfinity: true,
6558
6567
  lowLatencyMode: !!this.config.lowLatencyMode,
6559
- maxLiveSyncPlaybackRate: this.config.lowLatencyMode ? 1.5 : 1
6560
- }, this.config.lowLatencyMode ? {
6561
- liveSyncDuration: 2
6562
- } : {}), {
6568
+ maxLiveSyncPlaybackRate: 1.1,
6563
6569
  maxBufferLength: 30,
6564
6570
  maxMaxBufferLength: 600,
6565
6571
  maxBufferSize: 60 * 1e3 * 1e3,
6566
- maxBufferHole: 0.5,
6572
+ maxBufferHole: 1,
6567
6573
  highBufferWatchdogPeriod: 2,
6568
- nudgeOffset: 0.1,
6569
- nudgeMaxRetry: 3,
6574
+ nudgeOffset: 0.2,
6575
+ nudgeMaxRetry: 5,
6570
6576
  startPosition: -1
6571
- }));
6577
+ });
6572
6578
  this.hls.on(import_hls2.default.Events.MEDIA_ATTACHED, function() {
6573
6579
  var _this_hls;
6574
6580
  (_this_hls = _this.hls) === null || _this_hls === void 0 ? void 0 : _this_hls.loadSource(_this.config.src);
@@ -6592,6 +6598,8 @@ var HlsEngine = /*#__PURE__*/ function() {
6592
6598
  this.bufferedSegmentsCount = 0;
6593
6599
  this.hasInitialBufferCompleted = false;
6594
6600
  this.shouldAutoplayAfterBuffering = !!this.config.autoplay;
6601
+ this.latencyProfileApplied = false;
6602
+ this.detectedLowLatencyStream = void 0;
6595
6603
  minSegments = (_this_config_minSegmentsBeforePlay = this.config.minSegmentsBeforePlay) !== null && _this_config_minSegmentsBeforePlay !== void 0 ? _this_config_minSegmentsBeforePlay : 2;
6596
6604
  if (this.debug) {
6597
6605
  console.log("[StormcloudVideoPlayer] Waiting for", minSegments, "segments to buffer before playback");
@@ -6622,6 +6630,7 @@ var HlsEngine = /*#__PURE__*/ function() {
6622
6630
  }).call(_this);
6623
6631
  });
6624
6632
  this.hls.on(import_hls2.default.Events.LEVEL_LOADED, function(_evt, data) {
6633
+ _this.applyStreamLatencyProfile(data === null || data === void 0 ? void 0 : data.details);
6625
6634
  if (_this.callbacks.isInAdBreak() || _this.callbacks.hasPendingAdBreak()) {
6626
6635
  return;
6627
6636
  }
@@ -6895,6 +6904,70 @@ var HlsEngine = /*#__PURE__*/ function() {
6895
6904
  this.hls.attachMedia(this.video);
6896
6905
  }
6897
6906
  },
6907
+ {
6908
+ key: "isLowLatencyStream",
6909
+ value: function isLowLatencyStream() {
6910
+ return this.detectedLowLatencyStream;
6911
+ }
6912
+ },
6913
+ {
6914
+ key: "applyStreamLatencyProfile",
6915
+ value: function applyStreamLatencyProfile(details) {
6916
+ if (this.latencyProfileApplied || !this.hls) {
6917
+ return;
6918
+ }
6919
+ if (!details) {
6920
+ return;
6921
+ }
6922
+ if (details.live !== true) {
6923
+ this.latencyProfileApplied = true;
6924
+ this.detectedLowLatencyStream = false;
6925
+ return;
6926
+ }
6927
+ var isLowLatencyManifest = this.isLowLatencyManifest(details);
6928
+ var useLowLatency = isLowLatencyManifest && !!this.config.lowLatencyMode;
6929
+ this.detectedLowLatencyStream = useLowLatency;
6930
+ this.latencyProfileApplied = true;
6931
+ var cfg = this.hls.config;
6932
+ if (useLowLatency) {
6933
+ cfg.maxLiveSyncPlaybackRate = 1.5;
6934
+ cfg.maxBufferHole = 0.5;
6935
+ delete cfg.liveSyncDuration;
6936
+ } else {
6937
+ cfg.maxLiveSyncPlaybackRate = 1.1;
6938
+ cfg.maxBufferHole = 1;
6939
+ delete cfg.liveSyncDuration;
6940
+ cfg.liveSyncDurationCount = 3;
6941
+ }
6942
+ if (this.debug) {
6943
+ var _details_targetduration;
6944
+ console.log("[StormcloudVideoPlayer] Live latency profile: ".concat(useLowLatency ? "LL-HLS (low latency)" : "standard live (stability)"), {
6945
+ isLowLatencyManifest: isLowLatencyManifest,
6946
+ lowLatencyModeRequested: !!this.config.lowLatencyMode,
6947
+ canBlockReload: details.canBlockReload,
6948
+ partTarget: details.partTarget,
6949
+ partHoldBack: details.partHoldBack,
6950
+ partListLength: Array.isArray(details.partList) ? details.partList.length : 0,
6951
+ targetDuration: (_details_targetduration = details.targetduration) !== null && _details_targetduration !== void 0 ? _details_targetduration : details.targetDuration,
6952
+ maxLiveSyncPlaybackRate: cfg.maxLiveSyncPlaybackRate,
6953
+ maxBufferHole: cfg.maxBufferHole
6954
+ });
6955
+ }
6956
+ }
6957
+ },
6958
+ {
6959
+ key: "isLowLatencyManifest",
6960
+ value: function isLowLatencyManifest(details) {
6961
+ if (!details) {
6962
+ return false;
6963
+ }
6964
+ var hasParts = Array.isArray(details.partList) && details.partList.length > 0;
6965
+ var hasPartTarget = typeof details.partTarget === "number" && details.partTarget > 0;
6966
+ var hasPartHoldBack = typeof details.partHoldBack === "number" && details.partHoldBack > 0;
6967
+ var canBlockReload = details.canBlockReload === true;
6968
+ return hasParts || hasPartTarget || hasPartHoldBack || canBlockReload;
6969
+ }
6970
+ },
6898
6971
  {
6899
6972
  key: "onId3Tag",
6900
6973
  value: function onId3Tag(tag) {
@@ -9380,6 +9453,12 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
9380
9453
  return this.hlsEngine.isLiveStream;
9381
9454
  }
9382
9455
  },
9456
+ {
9457
+ key: "isLowLatencyStream",
9458
+ value: function isLowLatencyStream() {
9459
+ return this.hlsEngine.isLowLatencyStream();
9460
+ }
9461
+ },
9383
9462
  {
9384
9463
  key: "videoElement",
9385
9464
  get: function get() {