stormcloud-video-player 0.3.17 → 0.3.18

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.d.cts CHANGED
@@ -151,6 +151,13 @@ declare class StormcloudVideoPlayer {
151
151
  private isShowingPlaceholder;
152
152
  private timeUpdateHandler?;
153
153
  private emptiedHandler?;
154
+ private consecutiveEmptyResponses;
155
+ private totalAdRequestsInBreak;
156
+ private lastEmptyResponseTimeMs;
157
+ private readonly maxTotalAdRequestsPerBreak;
158
+ private readonly maxConsecutiveEmptyResponses;
159
+ private readonly baseEmptyResponseDelayMs;
160
+ private readonly maxEmptyResponseDelayMs;
154
161
  constructor(config: StormcloudVideoPlayerConfig);
155
162
  private createAdPlayer;
156
163
  load(): Promise<void>;
package/lib/index.d.ts CHANGED
@@ -151,6 +151,13 @@ declare class StormcloudVideoPlayer {
151
151
  private isShowingPlaceholder;
152
152
  private timeUpdateHandler?;
153
153
  private emptiedHandler?;
154
+ private consecutiveEmptyResponses;
155
+ private totalAdRequestsInBreak;
156
+ private lastEmptyResponseTimeMs;
157
+ private readonly maxTotalAdRequestsPerBreak;
158
+ private readonly maxConsecutiveEmptyResponses;
159
+ private readonly baseEmptyResponseDelayMs;
160
+ private readonly maxEmptyResponseDelayMs;
154
161
  constructor(config: StormcloudVideoPlayerConfig);
155
162
  private createAdPlayer;
156
163
  load(): Promise<void>;
package/lib/index.js CHANGED
@@ -335,6 +335,20 @@ function _ts_generator(thisArg, body) {
335
335
  };
336
336
  }
337
337
  }
338
+ function _ts_values(o) {
339
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
340
+ if (m) return m.call(o);
341
+ if (o && typeof o.length === "number") return {
342
+ next: function() {
343
+ if (o && i >= o.length) o = void 0;
344
+ return {
345
+ value: o && o[i++],
346
+ done: !o
347
+ };
348
+ }
349
+ };
350
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
351
+ }
338
352
  // src/ui/StormcloudVideoPlayer.tsx
339
353
  import React, { useEffect, useRef, useMemo } from "react";
340
354
  // src/player/StormcloudVideoPlayer.ts
@@ -1289,6 +1303,7 @@ function createImaController(video, options) {
1289
1303
  },
1290
1304
  showPlaceholder: function showPlaceholder() {
1291
1305
  ensurePlaceholderContainer();
1306
+ hideContentVideo();
1292
1307
  if (adContainerEl) {
1293
1308
  adContainerEl.style.display = "flex";
1294
1309
  adContainerEl.style.backgroundColor = "#000";
@@ -1308,6 +1323,9 @@ function createImaController(video, options) {
1308
1323
  }
1309
1324
  }, 300);
1310
1325
  }
1326
+ if (!adPlaying) {
1327
+ showContentVideo();
1328
+ }
1311
1329
  }
1312
1330
  };
1313
1331
  }
@@ -2082,6 +2100,8 @@ function createHlsAdPlayer(contentVideo, options) {
2082
2100
  return 1;
2083
2101
  },
2084
2102
  showPlaceholder: function showPlaceholder() {
2103
+ contentVideo.style.opacity = "0";
2104
+ contentVideo.style.visibility = "hidden";
2085
2105
  if (!adContainerEl) {
2086
2106
  var _contentVideo_parentElement;
2087
2107
  var container = document.createElement("div");
@@ -2109,6 +2129,10 @@ function createHlsAdPlayer(contentVideo, options) {
2109
2129
  adContainerEl.style.display = "none";
2110
2130
  adContainerEl.style.pointerEvents = "none";
2111
2131
  }
2132
+ if (!adPlaying) {
2133
+ contentVideo.style.visibility = "visible";
2134
+ contentVideo.style.opacity = "1";
2135
+ }
2112
2136
  }
2113
2137
  };
