stormcloud-video-player 0.2.15 → 0.2.16

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.
@@ -1736,6 +1736,8 @@ var StormcloudVideoPlayer = class {
1736
1736
  this.totalAdsInBreak = 0;
1737
1737
  this.showAds = false;
1738
1738
  this.isLiveStream = false;
1739
+ this.nativeHlsMode = false;
1740
+ this.videoSrcProtection = null;
1739
1741
  initializePolyfills();
1740
1742
  const browserOverrides = getBrowserConfigOverrides();
1741
1743
  this.config = { ...config, ...browserOverrides };
@@ -1756,7 +1758,9 @@ var StormcloudVideoPlayer = class {
1756
1758
  }
1757
1759
  if (adPlayerType === "hls") {
1758
1760
  if (this.config.debugAdTiming) {
1759
- console.log("[StormcloudVideoPlayer] Creating HLS ad player (AdStorm mode)");
1761
+ console.log(
1762
+ "[StormcloudVideoPlayer] Creating HLS ad player (AdStorm mode)"
1763
+ );
1760
1764
  }
1761
1765
  return createHlsAdPlayer(this.video, {
1762
1766
  continueLiveStreamDuringAds,
@@ -1765,7 +1769,9 @@ var StormcloudVideoPlayer = class {
1765
1769
  });
1766
1770
  } else {
1767
1771
  if (this.config.debugAdTiming) {
1768
- console.log("[StormcloudVideoPlayer] Creating Google IMA ad player (Default mode)");
1772
+ console.log(
1773
+ "[StormcloudVideoPlayer] Creating Google IMA ad player (Default mode)"
1774
+ );
1769
1775
  }
1770
1776
  return createImaController(this.video, {
1771
1777
  continueLiveStreamDuringAds
@@ -1789,11 +1795,13 @@ var StormcloudVideoPlayer = class {
1789
1795
  }
1790
1796
  this.initializeTracking();
1791
1797
  if (this.shouldUseNativeHls()) {
1798
+ this.nativeHlsMode = true;
1799
+ this.videoSrcProtection = this.config.src;
1792
1800
  this.video.src = this.config.src;
1793
1801
  this.isLiveStream = (_a = this.config.lowLatencyMode) != null ? _a : false;
1794
1802
  if (this.config.debugAdTiming) {
1795
1803
  console.log(
1796
- "[StormcloudVideoPlayer] allowNativeHls: true - VOD mode detected:",
1804
+ "[StormcloudVideoPlayer] Using native HLS playback - VOD mode:",
1797
1805
  {
1798
1806
  isLive: this.isLiveStream,
1799
1807
  allowNativeHls: this.config.allowNativeHls,
@@ -1941,7 +1949,9 @@ var StormcloudVideoPlayer = class {
1941
1949
  this.ima.initialize();
1942
1950
  this.ima.on("all_ads_completed", () => {
1943
1951
  if (this.config.debugAdTiming) {
1944
- console.log("[StormcloudVideoPlayer] IMA all_ads_completed event received");
1952
+ console.log(
1953
+ "[StormcloudVideoPlayer] IMA all_ads_completed event received"
1954
+ );
1945
1955
  }
1946
1956
  });
1947
1957
  this.ima.on("ad_error", () => {
@@ -2006,13 +2016,31 @@ var StormcloudVideoPlayer = class {
2006
2016
  this.video.addEventListener("timeupdate", () => {
2007
2017
  this.onTimeUpdate(this.video.currentTime);
2008
2018
  });
2019
+ this.video.addEventListener("emptied", () => {
2020
+ if (this.nativeHlsMode && this.videoSrcProtection && !this.ima.isAdPlaying()) {
2021
+ if (this.config.debugAdTiming) {
2022
+ console.log(
2023
+ "[StormcloudVideoPlayer] Video src was cleared, restoring:",
2024
+ this.videoSrcProtection
2025
+ );
2026
+ }
2027
+ const currentTime = this.video.currentTime;
2028
+ const wasPaused = this.video.paused;
2029
+ this.video.src = this.videoSrcProtection;
2030
+ this.video.currentTime = currentTime;
2031
+ if (!wasPaused) {
2032
+ this.video.play().catch(() => {
2033
+ });
2034
+ }
2035
+ }
2036
+ });
2009
2037
  }
2010
2038
  shouldUseNativeHls() {
2011
2039
  const streamType = this.getStreamType();
2012
2040
  if (streamType === "other") {
2013
2041
  return true;
2014
2042
  }
2015
- const canNative = this.video.canPlayType("application/vnd.apple.mpegURL");
2043
+ const canNative = this.video.canPlayType("application/vnd.apple.mpegurl");
2016
2044
  return !!(this.config.allowNativeHls && canNative);
2017
2045
  }
2018
2046
  onId3Tag(tag) {
@@ -2439,10 +2467,7 @@ var StormcloudVideoPlayer = class {
2439
2467
  var _a, _b, _c;
2440
2468
  const vastMode = this.config.vastMode || "default";
2441
2469
  if (this.config.debugAdTiming) {
2442
- console.log(
2443
- "[StormcloudVideoPlayer] VAST mode:",
2444
- vastMode
2445
- );
2470
+ console.log("[StormcloudVideoPlayer] VAST mode:", vastMode);
2446
2471
  }
2447
2472
  if (vastMode === "adstorm") {
2448
2473
  if (!this.config.licenseKey) {
@@ -2560,10 +2585,7 @@ var StormcloudVideoPlayer = class {
2560
2585
  this.currentAdIndex = 0;
2561
2586
  this.totalAdsInBreak = 1;
2562
2587
  if (this.config.debugAdTiming) {
2563
- console.log(
2564
- "[StormcloudVideoPlayer] Using VAST endpoint:",
2565
- vastTagUrl
2566
- );
2588
+ console.log("[StormcloudVideoPlayer] Using VAST endpoint:", vastTagUrl);
2567
2589
  }
2568
2590
  } else if (tags && tags.length > 0) {
2569
2591
  vastTagUrl = tags[0];
@@ -2715,15 +2737,21 @@ var StormcloudVideoPlayer = class {
2715
2737
  await this.ima.requestAds(vastTagUrl);
2716
2738
  try {
2717
2739
  if (this.config.debugAdTiming) {
2718
- console.log("[StormcloudVideoPlayer] Ad request completed, attempting playback");
2740
+ console.log(
2741
+ "[StormcloudVideoPlayer] Ad request completed, attempting playback"
2742
+ );
2719
2743
  }
2720
2744
  await this.ima.play();
2721
2745
  if (this.config.debugAdTiming) {
2722
- console.log("[StormcloudVideoPlayer] Ad playback started successfully");
2746
+ console.log(
2747
+ "[StormcloudVideoPlayer] Ad playback started successfully"
2748
+ );
2723
2749
  }
2724
2750
  } catch (playError) {
2725
2751
  if (this.config.debugAdTiming) {
2726
- console.log("[StormcloudVideoPlayer] No ads available, skipping playback");
2752
+ console.log(
2753
+ "[StormcloudVideoPlayer] No ads available, skipping playback"
2754
+ );
2727
2755
  }
2728
2756
  this.handleAdFailure();
2729
2757
  return;
@@ -2779,7 +2807,9 @@ var StormcloudVideoPlayer = class {
2779
2807
  });
2780
2808
  } else {
2781
2809
  if (this.config.debugAdTiming) {
2782
- console.log("[StormcloudVideoPlayer] Video is already playing, no resume needed");
2810
+ console.log(
2811
+ "[StormcloudVideoPlayer] Video is already playing, no resume needed"
2812
+ );
2783
2813
  }
2784
2814
  }
2785
2815
  }
@@ -2798,7 +2828,11 @@ var StormcloudVideoPlayer = class {
2798
2828
  if (this.config.debugAdTiming) {
2799
2829
  console.warn(
2800
2830
  "[StormcloudVideoPlayer] Failsafe timer triggered - forcing video resume",
2801
- { paused: this.video.paused, showAds: this.showAds, adPlaying: this.ima.isAdPlaying() }
2831
+ {
2832
+ paused: this.video.paused,
2833
+ showAds: this.showAds,
2834
+ adPlaying: this.ima.isAdPlaying()
2835
+ }
2802
2836
  );
2803
2837
  }
2804
2838
  this.handleAdFailure();