stormcloud-video-player 0.3.67 → 0.3.68

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.
@@ -78,9 +78,13 @@ declare class StormcloudVideoPlayer {
78
78
  private preloadPoolLoopRunning;
79
79
  private adDetectSentForCurrentBreak;
80
80
  private preAdBreakAudio;
81
+ private detectedLowLatencyStream;
82
+ private latencyProfileApplied;
81
83
  constructor(config: StormcloudVideoPlayerConfig);
82
84
  private createAdPlayer;
83
85
  load(): Promise<void>;
86
+ private applyStreamLatencyProfile;
87
+ private isLowLatencyManifest;
84
88
  private attachImaEventListeners;
85
89
  private recreateImaController;
86
90
  private ensurePlaceholderContainer;
@@ -151,6 +155,7 @@ declare class StormcloudVideoPlayer {
151
155
  isShowingAds(): boolean;
152
156
  getStreamType(): "hls" | "other";
153
157
  shouldShowNativeControls(): boolean;
158
+ isLowLatencyStream(): boolean | undefined;
154
159
  private shouldContinueLiveStreamDuringAds;
155
160
  private startAdPrefetch;
156
161
  private clearPendingAdBreak;
@@ -1783,7 +1783,7 @@ function createHlsAdPlayer(contentVideo, options) {
1783
1783
  }
1784
1784
  var adElement = xmlDoc.querySelector("Ad");
1785
1785
  if (!adElement) {
1786
- console.warn("[HlsAdPlayer] No Ad element found in VAST XML");
1786
+ console.warn("[HlsAdPlayer] No Ad element found in VAST XML (no fill). Content (first 2000 chars):", xmlString.substring(0, 2e3));
1787
1787
  return null;
1788
1788
  }
1789
1789
  var adId = adElement.getAttribute("id") || "unknown";
@@ -1879,7 +1879,7 @@ function createHlsAdPlayer(contentVideo, options) {
1879
1879
  }
1880
1880
  function fetchAndParseVastAd(vastTagUrl) {
1881
1881
  return _async_to_generator(function() {
1882
- var response, vastXml;
1882
+ var response, vastXml, trimmedXml;
1883
1883
  return _ts_generator(this, function(_state) {
1884
1884
  switch(_state.label){
1885
1885
  case 0:
@@ -1905,8 +1905,16 @@ function createHlsAdPlayer(contentVideo, options) {
1905
1905
  ];
1906
1906
  case 2:
1907
1907
  vastXml = _state.sent();
1908
- console.log("[HlsAdPlayer] VAST XML received");
1908
+ console.log("[HlsAdPlayer] VAST XML received (length=".concat(vastXml.length, ")"));
1909
1909
  console.log("[HlsAdPlayer] VAST XML content (first 2000 chars):", vastXml.substring(0, 2e3));
1910
+ trimmedXml = vastXml.trim();
1911
+ if (trimmedXml.length === 0) {
1912
+ console.warn("[HlsAdPlayer] VAST response body is empty (no fill)");
1913
+ return [
1914
+ 2,
1915
+ null
1916
+ ];
1917
+ }
1910
1918
  return [
1911
1919
  2,
1912
1920
  parseVastXml(vastXml)
@@ -3346,6 +3354,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3346
3354
  this.preloadPoolActive = false;
3347
3355
  this.preloadPoolLoopRunning = false;
3348
3356
  this.adDetectSentForCurrentBreak = false;
3357
+ this.latencyProfileApplied = false;
3349
3358
  this.continuousFetchLoopRunning = false;
3350
3359
  initializePolyfills();
3351
3360
  var browserOverrides = getBrowserConfigOverrides();
@@ -3462,24 +3471,21 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3462
3471
  2
3463
3472
  ];
3464
3473
  case 7:
3465
- this.hls = new import_hls2.default(_object_spread_props(_object_spread({
3474
+ this.hls = new import_hls2.default({
3466
3475
  enableWorker: true,
3467
3476
  backBufferLength: 30,
3468
3477
  liveDurationInfinity: true,
3469
3478
  lowLatencyMode: !!this.config.lowLatencyMode,
3470
- maxLiveSyncPlaybackRate: this.config.lowLatencyMode ? 1.5 : 1
3471
- }, this.config.lowLatencyMode ? {
3472
- liveSyncDuration: 2
3473
- } : {}), {
3479
+ maxLiveSyncPlaybackRate: 1.1,
3474
3480
  maxBufferLength: 30,
3475
3481
  maxMaxBufferLength: 600,
3476
3482
  maxBufferSize: 60 * 1e3 * 1e3,
3477
- maxBufferHole: 0.5,
3483
+ maxBufferHole: 1,
3478
3484
  highBufferWatchdogPeriod: 2,
3479
- nudgeOffset: 0.1,
3480
- nudgeMaxRetry: 3,
3485
+ nudgeOffset: 0.2,
3486
+ nudgeMaxRetry: 5,
3481
3487
  startPosition: -1
3482
- }));
3488
+ });
3483
3489
  this.hls.on(import_hls2.default.Events.MEDIA_ATTACHED, function() {
3484
3490
  var _this_hls;
3485
3491
  (_this_hls = _this.hls) === null || _this_hls === void 0 ? void 0 : _this_hls.loadSource(_this.config.src);
@@ -3523,6 +3529,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3523
3529
  this.bufferedSegmentsCount = 0;
3524
3530
  this.hasInitialBufferCompleted = false;
3525
3531
  this.shouldAutoplayAfterBuffering = !!this.config.autoplay;
3532
+ this.latencyProfileApplied = false;
3533
+ this.detectedLowLatencyStream = void 0;
3526
3534
  minSegments = (_this_config_minSegmentsBeforePlay = this.config.minSegmentsBeforePlay) !== null && _this_config_minSegmentsBeforePlay !== void 0 ? _this_config_minSegmentsBeforePlay : 2;
3527
3535
  if (this.config.debugAdTiming) {
3528
3536
  console.log("[StormcloudVideoPlayer] Waiting for", minSegments, "segments to buffer before playback");
@@ -3552,6 +3560,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3552
3560
  }).call(_this);
3553
3561
  });
3554
3562
  this.hls.on(import_hls2.default.Events.LEVEL_LOADED, function(_evt, data) {
3563
+ _this.applyStreamLatencyProfile(data === null || data === void 0 ? void 0 : data.details);
3555
3564
  if (_this.inAdBreak || _this.pendingAdBreak) {
3556
3565
  return;
3557
3566
  }
@@ -3831,6 +3840,64 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3831
3840
  }).call(this);
3832
3841
  }
3833
3842
  },
3843
+ {
3844
+ key: "applyStreamLatencyProfile",
3845
+ value: function applyStreamLatencyProfile(details) {
3846
+ if (this.latencyProfileApplied || !this.hls) {
3847
+ return;
3848
+ }
3849
+ if (!details) {
3850
+ return;
3851
+ }
3852
+ if (details.live !== true) {
3853
+ this.latencyProfileApplied = true;
3854
+ this.detectedLowLatencyStream = false;
3855
+ return;
3856
+ }
3857
+ var isLowLatencyManifest = this.isLowLatencyManifest(details);
3858
+ var useLowLatency = isLowLatencyManifest && !!this.config.lowLatencyMode;
3859
+ this.detectedLowLatencyStream = useLowLatency;
3860
+ this.latencyProfileApplied = true;
3861
+ var cfg = this.hls.config;
3862
+ if (useLowLatency) {
3863
+ cfg.maxLiveSyncPlaybackRate = 1.5;
3864
+ cfg.maxBufferHole = 0.5;
3865
+ delete cfg.liveSyncDuration;
3866
+ } else {
3867
+ cfg.maxLiveSyncPlaybackRate = 1.1;
3868
+ cfg.maxBufferHole = 1;
3869
+ delete cfg.liveSyncDuration;
3870
+ cfg.liveSyncDurationCount = 3;
3871
+ }
3872
+ if (this.config.debugAdTiming) {
3873
+ var _details_targetduration;
3874
+ console.log("[StormcloudVideoPlayer] Live latency profile: ".concat(useLowLatency ? "LL-HLS (low latency)" : "standard live (stability)"), {
3875
+ isLowLatencyManifest: isLowLatencyManifest,
3876
+ lowLatencyModeRequested: !!this.config.lowLatencyMode,
3877
+ canBlockReload: details.canBlockReload,
3878
+ partTarget: details.partTarget,
3879
+ partHoldBack: details.partHoldBack,
3880
+ partListLength: Array.isArray(details.partList) ? details.partList.length : 0,
3881
+ targetDuration: (_details_targetduration = details.targetduration) !== null && _details_targetduration !== void 0 ? _details_targetduration : details.targetDuration,
3882
+ maxLiveSyncPlaybackRate: cfg.maxLiveSyncPlaybackRate,
3883
+ maxBufferHole: cfg.maxBufferHole
3884
+ });
3885
+ }
3886
+ }
3887
+ },
3888
+ {
3889
+ key: "isLowLatencyManifest",
3890
+ value: function isLowLatencyManifest(details) {
3891
+ if (!details) {
3892
+ return false;
3893
+ }
3894
+ var hasParts = Array.isArray(details.partList) && details.partList.length > 0;
3895
+ var hasPartTarget = typeof details.partTarget === "number" && details.partTarget > 0;
3896
+ var hasPartHoldBack = typeof details.partHoldBack === "number" && details.partHoldBack > 0;
3897
+ var canBlockReload = details.canBlockReload === true;
3898
+ return hasParts || hasPartTarget || hasPartHoldBack || canBlockReload;
3899
+ }
3900
+ },
3834
3901
  {
3835
3902
  key: "attachImaEventListeners",
3836
3903
  value: function attachImaEventListeners() {
@@ -5819,6 +5886,12 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5819
5886
  return !!(this.config.allowNativeHls && !((_this_config_showCustomControls = this.config.showCustomControls) !== null && _this_config_showCustomControls !== void 0 ? _this_config_showCustomControls : false));
5820
5887
  }
5821
5888
  },
5889
+ {
5890
+ key: "isLowLatencyStream",
5891
+ value: function isLowLatencyStream() {
5892
+ return this.detectedLowLatencyStream;
5893
+ }
5894
+ },
5822
5895
  {
5823
5896
  key: "shouldContinueLiveStreamDuringAds",
5824
5897
  value: function shouldContinueLiveStreamDuringAds() {