2114
2138
  }
@@ -2766,6 +2790,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
2766
2790
  this.maxPlaceholderDurationMs = 5e3;
2767
2791
  this.placeholderStartTimeMs = null;
2768
2792
  this.isShowingPlaceholder = false;
2793
+ this.consecutiveEmptyResponses = 0;
2794
+ this.totalAdRequestsInBreak = 0;
2795
+ this.lastEmptyResponseTimeMs = 0;
2796
+ this.maxTotalAdRequestsPerBreak = 20;
2797
+ this.maxConsecutiveEmptyResponses = 5;
2798
+ this.baseEmptyResponseDelayMs = 2e3;
2799
+ this.maxEmptyResponseDelayMs = 3e4;
2769
2800
  initializePolyfills();
2770
2801
  var browserOverrides = getBrowserConfigOverrides();
2771
2802
  this.config = _object_spread({}, config, browserOverrides);
@@ -2955,6 +2986,87 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
2955
2986
  });
2956
2987
  }).call(_this);
2957
2988
  });
2989
+ this.hls.on(Hls2.Events.LEVEL_LOADED, function(_evt, data) {
2990
+ if (_this.inAdBreak) {
2991
+ return;
2992
+ }
2993
+ var details = data === null || data === void 0 ? void 0 : data.details;
2994
+ if (!details || !details.fragments || details.fragments.length === 0) {
2995
+ return;
2996
+ }
2997
+ var fragmentsToScan = Math.min(5, details.fragments.length);
2998
+ for(var i = 0; i < fragmentsToScan; i++){
2999
+ var frag = details.fragments[i];
3000
+ var tagList = frag === null || frag === void 0 ? void 0 : frag.tagList;
3001
+ if (!Array.isArray(tagList)) continue;
3002
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
3003
+ try {
3004
+ for(var _iterator = tagList[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
3005
+ var entry = _step.value;
3006
+ var tag = "";
3007
+ var value = "";
3008
+ if (Array.isArray(entry)) {
3009
+ var _entry_;
3010
+ tag = String((_entry_ = entry[0]) !== null && _entry_ !== void 0 ? _entry_ : "");
3011
+ var _entry_1;
3012
+ value = String((_entry_1 = entry[1]) !== null && _entry_1 !== void 0 ? _entry_1 : "");
3013
+ } else if (typeof entry === "string") {
3014
+ var idx = entry.indexOf(":");
3015
+ if (idx >= 0) {
3016
+ tag = entry.substring(0, idx);
3017
+ value = entry.substring(idx + 1);
3018
+ } else {
3019
+ tag = entry;
3020
+ }
3021
+ }
3022
+ if (!tag) continue;
3023
+ if (tag.includes("EXT-X-CUE-OUT") || tag.includes("EXT-X-DATERANGE")) {
3024
+ var attrs = tag.includes("EXT-X-DATERANGE") ? _this.parseAttributeList(value) : {};
3025
+ var hasScteOut = tag.includes("EXT-X-CUE-OUT") || "SCTE35-OUT" in attrs || attrs["SCTE35-OUT"] !== void 0;
3026
+ if (hasScteOut) {
3027
+ if (_this.config.debugAdTiming) {
3028
+ console.log("[StormcloudVideoPlayer] \uD83C\uDFAF EARLY SCTE-35 DETECTION: Ad break marker found in fragment", i, "- triggering ad handling immediately");
3029
+ }
3030
+ var durationSeconds = _this.parseCueOutDuration(value);
3031
+ var marker = _object_spread_props(_object_spread({
3032
+ type: "start"
3033
+ }, durationSeconds !== void 0 ? {
3034
+ durationSeconds: durationSeconds
3035
+ } : {}), {
3036
+ raw: {
3037
+ tag: tag,
3038
+ value: value,
3039
+ earlyDetection: true
3040
+ }
3041
+ });
3042
+ _this.inAdBreak = true;
3043
+ _this.expectedAdBreakDurationMs = durationSeconds ? durationSeconds * 1e3 : void 0;
3044
+ _this.currentAdBreakStartWallClockMs = Date.now();
3045
+ _this.clearAdStartTimer();
3046
+ _this.handleAdStart(marker);
3047
+ if (_this.expectedAdBreakDurationMs != null) {
3048
+ _this.scheduleAdStopCountdown(_this.expectedAdBreakDurationMs);
3049
+ }
3050
+ return;
3051
+ }
3052
+ }
3053
+ }
3054
+ } catch (err) {
3055
+ _didIteratorError = true;
3056
+ _iteratorError = err;
3057
+ } finally{
3058
+ try {
3059
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
3060
+ _iterator.return();
3061
+ }
3062
+ } finally{
3063
+ if (_didIteratorError) {
3064
+ throw _iteratorError;
3065
+ }
3066
+ }
3067
+ }
3068
+ }
3069
+ });
2958
3070
  this.hls.on(Hls2.Events.FRAG_BUFFERED, function(_evt, data) {
2959
3071
  return _async_to_generator(function() {
2960
3072
  var _this, _this_config_minSegmentsBeforePlay, minSegments, _this_video_play;
@@ -3162,11 +3274,16 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3162
3274
  this.ima.initialize();
3163
3275
  this.ima.updateOriginalMutedState(this.video.muted, this.video.volume);
3164
3276
  this.ima.on("all_ads_completed", function() {
3277
+ var remaining = _this.getRemainingAdMs();
3165
3278
  if (_this.config.debugAdTiming) {
3166
- console.log("[StormcloudVideoPlayer] IMA all_ads_completed event received - ending ad break");
3279
+ console.log("[StormcloudVideoPlayer] IMA all_ads_completed event received - remaining=".concat(remaining, "ms, queued ads=").concat(_this.adRequestQueue.length));
3167
3280
  }
3168
3281
  if (_this.inAdBreak) {
3169
- _this.handleAdPodComplete();
3282
+ if (remaining > 500) {
3283
+ _this.tryNextAvailableAd();
3284
+ } else {
3285
+ _this.handleAdPodComplete();
3286
+ }
3170
3287
  }
3171
3288
  });
3172
3289
  this.ima.on("ad_error", function(errorPayload) {
@@ -3961,6 +4078,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3961
4078
  this.continuousFetchingActive = true;
3962
4079
  this.isShowingPlaceholder = false;
3963
4080
  this.placeholderStartTimeMs = null;
4081
+ this.consecutiveEmptyResponses = 0;
4082
+ this.totalAdRequestsInBreak = 0;
4083
+ this.lastEmptyResponseTimeMs = 0;
3964
4084
  currentMuted = this.video.muted;
3965
4085
  currentVolume = this.video.volume;
3966
4086
  this.ima.updateOriginalMutedState(currentMuted, currentVolume);
@@ -3968,6 +4088,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3968
4088
  this.currentAdIndex = 0;
3969
4089
  this.totalAdsInBreak = 1;
3970
4090
  this.adPodQueue = [];
4091
+ this.showAds = true;
4092
+ this.ima.showPlaceholder();
3971
4093
  if (this.expectedAdBreakDurationMs == null && adBreakDurationMs != null) {
3972
4094
  this.expectedAdBreakDurationMs = adBreakDurationMs;
3973
4095
  this.currentAdBreakStartWallClockMs = Date.now();
@@ -4054,158 +4176,200 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4054
4176
  key: "continuousFetchLoop",
4055
4177
  value: function continuousFetchLoop(baseVastUrl) {
4056
4178
  return _async_to_generator(function() {
4057
- var remaining, maxQueueSize, newAdUrl, response, xmlText, parser, xmlDoc, mediaFiles, error;
4179
+ var _this, _loop, _ret;
4058
4180
  return _ts_generator(this, function(_state) {
4059
4181
  switch(_state.label){
4060
4182
  case 0:
4061
- if (!(this.continuousFetchingActive && this.inAdBreak)) return [
4062
- 3,
4063
- 14
4064
- ];
4065
- remaining = this.getRemainingAdMs();
4066
- if (remaining <= 0) {
4067
- if (this.config.debugAdTiming) {
4068
- console.log("[CONTINUOUS-FETCH] \u23F9\uFE0F Ad break time expired, stopping fetch loop");
4069
- }
4070
- return [
4071
- 3,
4072
- 14
4073
- ];
4074
- }
4075
- maxQueueSize = 3;
4076
- if (!(this.adRequestQueue.length >= maxQueueSize)) return [
4077
- 3,
4078
- 2
4079
- ];
4080
- if (this.config.debugAdTiming) {
4081
- console.log("[CONTINUOUS-FETCH] ⏸️ Queue full (".concat(this.adRequestQueue.length, "), pausing fetching..."));
4082
- }
4083
- return [
4084
- 4,
4085
- new Promise(function(resolve) {
4086
- return setTimeout(resolve, 2e3);
4087
- })
4088
- ];
4183
+ _loop = function() {
4184
+ var remaining, maxQueueSize, newAdUrl, _this_ima_hasPreloadedAd, _this_ima, _this_ima_hasPreloadedAd1, hasPreloadedAd, backoffDelay, error, backoffDelay1;
4185
+ return _ts_generator(this, function(_state) {
4186
+ switch(_state.label){
4187
+ case 0:
4188
+ remaining = _this.getRemainingAdMs();
4189
+ if (remaining <= 0) {
4190
+ if (_this.config.debugAdTiming) {
4191
+ console.log("[CONTINUOUS-FETCH] \u23F9\uFE0F Ad break time expired, stopping fetch loop");
4192
+ }
4193
+ return [
4194
+ 2,
4195
+ "break"
4196
+ ];
4197
+ }
4198
+ if (_this.totalAdRequestsInBreak >= _this.maxTotalAdRequestsPerBreak) {
4199
+ if (_this.config.debugAdTiming) {
4200
+ console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Maximum ad requests reached (".concat(_this.maxTotalAdRequestsPerBreak, "), stopping fetch loop to prevent server blocks"));
4201
+ }
4202
+ return [
4203
+ 2,
4204
+ "break"
4205
+ ];
4206
+ }
4207
+ if (_this.consecutiveEmptyResponses >= _this.maxConsecutiveEmptyResponses) {
4208
+ if (_this.config.debugAdTiming) {
4209
+ console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Too many consecutive empty responses (".concat(_this.maxConsecutiveEmptyResponses, "), stopping fetch loop"));
4210
+ }
4211
+ return [
4212
+ 2,
4213
+ "break"
4214
+ ];
4215
+ }
4216
+ maxQueueSize = 3;
4217
+ if (!(_this.adRequestQueue.length >= maxQueueSize)) return [
4218
+ 3,
4219
+ 2
4220
+ ];
4221
+ if (_this.config.debugAdTiming) {
4222
+ console.log("[CONTINUOUS-FETCH] ⏸️ Queue full (".concat(_this.adRequestQueue.length, "), pausing fetching..."));
4223
+ }
4224
+ return [
4225
+ 4,
4226
+ new Promise(function(resolve) {
4227
+ return setTimeout(resolve, 2e3);
4228
+ })
4229
+ ];
4230
+ case 1:
4231
+ _state.sent();
4232
+ return [
4233
+ 2,
4234
+ "continue"
4235
+ ];
4236
+ case 2:
4237
+ newAdUrl = _this.generateVastUrlsWithCorrelators(baseVastUrl, 1)[0];
4238
+ if (!(!newAdUrl || _this.failedVastUrls.has(newAdUrl))) return [
4239
+ 3,
4240
+ 4
4241
+ ];
4242
+ return [
4243
+ 4,
4244
+ new Promise(function(resolve) {
4245
+ return setTimeout(resolve, 1e3);
4246
+ })
4247
+ ];
4248
+ case 3:
4249
+ _state.sent();
4250
+ return [
4251
+ 2,
4252
+ "continue"
4253
+ ];
4254
+ case 4:
4255
+ _this.totalAdRequestsInBreak++;
4256
+ if (_this.config.debugAdTiming) {
4257
+ console.log("[CONTINUOUS-FETCH] \uD83D\uDCE1 Attempting to fetch ad (request ".concat(_this.totalAdRequestsInBreak, "/").concat(_this.maxTotalAdRequestsPerBreak, ", queue: ").concat(_this.adRequestQueue.length, ")..."));
4258
+ }
4259
+ _state.label = 5;
4260
+ case 5:
4261
+ _state.trys.push([
4262
+ 5,
4263
+ 11,
4264
+ ,
4265
+ 13
4266
+ ]);
4267
+ if (!_this.ima.preloadAds) return [
4268
+ 3,
4269
+ 7
4270
+ ];
4271
+ return [
4272
+ 4,
4273
+ _this.ima.preloadAds(newAdUrl)
4274
+ ];
4275
+ case 6:
4276
+ _state.sent();
4277
+ _state.label = 7;
4278
+ case 7:
4279
+ hasPreloadedAd = (_this_ima_hasPreloadedAd1 = (_this_ima_hasPreloadedAd = (_this_ima = _this.ima).hasPreloadedAd) === null || _this_ima_hasPreloadedAd === void 0 ? void 0 : _this_ima_hasPreloadedAd.call(_this_ima, newAdUrl)) !== null && _this_ima_hasPreloadedAd1 !== void 0 ? _this_ima_hasPreloadedAd1 : false;
4280
+ if (!!hasPreloadedAd) return [
4281
+ 3,
4282
+ 9
4283
+ ];
4284
+ _this.consecutiveEmptyResponses++;
4285
+ _this.lastEmptyResponseTimeMs = Date.now();
4286
+ backoffDelay = Math.min(_this.baseEmptyResponseDelayMs * Math.pow(2, _this.consecutiveEmptyResponses - 1), _this.maxEmptyResponseDelayMs);
4287
+ if (_this.config.debugAdTiming) {
4288
+ console.log("[CONTINUOUS-FETCH] ⚠️ Empty/invalid VAST response (".concat(_this.consecutiveEmptyResponses, "/").concat(_this.maxConsecutiveEmptyResponses, " consecutive), backing off for ").concat(backoffDelay, "ms"));
4289
+ }
4290
+ _this.failedVastUrls.add(newAdUrl);
4291
+ return [
4292
+ 4,
4293
+ new Promise(function(resolve) {
4294
+ return setTimeout(resolve, backoffDelay);
4295
+ })
4296
+ ];
4297
+ case 8:
4298
+ _state.sent();
4299
+ return [
4300
+ 2,
4301
+ "continue"
4302
+ ];
4303
+ case 9:
4304
+ _this.consecutiveEmptyResponses = 0;
4305
+ if (_this.config.debugAdTiming) {
4306
+ console.log("[CONTINUOUS-FETCH] ✅ Successfully preloaded ad, adding to queue (queue size: ".concat(_this.adRequestQueue.length + 1, ")"));
4307
+ }
4308
+ _this.adRequestQueue.push(newAdUrl);
4309
+ _this.totalAdsInBreak++;
4310
+ return [
4311
+ 4,
4312
+ new Promise(function(resolve) {
4313
+ return setTimeout(resolve, 500);
4314
+ })
4315
+ ];
4316
+ case 10:
4317
+ _state.sent();
4318
+ return [
4319
+ 3,
4320
+ 13
4321
+ ];
4322
+ case 11:
4323
+ error = _state.sent();
4324
+ if (_this.config.debugAdTiming) {
4325
+ console.log("[CONTINUOUS-FETCH] \u274C Ad preload failed:", error.message);
4326
+ }
4327
+ _this.failedVastUrls.add(newAdUrl);
4328
+ _this.consecutiveEmptyResponses++;
4329
+ backoffDelay1 = Math.min(_this.baseEmptyResponseDelayMs * Math.pow(2, _this.consecutiveEmptyResponses - 1), _this.maxEmptyResponseDelayMs);
4330
+ return [
4331
+ 4,
4332
+ new Promise(function(resolve) {
4333
+ return setTimeout(resolve, backoffDelay1);
4334
+ })
4335
+ ];
4336
+ case 12:
4337
+ _state.sent();
4338
+ return [
4339
+ 3,
4340
+ 13
4341
+ ];
4342
+ case 13:
4343
+ return [
4344
+ 2
4345
+ ];
4346
+ }
4347
+ });
4348
+ };
4349
+ _state.label = 1;
4089
4350
  case 1:
4090
- _state.sent();
4091
- return [
4092
- 3,
4093
- 0
4094
- ];
4095
- case 2:
4096
- newAdUrl = this.generateVastUrlsWithCorrelators(baseVastUrl, 1)[0];
4097
- if (!(!newAdUrl || this.failedVastUrls.has(newAdUrl))) return [
4351
+ if (!(this.continuousFetchingActive && this.inAdBreak)) return [
4098
4352
  3,
4099
- 4
4353
+ 3
4100
4354
  ];
4355
+ _this = this;
4101
4356
  return [
4102
- 4,
4103
- new Promise(function(resolve) {
4104
- return setTimeout(resolve, 1e3);
4105
- })
4106
- ];
4107
- case 3:
4108
- _state.sent();
4109
- return [
4110
- 3,
4111
- 0
4112
- ];
4113
- case 4:
4114
- if (this.config.debugAdTiming) {
4115
- console.log("[CONTINUOUS-FETCH] \uD83D\uDCE1 Attempting to fetch ad (".concat(this.successfulAdRequests.length + this.adRequestQueue.length + 1, " total)..."));
4116
- }
4117
- _state.label = 5;
4118
- case 5:
4119
- _state.trys.push([
4120
4357
  5,
4121
- 11,
4122
- ,
4123
- 13
4124
- ]);
4125
- return [
4126
- 4,
4127
- fetch(newAdUrl, {
4128
- mode: "cors"
4129
- })
4130
- ];
4131
- case 6:
4132
- response = _state.sent();
4133
- if (!response.ok) {
4134
- throw new Error("Failed to fetch VAST: ".concat(response.status));
4135
- }
4136
- return [
4137
- 4,
4138
- response.text()
4139
- ];
4140
- case 7:
4141
- xmlText = _state.sent();
4142
- parser = new DOMParser();
4143
- xmlDoc = parser.parseFromString(xmlText, "text/xml");
4144
- mediaFiles = xmlDoc.querySelectorAll("MediaFile");
4145
- if (!(mediaFiles.length === 0)) return [
4146
- 3,
4147
- 9
4148
- ];
4149
- if (this.config.debugAdTiming) {
4150
- console.log("[CONTINUOUS-FETCH] \u26A0\uFE0F VAST response has no media files, skipping");
4151
- }
4152
- this.failedVastUrls.add(newAdUrl);
4153
- return [
4154
- 4,
4155
- new Promise(function(resolve) {
4156
- return setTimeout(resolve, 1e3);
4157
- })
4358
+ _ts_values(_loop())
4158
4359
  ];
4159
- case 8:
4160
- _state.sent();
4161
- return [
4162
- 3,
4163
- 0
4164
- ];
4165
- case 9:
4166
- if (this.config.debugAdTiming) {
4167
- console.log("[CONTINUOUS-FETCH] ✅ Successfully fetched ad, adding to queue (queue size: ".concat(this.adRequestQueue.length + 1, ")"));
4168
- }
4169
- this.adRequestQueue.push(newAdUrl);
4170
- this.totalAdsInBreak++;
4171
- return [
4172
- 4,
4173
- new Promise(function(resolve) {
4174
- return setTimeout(resolve, 500);
4175
- })
4176
- ];
4177
- case 10:
4178
- _state.sent();
4179
- return [
4180
- 3,
4181
- 13
4182
- ];
4183
- case 11:
4184
- error = _state.sent();
4185
- if (this.config.debugAdTiming) {
4186
- console.log("[CONTINUOUS-FETCH] \u274C Ad fetch failed:", error.message);
4187
- }
4188
- this.failedVastUrls.add(newAdUrl);
4189
- return [
4190
- 4,
4191
- new Promise(function(resolve) {
4192
- return setTimeout(resolve, 2e3);
4193
- })
4194
- ];
4195
- case 12:
4196
- _state.sent();
4197
- return [
4360
+ case 2:
4361
+ _ret = _state.sent();
4362
+ if (_ret === "break") return [
4198
4363
  3,
4199
- 13
4364
+ 3
4200
4365
  ];
4201
- case 13:
4202
4366
  return [
4203
4367
  3,
4204
- 0
4368
+ 1
4205
4369
  ];
4206
- case 14:
4370
+ case 3:
4207
4371
  if (this.config.debugAdTiming) {
4208
- console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Continuous fetch loop ended");
4372
+ console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Continuous fetch loop ended (total requests: ".concat(this.totalAdRequestsInBreak, ", empty responses: ").concat(this.consecutiveEmptyResponses, ")"));
4209
4373
  }
4210
4374
  return [
4211
4375
  2
@@ -5973,11 +6137,17 @@ var StormcloudVideoPlayerComponent = React.memo(function(props) {
5973
6137
  if (!playerRef.current) return;
5974
6138
  var checkAdStatus = function() {
5975
6139
  if (playerRef.current) {
5976
- var showAds = playerRef.current.isShowingAds();
6140
+ var _videoRef_current_dataset, _videoRef_current;
6141
+ var showAdsFromMethod = playerRef.current.isShowingAds();
6142
+ var showAdsFromAttribute = ((_videoRef_current = videoRef.current) === null || _videoRef_current === void 0 ? void 0 : (_videoRef_current_dataset = _videoRef_current.dataset) === null || _videoRef_current_dataset === void 0 ? void 0 : _videoRef_current_dataset.stormcloudAdPlaying) === "true";
6143
+ var showAds = showAdsFromMethod || showAdsFromAttribute;
5977
6144
  var currentIndex = playerRef.current.getCurrentAdIndex();
5978
6145
  var totalAds = playerRef.current.getTotalAdsInBreak();
5979
6146
  setAdStatus(function(prev) {
5980
6147
  if (prev.showAds !== showAds || prev.currentIndex !== currentIndex || prev.totalAds !== totalAds) {
6148
+ if (showAds && !prev.showAds) {
6149
+ setShowCenterPlay(false);
6150
+ }
5981
6151
  return {
5982
6152
  showAds: showAds,
5983
6153
  currentIndex: currentIndex,
@@ -5988,7 +6158,7 @@ var StormcloudVideoPlayerComponent = React.memo(function(props) {
5988
6158
  });
5989
6159
  }
5990
6160
  };
5991
- var interval = setInterval(checkAdStatus, 100);
6161
+ var interval = setInterval(checkAdStatus, 50);
5992
6162
  return function() {
5993
6163
  return clearInterval(interval);
5994
6164
  };
@@ -6116,7 +6286,9 @@ var StormcloudVideoPlayerComponent = React.memo(function(props) {
6116
6286
  }
6117
6287
  };
6118
6288
  var handlePause = function() {
6119
- if (playerRef.current && !playerRef.current.isShowingAds()) {
6289
+ var _playerRef_current, _videoRef_current_dataset, _videoRef_current;
6290
+ var isAdActive = ((_playerRef_current = playerRef.current) === null || _playerRef_current === void 0 ? void 0 : _playerRef_current.isShowingAds()) || ((_videoRef_current = videoRef.current) === null || _videoRef_current === void 0 ? void 0 : (_videoRef_current_dataset = _videoRef_current.dataset) === null || _videoRef_current_dataset === void 0 ? void 0 : _videoRef_current_dataset.stormcloudAdPlaying) === "true";
6291
+ if (playerRef.current && !isAdActive) {
6120
6292
  setShowCenterPlay(true);
6121
6293
  } else {
6122
6294
  setShowCenterPlay(false);