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.
@@ -979,6 +979,7 @@ function createVastAdLayer(contentVideo, options) {
979
979
  var destroyed = false;
980
980
  var tornDown = false;
981
981
  var trackingFired = createEmptyTrackingState();
982
+ var adStallTimerId;
982
983
  var currentAdEventHandlers;
983
984
  var preloadSlots = /* @__PURE__ */ new Map();
984
985
  function emit(event, payload) {
@@ -1094,7 +1095,14 @@ function createVastAdLayer(contentVideo, options) {
1094
1095
  video.volume = 1;
1095
1096
  return video;
1096
1097
  }
1098
+ function clearAdStallTimer() {
1099
+ if (adStallTimerId != null) {
1100
+ clearTimeout(adStallTimerId);
1101
+ adStallTimerId = void 0;
1102
+ }
1103
+ }
1097
1104
  function removeAdEventListeners() {
1105
+ clearAdStallTimer();
1098
1106
  if (!currentAdEventHandlers || !adVideoElement) return;
1099
1107
  var el = adVideoElement;
1100
1108
  el.removeEventListener("timeupdate", currentAdEventHandlers.timeupdate);
@@ -1104,6 +1112,7 @@ function createVastAdLayer(contentVideo, options) {
1104
1112
  el.removeEventListener("volumechange", currentAdEventHandlers.volumechange);
1105
1113
  el.removeEventListener("pause", currentAdEventHandlers.pause);
1106
1114
  el.removeEventListener("play", currentAdEventHandlers.play);
1115
+ el.removeEventListener("waiting", currentAdEventHandlers.waiting);
1107
1116
  currentAdEventHandlers = void 0;
1108
1117
  }
1109
1118
  function setupAdEventListeners() {
@@ -1128,6 +1137,7 @@ function createVastAdLayer(contentVideo, options) {
1128
1137
  }
1129
1138
  },
1130
1139
  playing: function playing() {
1140
+ clearAdStallTimer();
1131
1141
  var ad = currentAd;
1132
1142
  if (!ad || trackingFired.start) return;
1133
1143
  trackingFired.start = true;
@@ -1164,6 +1174,16 @@ function createVastAdLayer(contentVideo, options) {
1164
1174
  if (currentAd && adVideoElement && adVideoElement.currentTime > 0) {
1165
1175
  fireTrackingPixels2(currentAd.trackingUrls.resume);
1166
1176
  }
1177
+ },
1178
+ waiting: function waiting() {
1179
+ clearAdStallTimer();
1180
+ adStallTimerId = setTimeout(function() {
1181
+ adStallTimerId = void 0;
1182
+ if (adPlaying) {
1183
+ if (debug) console.warn("".concat(LOG, " Ad video stalled for too long, treating as error"));
1184
+ handleAdError();
1185
+ }
1186
+ }, 8e3);
1167
1187
  }
1168
1188
  };
1169
1189
  adVideoElement.addEventListener("timeupdate", handlers.timeupdate);
@@ -1173,6 +1193,7 @@ function createVastAdLayer(contentVideo, options) {
1173
1193
  adVideoElement.addEventListener("volumechange", handlers.volumechange);
1174
1194
  adVideoElement.addEventListener("pause", handlers.pause);
1175
1195
  adVideoElement.addEventListener("play", handlers.play);
1196
+ adVideoElement.addEventListener("waiting", handlers.waiting);
1176
1197
  currentAdEventHandlers = handlers;
1177
1198
  }
1178
1199
  function setAdPlayingFlag(isPlaying) {
@@ -1184,6 +1205,7 @@ function createVastAdLayer(contentVideo, options) {
1184
1205
  }
1185
1206
  function handleAdComplete() {
1186
1207
  if (tornDown) return;
1208
+ clearAdStallTimer();
1187
1209
  if (debug) console.log("".concat(LOG, " Handling ad completion"));
1188
1210
  adPlaying = false;
1189
1211
  setAdPlayingFlag(false);
@@ -1197,6 +1219,7 @@ function createVastAdLayer(contentVideo, options) {
1197
1219
  function handleAdError() {
1198
1220
  if (tornDown) return;
1199
1221
  if (!adPlaying) return;
1222
+ clearAdStallTimer();
1200
1223
  if (debug) console.log("".concat(LOG, " Handling ad error"));
1201
1224
  adPlaying = false;
1202
1225
  setAdPlayingFlag(false);
@@ -1247,6 +1270,7 @@ function createVastAdLayer(contentVideo, options) {
1247
1270
  adHls.loadSource(mediaFile.url);
1248
1271
  adHls.attachMedia(adVideoElement);
1249
1272
  adHls.on(import_hls.default.Events.MANIFEST_PARSED, function() {
1273
+ if (!adPlaying) return;
1250
1274
  adVideoElement.play().catch(function(error) {
1251
1275
  console.error("".concat(LOG, " Error starting HLS ad playback:"), error);
1252
1276
  handleAdError();
@@ -1880,6 +1904,7 @@ function createVastAdLayer(contentVideo, options) {
1880
1904
  return 1;
1881
1905
  },
1882
1906
  showPlaceholder: function showPlaceholder() {
1907
+ if (singleElementMode) return;
1883
1908
  contentVideo.style.opacity = "0";
1884
1909
  contentVideo.style.visibility = "hidden";
1885
1910
  if (!adContainerEl) {
@@ -3576,7 +3601,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3576
3601
  }
3577
3602
  _this.adLayer.cancelPreload(token);
3578
3603
  } else {
3579
- _this.showPlaceholderLayer();
3604
+ if (!_this.config.singlePipelineMode) {
3605
+ _this.showPlaceholderLayer();
3606
+ }
3580
3607
  _this.adLayer.showPlaceholder();
3581
3608
  _this.isInAdTransition = true;
3582
3609
  setTimeout(function() {
@@ -3600,7 +3627,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3600
3627
  console.log("[StormcloudVideoPlayer] content_resume: skip pending bids, only", remainingNow1, "ms left");
3601
3628
  }
3602
3629
  } else {
3603
- _this.showPlaceholderLayer();
3630
+ if (!_this.config.singlePipelineMode) {
3631
+ _this.showPlaceholderLayer();
3632
+ }
3604
3633
  _this.adLayer.showPlaceholder();
3605
3634
  _this.isInAdTransition = true;
3606
3635
  setTimeout(function() {
@@ -4968,7 +4997,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4968
4997
  if (!this.config.disableFiller) this.showAds = true;
4969
4998
  if (adBreakDurationMs != null) {
4970
4999
  this.startFillerBreakTimer(adBreakDurationMs);
4971
- } else if (!this.config.disableFiller) {
5000
+ } else if (!this.config.disableFiller && this.preloadedTokens.length === 0) {
4972
5001
  this.showPlaceholderLayer();
4973
5002
  }
4974
5003
  if (!this.config.disableFiller) this.adLayer.showPlaceholder();