stormcloud-video-player 0.6.3 → 0.6.4

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.
@@ -618,6 +618,7 @@ function createVastAdLayer(contentVideo, options) {
618
618
  var destroyed = false;
619
619
  var tornDown = false;
620
620
  var trackingFired = createEmptyTrackingState();
621
+ var adStallTimerId;
621
622
  var currentAdEventHandlers;
622
623
  var preloadSlots = /* @__PURE__ */ new Map();
623
624
  function emit(event, payload) {
@@ -733,7 +734,14 @@ function createVastAdLayer(contentVideo, options) {
733
734
  video.volume = 1;
734
735
  return video;
735
736
  }
737
+ function clearAdStallTimer() {
738
+ if (adStallTimerId != null) {
739
+ clearTimeout(adStallTimerId);
740
+ adStallTimerId = void 0;
741
+ }
742
+ }
736
743
  function removeAdEventListeners() {
744
+ clearAdStallTimer();
737
745
  if (!currentAdEventHandlers || !adVideoElement) return;
738
746
  var el = adVideoElement;
739
747
  el.removeEventListener("timeupdate", currentAdEventHandlers.timeupdate);
@@ -743,6 +751,7 @@ function createVastAdLayer(contentVideo, options) {
743
751
  el.removeEventListener("volumechange", currentAdEventHandlers.volumechange);
744
752
  el.removeEventListener("pause", currentAdEventHandlers.pause);
745
753
  el.removeEventListener("play", currentAdEventHandlers.play);
754
+ el.removeEventListener("waiting", currentAdEventHandlers.waiting);
746
755
  currentAdEventHandlers = void 0;
747
756
  }
748
757
  function setupAdEventListeners() {
@@ -767,6 +776,7 @@ function createVastAdLayer(contentVideo, options) {
767
776
  }
768
777
  },
769
778
  playing: function playing() {
779
+ clearAdStallTimer();
770
780
  var ad = currentAd;
771
781
  if (!ad || trackingFired.start) return;
772
782
  trackingFired.start = true;
@@ -803,6 +813,16 @@ function createVastAdLayer(contentVideo, options) {
803
813
  if (currentAd && adVideoElement && adVideoElement.currentTime > 0) {
804
814
  fireTrackingPixels2(currentAd.trackingUrls.resume);
805
815
  }
816
+ },
817
+ waiting: function waiting() {
818
+ clearAdStallTimer();
819
+ adStallTimerId = setTimeout(function() {
820
+ adStallTimerId = void 0;
821
+ if (adPlaying) {
822
+ if (debug) console.warn("".concat(LOG, " Ad video stalled for too long, treating as error"));
823
+ handleAdError();
824
+ }
825
+ }, 8e3);
806
826
  }
807
827
  };
808
828
  adVideoElement.addEventListener("timeupdate", handlers.timeupdate);
@@ -812,6 +832,7 @@ function createVastAdLayer(contentVideo, options) {
812
832
  adVideoElement.addEventListener("volumechange", handlers.volumechange);
813
833
  adVideoElement.addEventListener("pause", handlers.pause);
814
834
  adVideoElement.addEventListener("play", handlers.play);
835
+ adVideoElement.addEventListener("waiting", handlers.waiting);
815
836
  currentAdEventHandlers = handlers;
816
837
  }
817
838
  function setAdPlayingFlag(isPlaying) {
@@ -823,6 +844,7 @@ function createVastAdLayer(contentVideo, options) {
823
844
  }
824
845
  function handleAdComplete() {
825
846
  if (tornDown) return;
847
+ clearAdStallTimer();
826
848
  if (debug) console.log("".concat(LOG, " Handling ad completion"));
827
849
  adPlaying = false;
828
850
  setAdPlayingFlag(false);
@@ -836,6 +858,7 @@ function createVastAdLayer(contentVideo, options) {
836
858
  function handleAdError() {
837
859
  if (tornDown) return;
838
860
  if (!adPlaying) return;
861
+ clearAdStallTimer();
839
862
  if (debug) console.log("".concat(LOG, " Handling ad error"));
840
863
  adPlaying = false;
841
864
  setAdPlayingFlag(false);
@@ -886,6 +909,7 @@ function createVastAdLayer(contentVideo, options) {
886
909
  adHls.loadSource(mediaFile.url);
887
910
  adHls.attachMedia(adVideoElement);
888
911
  adHls.on(import_hls.default.Events.MANIFEST_PARSED, function() {
912
+ if (!adPlaying) return;
889
913
  adVideoElement.play().catch(function(error) {
890
914
  console.error("".concat(LOG, " Error starting HLS ad playback:"), error);
891
915
  handleAdError();
@@ -1519,6 +1543,7 @@ function createVastAdLayer(contentVideo, options) {
1519
1543
  return 1;
1520
1544
  },
1521
1545
  showPlaceholder: function showPlaceholder() {
1546
+ if (singleElementMode) return;
1522
1547
  contentVideo.style.opacity = "0";
1523
1548
  contentVideo.style.visibility = "hidden";
1524
1549
  if (!adContainerEl) {