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.
package/lib/index.js CHANGED
@@ -963,6 +963,7 @@ function createVastAdLayer(contentVideo, options) {
963
963
  var destroyed = false;
964
964
  var tornDown = false;
965
965
  var trackingFired = createEmptyTrackingState();
966
+ var adStallTimerId;
966
967
  var currentAdEventHandlers;
967
968
  var preloadSlots = /* @__PURE__ */ new Map();
968
969
  function emit(event, payload) {
@@ -1078,7 +1079,14 @@ function createVastAdLayer(contentVideo, options) {
1078
1079
  video.volume = 1;
1079
1080
  return video;
1080
1081
  }
1082
+ function clearAdStallTimer() {
1083
+ if (adStallTimerId != null) {
1084
+ clearTimeout(adStallTimerId);
1085
+ adStallTimerId = void 0;
1086
+ }
1087
+ }
1081
1088
  function removeAdEventListeners() {
1089
+ clearAdStallTimer();
1082
1090
  if (!currentAdEventHandlers || !adVideoElement) return;
1083
1091
  var el = adVideoElement;
1084
1092
  el.removeEventListener("timeupdate", currentAdEventHandlers.timeupdate);
@@ -1088,6 +1096,7 @@ function createVastAdLayer(contentVideo, options) {
1088
1096
  el.removeEventListener("volumechange", currentAdEventHandlers.volumechange);
1089
1097
  el.removeEventListener("pause", currentAdEventHandlers.pause);
1090
1098
  el.removeEventListener("play", currentAdEventHandlers.play);
1099
+ el.removeEventListener("waiting", currentAdEventHandlers.waiting);
1091
1100
  currentAdEventHandlers = void 0;
1092
1101
  }
1093
1102
  function setupAdEventListeners() {
@@ -1112,6 +1121,7 @@ function createVastAdLayer(contentVideo, options) {
1112
1121
  }
1113
1122
  },
1114
1123
  playing: function playing() {
1124
+ clearAdStallTimer();
1115
1125
  var ad = currentAd;
1116
1126
  if (!ad || trackingFired.start) return;
1117
1127
  trackingFired.start = true;
@@ -1148,6 +1158,16 @@ function createVastAdLayer(contentVideo, options) {
1148
1158
  if (currentAd && adVideoElement && adVideoElement.currentTime > 0) {
1149
1159
  fireTrackingPixels2(currentAd.trackingUrls.resume);
1150
1160
  }
1161
+ },
1162
+ waiting: function waiting() {
1163
+ clearAdStallTimer();
1164
+ adStallTimerId = setTimeout(function() {
1165
+ adStallTimerId = void 0;
1166
+ if (adPlaying) {
1167
+ if (debug) console.warn("".concat(LOG, " Ad video stalled for too long, treating as error"));
1168
+ handleAdError();
1169
+ }
1170
+ }, 8e3);
1151
1171
  }
1152
1172
  };
1153
1173
  adVideoElement.addEventListener("timeupdate", handlers.timeupdate);
@@ -1157,6 +1177,7 @@ function createVastAdLayer(contentVideo, options) {
1157
1177
  adVideoElement.addEventListener("volumechange", handlers.volumechange);
1158
1178
  adVideoElement.addEventListener("pause", handlers.pause);
1159
1179
  adVideoElement.addEventListener("play", handlers.play);
1180
+ adVideoElement.addEventListener("waiting", handlers.waiting);
1160
1181
  currentAdEventHandlers = handlers;
1161
1182
  }
1162
1183
  function setAdPlayingFlag(isPlaying) {
@@ -1168,6 +1189,7 @@ function createVastAdLayer(contentVideo, options) {
1168
1189
  }
1169
1190
  function handleAdComplete() {
1170
1191
  if (tornDown) return;
1192
+ clearAdStallTimer();
1171
1193
  if (debug) console.log("".concat(LOG, " Handling ad completion"));
1172
1194
  adPlaying = false;
1173
1195
  setAdPlayingFlag(false);
@@ -1181,6 +1203,7 @@ function createVastAdLayer(contentVideo, options) {
1181
1203
  function handleAdError() {
1182
1204
  if (tornDown) return;
1183
1205
  if (!adPlaying) return;
1206
+ clearAdStallTimer();
1184
1207
  if (debug) console.log("".concat(LOG, " Handling ad error"));
1185
1208
  adPlaying = false;
1186
1209
  setAdPlayingFlag(false);
@@ -1231,6 +1254,7 @@ function createVastAdLayer(contentVideo, options) {
1231
1254
  adHls.loadSource(mediaFile.url);
1232
1255
  adHls.attachMedia(adVideoElement);
1233
1256
  adHls.on(Hls.Events.MANIFEST_PARSED, function() {
1257
+ if (!adPlaying) return;
1234
1258
  adVideoElement.play().catch(function(error) {
1235
1259
  console.error("".concat(LOG, " Error starting HLS ad playback:"), error);
1236
1260
  handleAdError();
@@ -1864,6 +1888,7 @@ function createVastAdLayer(contentVideo, options) {
1864
1888
  return 1;
1865
1889
  },
1866
1890
  showPlaceholder: function showPlaceholder() {
1891
+ if (singleElementMode) return;
1867
1892
  contentVideo.style.opacity = "0";
1868
1893
  contentVideo.style.visibility = "hidden";
1869
1894
  if (!adContainerEl) {
@@ -3588,7 +3613,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3588
3613
  }
3589
3614
  _this.adLayer.cancelPreload(token);
3590
3615
  } else {
3591
- _this.showPlaceholderLayer();
3616
+ if (!_this.config.singlePipelineMode) {
3617
+ _this.showPlaceholderLayer();
3618
+ }
3592
3619
  _this.adLayer.showPlaceholder();
3593
3620
  _this.isInAdTransition = true;
3594
3621
  setTimeout(function() {
@@ -3612,7 +3639,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3612
3639
  console.log("[StormcloudVideoPlayer] content_resume: skip pending bids, only", remainingNow1, "ms left");
3613
3640
  }
3614
3641
  } else {
3615
- _this.showPlaceholderLayer();
3642
+ if (!_this.config.singlePipelineMode) {
3643
+ _this.showPlaceholderLayer();
3644
+ }
3616
3645
  _this.adLayer.showPlaceholder();
3617
3646
  _this.isInAdTransition = true;
3618
3647
  setTimeout(function() {
@@ -4980,7 +5009,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4980
5009
  if (!this.config.disableFiller) this.showAds = true;
4981
5010
  if (adBreakDurationMs != null) {
4982
5011
  this.startFillerBreakTimer(adBreakDurationMs);
4983
- } else if (!this.config.disableFiller) {
5012
+ } else if (!this.config.disableFiller && this.preloadedTokens.length === 0) {
4984
5013
  this.showPlaceholderLayer();
4985
5014
  }
4986
5015
  if (!this.config.disableFiller) this.adLayer.showPlaceholder();