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.d.cts CHANGED
@@ -207,6 +207,7 @@ declare class StormcloudVideoPlayer {
207
207
  getStreamType(): "hls" | "other";
208
208
  shouldShowNativeControls(): boolean;
209
209
  isLive(): boolean;
210
+ isLowLatencyStream(): boolean | undefined;
210
211
  get videoElement(): HTMLVideoElement;
211
212
  toggleMute(): void;
212
213
  toggleFullscreen(): Promise<void>;
package/lib/index.d.ts CHANGED
@@ -207,6 +207,7 @@ declare class StormcloudVideoPlayer {
207
207
  getStreamType(): "hls" | "other";
208
208
  shouldShowNativeControls(): boolean;
209
209
  isLive(): boolean;
210
+ isLowLatencyStream(): boolean | undefined;
210
211
  get videoElement(): HTMLVideoElement;
211
212
  toggleMute(): void;
212
213
  toggleFullscreen(): Promise<void>;
package/lib/index.js CHANGED
@@ -1079,7 +1079,7 @@ function createHlsAdPlayer(contentVideo, options) {
1079
1079
  }
1080
1080
  function fetchAndParsePod(vastTagUrl) {
1081
1081
  return _async_to_generator(function() {
1082
- var vastXml, parser, xmlDoc, adElements, ads, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, adElement, parsed, resolved, error, err;
1082
+ var vastXml, trimmedXml, parser, xmlDoc, adElements, ads, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, adElement, parsed, resolved, error, err;
1083
1083
  return _ts_generator(this, function(_state) {
1084
1084
  switch(_state.label){
1085
1085
  case 0:
@@ -1089,11 +1089,19 @@ function createHlsAdPlayer(contentVideo, options) {
1089
1089
  ];
1090
1090
  case 1:
1091
1091
  vastXml = _state.sent();
1092
- console.log("[HlsAdPlayer] Pod VAST XML received");
1092
+ console.log("[HlsAdPlayer] Pod VAST XML received (length=".concat(vastXml.length, ")"));
1093
+ trimmedXml = vastXml.trim();
1094
+ if (trimmedXml.length === 0) {
1095
+ console.warn("[HlsAdPlayer] Pod VAST response body is empty (no fill)");
1096
+ return [
1097
+ 2,
1098
+ []
1099
+ ];
1100
+ }
1093
1101
  parser = new DOMParser();
1094
1102
  xmlDoc = parser.parseFromString(vastXml, "text/xml");
1095
1103
  if (xmlDoc.querySelector("parsererror")) {
1096
- console.error("[HlsAdPlayer] Pod VAST XML parsing error (malformed)");
1104
+ console.error("[HlsAdPlayer] Pod VAST XML parsing error (malformed). Content (first 2000 chars):", vastXml.substring(0, 2e3));
1097
1105
  return [
1098
1106
  2,
1099
1107
  []
@@ -1101,7 +1109,7 @@ function createHlsAdPlayer(contentVideo, options) {
1101
1109
  }
1102
1110
  adElements = Array.from(xmlDoc.querySelectorAll("Ad"));
1103
1111
  if (adElements.length === 0) {
1104
- console.warn("[HlsAdPlayer] No <Ad> elements found in pod VAST response");
1112
+ console.warn("[HlsAdPlayer] No <Ad> elements found in pod VAST response (no fill). Content (first 2000 chars):", vastXml.substring(0, 2e3));
1105
1113
  return [
1106
1114
  2,
1107
1115
  []
@@ -6505,6 +6513,7 @@ var HlsEngine = /*#__PURE__*/ function() {
6505
6513
  this.bufferedSegmentsCount = 0;
6506
6514
  this.shouldAutoplayAfterBuffering = false;
6507
6515
  this.hasInitialBufferCompleted = false;
6516
+ this.latencyProfileApplied = false;
6508
6517
  this.config = config;
6509
6518
  this.video = video;
6510
6519
  this.cueManager = cueManager;
@@ -6573,24 +6582,21 @@ var HlsEngine = /*#__PURE__*/ function() {
6573
6582
  key: "setupHls",
6574
6583
  value: function setupHls() {
6575
6584
  var _this = this;
6576
- this.hls = new Hls2(_object_spread_props(_object_spread({
6585
+ this.hls = new Hls2({
6577
6586
  enableWorker: true,
6578
6587
  backBufferLength: 30,
6579
6588
  liveDurationInfinity: true,
6580
6589
  lowLatencyMode: !!this.config.lowLatencyMode,
6581
- maxLiveSyncPlaybackRate: this.config.lowLatencyMode ? 1.5 : 1
6582
- }, this.config.lowLatencyMode ? {
6583
- liveSyncDuration: 2
6584
- } : {}), {
6590
+ maxLiveSyncPlaybackRate: 1.1,
6585
6591
  maxBufferLength: 30,
6586
6592
  maxMaxBufferLength: 600,
6587
6593
  maxBufferSize: 60 * 1e3 * 1e3,
6588
- maxBufferHole: 0.5,
6594
+ maxBufferHole: 1,
6589
6595
  highBufferWatchdogPeriod: 2,
6590
- nudgeOffset: 0.1,
6591
- nudgeMaxRetry: 3,
6596
+ nudgeOffset: 0.2,
6597
+ nudgeMaxRetry: 5,
6592
6598
  startPosition: -1
6593
- }));
6599
+ });
6594
6600
  this.hls.on(Hls2.Events.MEDIA_ATTACHED, function() {
6595
6601
  var _this_hls;
6596
6602
  (_this_hls = _this.hls) === null || _this_hls === void 0 ? void 0 : _this_hls.loadSource(_this.config.src);
@@ -6614,6 +6620,8 @@ var HlsEngine = /*#__PURE__*/ function() {
6614
6620
  this.bufferedSegmentsCount = 0;
6615
6621
  this.hasInitialBufferCompleted = false;
6616
6622
  this.shouldAutoplayAfterBuffering = !!this.config.autoplay;
6623
+ this.latencyProfileApplied = false;
6624
+ this.detectedLowLatencyStream = void 0;
6617
6625
  minSegments = (_this_config_minSegmentsBeforePlay = this.config.minSegmentsBeforePlay) !== null && _this_config_minSegmentsBeforePlay !== void 0 ? _this_config_minSegmentsBeforePlay : 2;
6618
6626
  if (this.debug) {
6619
6627
  console.log("[StormcloudVideoPlayer] Waiting for", minSegments, "segments to buffer before playback");
@@ -6644,6 +6652,7 @@ var HlsEngine = /*#__PURE__*/ function() {
6644
6652
  }).call(_this);
6645
6653
  });
6646
6654
  this.hls.on(Hls2.Events.LEVEL_LOADED, function(_evt, data) {
6655
+ _this.applyStreamLatencyProfile(data === null || data === void 0 ? void 0 : data.details);
6647
6656
  if (_this.callbacks.isInAdBreak() || _this.callbacks.hasPendingAdBreak()) {
6648
6657
  return;
6649
6658
  }
@@ -6917,6 +6926,70 @@ var HlsEngine = /*#__PURE__*/ function() {
6917
6926
  this.hls.attachMedia(this.video);
6918
6927
  }
6919
6928
  },
6929
+ {
6930
+ key: "isLowLatencyStream",
6931
+ value: function isLowLatencyStream() {
6932
+ return this.detectedLowLatencyStream;
6933
+ }
6934
+ },
6935
+ {
6936
+ key: "applyStreamLatencyProfile",
6937
+ value: function applyStreamLatencyProfile(details) {
6938
+ if (this.latencyProfileApplied || !this.hls) {
6939
+ return;
6940
+ }
6941
+ if (!details) {
6942
+ return;
6943
+ }
6944
+ if (details.live !== true) {
6945
+ this.latencyProfileApplied = true;
6946
+ this.detectedLowLatencyStream = false;
6947
+ return;
6948
+ }
6949
+ var isLowLatencyManifest = this.isLowLatencyManifest(details);
6950
+ var useLowLatency = isLowLatencyManifest && !!this.config.lowLatencyMode;
6951
+ this.detectedLowLatencyStream = useLowLatency;
6952
+ this.latencyProfileApplied = true;
6953
+ var cfg = this.hls.config;
6954
+ if (useLowLatency) {
6955
+ cfg.maxLiveSyncPlaybackRate = 1.5;
6956
+ cfg.maxBufferHole = 0.5;
6957
+ delete cfg.liveSyncDuration;
6958
+ } else {
6959
+ cfg.maxLiveSyncPlaybackRate = 1.1;
6960
+ cfg.maxBufferHole = 1;
6961
+ delete cfg.liveSyncDuration;
6962
+ cfg.liveSyncDurationCount = 3;
6963
+ }
6964
+ if (this.debug) {
6965
+ var _details_targetduration;
6966
+ console.log("[StormcloudVideoPlayer] Live latency profile: ".concat(useLowLatency ? "LL-HLS (low latency)" : "standard live (stability)"), {
6967
+ isLowLatencyManifest: isLowLatencyManifest,
6968
+ lowLatencyModeRequested: !!this.config.lowLatencyMode,
6969
+ canBlockReload: details.canBlockReload,
6970
+ partTarget: details.partTarget,
6971
+ partHoldBack: details.partHoldBack,
6972
+ partListLength: Array.isArray(details.partList) ? details.partList.length : 0,
6973
+ targetDuration: (_details_targetduration = details.targetduration) !== null && _details_targetduration !== void 0 ? _details_targetduration : details.targetDuration,
6974
+ maxLiveSyncPlaybackRate: cfg.maxLiveSyncPlaybackRate,
6975
+ maxBufferHole: cfg.maxBufferHole
6976
+ });
6977
+ }
6978
+ }
6979
+ },
6980
+ {
6981
+ key: "isLowLatencyManifest",
6982
+ value: function isLowLatencyManifest(details) {
6983
+ if (!details) {
6984
+ return false;
6985
+ }
6986
+ var hasParts = Array.isArray(details.partList) && details.partList.length > 0;
6987
+ var hasPartTarget = typeof details.partTarget === "number" && details.partTarget > 0;
6988
+ var hasPartHoldBack = typeof details.partHoldBack === "number" && details.partHoldBack > 0;
6989
+ var canBlockReload = details.canBlockReload === true;
6990
+ return hasParts || hasPartTarget || hasPartHoldBack || canBlockReload;
6991
+ }
6992
+ },
6920
6993
  {
6921
6994
  key: "onId3Tag",
6922
6995
  value: function onId3Tag(tag) {
@@ -9404,6 +9477,12 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
9404
9477
  return this.hlsEngine.isLiveStream;
9405
9478
  }
9406
9479
  },
9480
+ {
9481
+ key: "isLowLatencyStream",
9482
+ value: function isLowLatencyStream() {
9483
+ return this.hlsEngine.isLowLatencyStream();
9484
+ }
9485
+ },
9407
9486
  {
9408
9487
  key: "videoElement",
9409
9488
  get: function get() {