stormcloud-video-player 0.3.17 → 0.3.19

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.
@@ -286,6 +286,20 @@ function _ts_generator(thisArg, body) {
286
286
  };
287
287
  }
288
288
  }
289
+ function _ts_values(o) {
290
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
291
+ if (m) return m.call(o);
292
+ if (o && typeof o.length === "number") return {
293
+ next: function() {
294
+ if (o && i >= o.length) o = void 0;
295
+ return {
296
+ value: o && o[i++],
297
+ done: !o
298
+ };
299
+ }
300
+ };
301
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
302
+ }
289
303
  var __create = Object.create;
290
304
  var __defProp = Object.defineProperty;
291
305
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -731,7 +745,12 @@ function createImaController(video, options) {
731
745
  return [
732
746
  4,
733
747
  fetch(vastTagUrl, {
734
- mode: "cors"
748
+ mode: "cors",
749
+ credentials: "include",
750
+ headers: {
751
+ "Accept": "application/xml, text/xml, */*"
752
+ },
753
+ referrerPolicy: "no-referrer-when-downgrade"
735
754
  })
736
755
  ];
737
756
  case 1:
@@ -1276,6 +1295,7 @@ function createImaController(video, options) {
1276
1295
  },
1277
1296
  showPlaceholder: function showPlaceholder() {
1278
1297
  ensurePlaceholderContainer();
1298
+ hideContentVideo();
1279
1299
  if (adContainerEl) {
1280
1300
  adContainerEl.style.display = "flex";
1281
1301
  adContainerEl.style.backgroundColor = "#000";
@@ -1295,6 +1315,9 @@ function createImaController(video, options) {
1295
1315
  }
1296
1316
  }, 300);
1297
1317
  }
1318
+ if (!adPlaying) {
1319
+ showContentVideo();
1320
+ }
1298
1321
  }
1299
1322
  };
1300
1323
  }
@@ -1559,7 +1582,14 @@ function createHlsAdPlayer(contentVideo, options) {
1559
1582
  case 0:
1560
1583
  return [
1561
1584
  4,
1562
- fetch(vastTagUrl)
1585
+ fetch(vastTagUrl, {
1586
+ mode: "cors",
1587
+ credentials: "include",
1588
+ headers: {
1589
+ "Accept": "application/xml, text/xml, */*"
1590
+ },
1591
+ referrerPolicy: "no-referrer-when-downgrade"
1592
+ })
1563
1593
  ];
1564
1594
  case 1:
1565
1595
  response = _state.sent();
@@ -2069,6 +2099,8 @@ function createHlsAdPlayer(contentVideo, options) {
2069
2099
  return 1;
2070
2100
  },
2071
2101
  showPlaceholder: function showPlaceholder() {
2102
+ contentVideo.style.opacity = "0";
2103
+ contentVideo.style.visibility = "hidden";
2072
2104
  if (!adContainerEl) {
2073
2105
  var _contentVideo_parentElement;
2074
2106
  var container = document.createElement("div");
@@ -2096,6 +2128,10 @@ function createHlsAdPlayer(contentVideo, options) {
2096
2128
  adContainerEl.style.display = "none";
2097
2129
  adContainerEl.style.pointerEvents = "none";
2098
2130
  }
2131
+ if (!adPlaying) {
2132
+ contentVideo.style.visibility = "visible";
2133
+ contentVideo.style.opacity = "1";
2134
+ }
2099
2135
  }
2100
2136
  };
2101
2137
  }
@@ -2750,6 +2786,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
2750
2786
  this.maxPlaceholderDurationMs = 5e3;
2751
2787
  this.placeholderStartTimeMs = null;
2752
2788
  this.isShowingPlaceholder = false;
2789
+ this.consecutiveEmptyResponses = 0;
2790
+ this.totalAdRequestsInBreak = 0;
2791
+ this.lastEmptyResponseTimeMs = 0;
2792
+ this.maxTotalAdRequestsPerBreak = 20;
2793
+ this.maxConsecutiveEmptyResponses = 5;
2794
+ this.baseEmptyResponseDelayMs = 2e3;
2795
+ this.maxEmptyResponseDelayMs = 3e4;
2753
2796
  initializePolyfills();
2754
2797
  var browserOverrides = getBrowserConfigOverrides();
2755
2798
  this.config = _object_spread({}, config, browserOverrides);
@@ -2939,6 +2982,87 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
2939
2982
  });
2940
2983
  }).call(_this);
2941
2984
  });
2985
+ this.hls.on(import_hls2.default.Events.LEVEL_LOADED, function(_evt, data) {
2986
+ if (_this.inAdBreak) {
2987
+ return;
2988
+ }
2989
+ var details = data === null || data === void 0 ? void 0 : data.details;
2990
+ if (!details || !details.fragments || details.fragments.length === 0) {
2991
+ return;
2992
+ }
2993
+ var fragmentsToScan = Math.min(5, details.fragments.length);
2994
+ for(var i = 0; i < fragmentsToScan; i++){
2995
+ var frag = details.fragments[i];
2996
+ var tagList = frag === null || frag === void 0 ? void 0 : frag.tagList;
2997
+ if (!Array.isArray(tagList)) continue;
2998
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2999
+ try {
3000
+ for(var _iterator = tagList[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
3001
+ var entry = _step.value;
3002
+ var tag = "";
3003
+ var value = "";
3004
+ if (Array.isArray(entry)) {
3005
+ var _entry_;
3006
+ tag = String((_entry_ = entry[0]) !== null && _entry_ !== void 0 ? _entry_ : "");
3007
+ var _entry_1;
3008
+ value = String((_entry_1 = entry[1]) !== null && _entry_1 !== void 0 ? _entry_1 : "");
3009
+ } else if (typeof entry === "string") {
3010
+ var idx = entry.indexOf(":");
3011
+ if (idx >= 0) {
3012
+ tag = entry.substring(0, idx);
3013
+ value = entry.substring(idx + 1);
3014
+ } else {
3015
+ tag = entry;
3016
+ }
3017
+ }
3018
+ if (!tag) continue;
3019
+ if (tag.includes("EXT-X-CUE-OUT") || tag.includes("EXT-X-DATERANGE")) {
3020
+ var attrs = tag.includes("EXT-X-DATERANGE") ? _this.parseAttributeList(value) : {};
3021
+ var hasScteOut = tag.includes("EXT-X-CUE-OUT") || "SCTE35-OUT" in attrs || attrs["SCTE35-OUT"] !== void 0;
3022
+ if (hasScteOut) {
3023
+ if (_this.config.debugAdTiming) {
3024
+ console.log("[StormcloudVideoPlayer] \uD83C\uDFAF EARLY SCTE-35 DETECTION: Ad break marker found in fragment", i, "- triggering ad handling immediately");
3025
+ }
3026
+ var durationSeconds = _this.parseCueOutDuration(value);
3027
+ var marker = _object_spread_props(_object_spread({
3028
+ type: "start"
3029
+ }, durationSeconds !== void 0 ? {
3030
+ durationSeconds: durationSeconds
3031
+ } : {}), {
3032
+ raw: {
3033
+ tag: tag,
3034
+ value: value,
3035
+ earlyDetection: true
3036
+ }
3037
+ });
3038
+ _this.inAdBreak = true;
3039
+ _this.expectedAdBreakDurationMs = durationSeconds ? durationSeconds * 1e3 : void 0;
3040
+ _this.currentAdBreakStartWallClockMs = Date.now();
3041
+ _this.clearAdStartTimer();
3042
+ _this.handleAdStart(marker);
3043
+ if (_this.expectedAdBreakDurationMs != null) {
3044
+ _this.scheduleAdStopCountdown(_this.expectedAdBreakDurationMs);
3045
+ }
3046
+ return;
3047
+ }
3048
+ }
3049
+ }
3050
+ } catch (err) {
3051
+ _didIteratorError = true;
3052
+ _iteratorError = err;
3053
+ } finally{
3054
+ try {
3055
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
3056
+ _iterator.return();
3057
+ }
3058
+ } finally{
3059
+ if (_didIteratorError) {
3060
+ throw _iteratorError;
3061
+ }
3062
+ }
3063
+ }
3064
+ }
3065
+ });
2942
3066
  this.hls.on(import_hls2.default.Events.FRAG_BUFFERED, function(_evt, data) {
2943
3067
  return _async_to_generator(function() {
2944
3068
  var _this, _this_config_minSegmentsBeforePlay, minSegments, _this_video_play;
@@ -3146,11 +3270,16 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3146
3270
  this.ima.initialize();
3147
3271
  this.ima.updateOriginalMutedState(this.video.muted, this.video.volume);
3148
3272
  this.ima.on("all_ads_completed", function() {
3273
+ var remaining = _this.getRemainingAdMs();
3149
3274
  if (_this.config.debugAdTiming) {
3150
- console.log("[StormcloudVideoPlayer] IMA all_ads_completed event received - ending ad break");
3275
+ console.log("[StormcloudVideoPlayer] IMA all_ads_completed event received - remaining=".concat(remaining, "ms, queued ads=").concat(_this.adRequestQueue.length));
3151
3276
  }
3152
3277
  if (_this.inAdBreak) {
3153
- _this.handleAdPodComplete();
3278
+ if (remaining > 500) {
3279
+ _this.tryNextAvailableAd();
3280
+ } else {
3281
+ _this.handleAdPodComplete();
3282
+ }
3154
3283
  }
3155
3284
  });
3156
3285
  this.ima.on("ad_error", function(errorPayload) {
@@ -3945,6 +4074,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3945
4074
  this.continuousFetchingActive = true;
3946
4075
  this.isShowingPlaceholder = false;
3947
4076
  this.placeholderStartTimeMs = null;
4077
+ this.consecutiveEmptyResponses = 0;
4078
+ this.totalAdRequestsInBreak = 0;
4079
+ this.lastEmptyResponseTimeMs = 0;
3948
4080
  currentMuted = this.video.muted;
3949
4081
  currentVolume = this.video.volume;
3950
4082
  this.ima.updateOriginalMutedState(currentMuted, currentVolume);
@@ -3952,6 +4084,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3952
4084
  this.currentAdIndex = 0;
3953
4085
  this.totalAdsInBreak = 1;
3954
4086
  this.adPodQueue = [];
4087
+ this.showAds = true;
4088
+ this.ima.showPlaceholder();
3955
4089
  if (this.expectedAdBreakDurationMs == null && adBreakDurationMs != null) {
3956
4090
  this.expectedAdBreakDurationMs = adBreakDurationMs;
3957
4091
  this.currentAdBreakStartWallClockMs = Date.now();
@@ -4038,158 +4172,200 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4038
4172
  key: "continuousFetchLoop",
4039
4173
  value: function continuousFetchLoop(baseVastUrl) {
4040
4174
  return _async_to_generator(function() {
4041
- var remaining, maxQueueSize, newAdUrl, response, xmlText, parser, xmlDoc, mediaFiles, error;
4175
+ var _this, _loop, _ret;
4042
4176
  return _ts_generator(this, function(_state) {
4043
4177
  switch(_state.label){
4044
4178
  case 0:
4045
- if (!(this.continuousFetchingActive && this.inAdBreak)) return [
4046
- 3,
4047
- 14
4048
- ];
4049
- remaining = this.getRemainingAdMs();
4050
- if (remaining <= 0) {
4051
- if (this.config.debugAdTiming) {
4052
- console.log("[CONTINUOUS-FETCH] \u23F9\uFE0F Ad break time expired, stopping fetch loop");
4053
- }
4054
- return [
4055
- 3,
4056
- 14
4057
- ];
4058
- }
4059
- maxQueueSize = 3;
4060
- if (!(this.adRequestQueue.length >= maxQueueSize)) return [
4061
- 3,
4062
- 2
4063
- ];
4064
- if (this.config.debugAdTiming) {
4065
- console.log("[CONTINUOUS-FETCH] ⏸️ Queue full (".concat(this.adRequestQueue.length, "), pausing fetching..."));
4066
- }
4067
- return [
4068
- 4,
4069
- new Promise(function(resolve) {
4070
- return setTimeout(resolve, 2e3);
4071
- })
4072
- ];
4179
+ _loop = function() {
4180
+ var remaining, maxQueueSize, newAdUrl, _this_ima_hasPreloadedAd, _this_ima, _this_ima_hasPreloadedAd1, hasPreloadedAd, backoffDelay, error, backoffDelay1;
4181
+ return _ts_generator(this, function(_state) {
4182
+ switch(_state.label){
4183
+ case 0:
4184
+ remaining = _this.getRemainingAdMs();
4185
+ if (remaining <= 0) {
4186
+ if (_this.config.debugAdTiming) {
4187
+ console.log("[CONTINUOUS-FETCH] \u23F9\uFE0F Ad break time expired, stopping fetch loop");
4188
+ }
4189
+ return [
4190
+ 2,
4191
+ "break"
4192
+ ];
4193
+ }
4194
+ if (_this.totalAdRequestsInBreak >= _this.maxTotalAdRequestsPerBreak) {
4195
+ if (_this.config.debugAdTiming) {
4196
+ console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Maximum ad requests reached (".concat(_this.maxTotalAdRequestsPerBreak, "), stopping fetch loop to prevent server blocks"));
4197
+ }
4198
+ return [
4199
+ 2,
4200
+ "break"
4201
+ ];
4202
+ }
4203
+ if (_this.consecutiveEmptyResponses >= _this.maxConsecutiveEmptyResponses) {
4204
+ if (_this.config.debugAdTiming) {
4205
+ console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Too many consecutive empty responses (".concat(_this.maxConsecutiveEmptyResponses, "), stopping fetch loop"));
4206
+ }
4207
+ return [
4208
+ 2,
4209
+ "break"
4210
+ ];
4211
+ }
4212
+ maxQueueSize = 3;
4213
+ if (!(_this.adRequestQueue.length >= maxQueueSize)) return [
4214
+ 3,
4215
+ 2
4216
+ ];
4217
+ if (_this.config.debugAdTiming) {
4218
+ console.log("[CONTINUOUS-FETCH] ⏸️ Queue full (".concat(_this.adRequestQueue.length, "), pausing fetching..."));
4219
+ }
4220
+ return [
4221
+ 4,
4222
+ new Promise(function(resolve) {
4223
+ return setTimeout(resolve, 2e3);
4224
+ })
4225
+ ];
4226
+ case 1:
4227
+ _state.sent();
4228
+ return [
4229
+ 2,
4230
+ "continue"
4231
+ ];
4232
+ case 2:
4233
+ newAdUrl = _this.generateVastUrlsWithCorrelators(baseVastUrl, 1)[0];
4234
+ if (!(!newAdUrl || _this.failedVastUrls.has(newAdUrl))) return [
4235
+ 3,
4236
+ 4
4237
+ ];
4238
+ return [
4239
+ 4,
4240
+ new Promise(function(resolve) {
4241
+ return setTimeout(resolve, 1e3);
4242
+ })
4243
+ ];
4244
+ case 3:
4245
+ _state.sent();
4246
+ return [
4247
+ 2,
4248
+ "continue"
4249
+ ];
4250
+ case 4:
4251
+ _this.totalAdRequestsInBreak++;
4252
+ if (_this.config.debugAdTiming) {
4253
+ console.log("[CONTINUOUS-FETCH] \uD83D\uDCE1 Attempting to fetch ad (request ".concat(_this.totalAdRequestsInBreak, "/").concat(_this.maxTotalAdRequestsPerBreak, ", queue: ").concat(_this.adRequestQueue.length, ")..."));
4254
+ }
4255
+ _state.label = 5;
4256
+ case 5:
4257
+ _state.trys.push([
4258
+ 5,
4259
+ 11,
4260
+ ,
4261
+ 13
4262
+ ]);
4263
+ if (!_this.ima.preloadAds) return [
4264
+ 3,
4265
+ 7
4266
+ ];
4267
+ return [
4268
+ 4,
4269
+ _this.ima.preloadAds(newAdUrl)
4270
+ ];
4271
+ case 6:
4272
+ _state.sent();
4273
+ _state.label = 7;
4274
+ case 7:
4275
+ 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;
4276
+ if (!!hasPreloadedAd) return [
4277
+ 3,
4278
+ 9
4279
+ ];
4280
+ _this.consecutiveEmptyResponses++;
4281
+ _this.lastEmptyResponseTimeMs = Date.now();
4282
+ backoffDelay = Math.min(_this.baseEmptyResponseDelayMs * Math.pow(2, _this.consecutiveEmptyResponses - 1), _this.maxEmptyResponseDelayMs);
4283
+ if (_this.config.debugAdTiming) {
4284
+ console.log("[CONTINUOUS-FETCH] ⚠️ Empty/invalid VAST response (".concat(_this.consecutiveEmptyResponses, "/").concat(_this.maxConsecutiveEmptyResponses, " consecutive), backing off for ").concat(backoffDelay, "ms"));
4285
+ }
4286
+ _this.failedVastUrls.add(newAdUrl);
4287
+ return [
4288
+ 4,
4289
+ new Promise(function(resolve) {
4290
+ return setTimeout(resolve, backoffDelay);
4291
+ })
4292
+ ];
4293
+ case 8:
4294
+ _state.sent();
4295
+ return [
4296
+ 2,
4297
+ "continue"
4298
+ ];
4299
+ case 9:
4300
+ _this.consecutiveEmptyResponses = 0;
4301
+ if (_this.config.debugAdTiming) {
4302
+ console.log("[CONTINUOUS-FETCH] ✅ Successfully preloaded ad, adding to queue (queue size: ".concat(_this.adRequestQueue.length + 1, ")"));
4303
+ }
4304
+ _this.adRequestQueue.push(newAdUrl);
4305
+ _this.totalAdsInBreak++;
4306
+ return [
4307
+ 4,
4308
+ new Promise(function(resolve) {
4309
+ return setTimeout(resolve, 500);
4310
+ })
4311
+ ];
4312
+ case 10:
4313
+ _state.sent();
4314
+ return [
4315
+ 3,
4316
+ 13
4317
+ ];
4318
+ case 11:
4319
+ error = _state.sent();
4320
+ if (_this.config.debugAdTiming) {
4321
+ console.log("[CONTINUOUS-FETCH] \u274C Ad preload failed:", error.message);
4322
+ }
4323
+ _this.failedVastUrls.add(newAdUrl);
4324
+ _this.consecutiveEmptyResponses++;
4325
+ backoffDelay1 = Math.min(_this.baseEmptyResponseDelayMs * Math.pow(2, _this.consecutiveEmptyResponses - 1), _this.maxEmptyResponseDelayMs);
4326
+ return [
4327
+ 4,
4328
+ new Promise(function(resolve) {
4329
+ return setTimeout(resolve, backoffDelay1);
4330
+ })
4331
+ ];
4332
+ case 12:
4333
+ _state.sent();
4334
+ return [
4335
+ 3,
4336
+ 13
4337
+ ];
4338
+ case 13:
4339
+ return [
4340
+ 2
4341
+ ];
4342
+ }
4343
+ });
4344
+ };
4345
+ _state.label = 1;
4073
4346
  case 1:
4074
- _state.sent();
4075
- return [
4076
- 3,
4077
- 0
4078
- ];
4079
- case 2:
4080
- newAdUrl = this.generateVastUrlsWithCorrelators(baseVastUrl, 1)[0];
4081
- if (!(!newAdUrl || this.failedVastUrls.has(newAdUrl))) return [
4347
+ if (!(this.continuousFetchingActive && this.inAdBreak)) return [
4082
4348
  3,
4083
- 4
4349
+ 3
4084
4350
  ];
4351
+ _this = this;
4085
4352
  return [
4086
- 4,
4087
- new Promise(function(resolve) {
4088
- return setTimeout(resolve, 1e3);
4089
- })
4090
- ];
4091
- case 3:
4092
- _state.sent();
4093
- return [
4094
- 3,
4095
- 0
4096
- ];
4097
- case 4:
4098
- if (this.config.debugAdTiming) {
4099
- console.log("[CONTINUOUS-FETCH] \uD83D\uDCE1 Attempting to fetch ad (".concat(this.successfulAdRequests.length + this.adRequestQueue.length + 1, " total)..."));
4100
- }
4101
- _state.label = 5;
4102
- case 5:
4103
- _state.trys.push([
4104
4353
  5,
4105
- 11,
4106
- ,
4107
- 13
4108
- ]);
4109
- return [
4110
- 4,
4111
- fetch(newAdUrl, {
4112
- mode: "cors"
4113
- })
4114
- ];
4115
- case 6:
4116
- response = _state.sent();
4117
- if (!response.ok) {
4118
- throw new Error("Failed to fetch VAST: ".concat(response.status));
4119
- }
4120
- return [
4121
- 4,
4122
- response.text()
4123
- ];
4124
- case 7:
4125
- xmlText = _state.sent();
4126
- parser = new DOMParser();
4127
- xmlDoc = parser.parseFromString(xmlText, "text/xml");
4128
- mediaFiles = xmlDoc.querySelectorAll("MediaFile");
4129
- if (!(mediaFiles.length === 0)) return [
4130
- 3,
4131
- 9
4354
+ _ts_values(_loop())
4132
4355
  ];
4133
- if (this.config.debugAdTiming) {
4134
- console.log("[CONTINUOUS-FETCH] \u26A0\uFE0F VAST response has no media files, skipping");
4135
- }
4136
- this.failedVastUrls.add(newAdUrl);
4137
- return [
4138
- 4,
4139
- new Promise(function(resolve) {
4140
- return setTimeout(resolve, 1e3);
4141
- })
4142
- ];
4143
- case 8:
4144
- _state.sent();
4145
- return [
4146
- 3,
4147
- 0
4148
- ];
4149
- case 9:
4150
- if (this.config.debugAdTiming) {
4151
- console.log("[CONTINUOUS-FETCH] ✅ Successfully fetched ad, adding to queue (queue size: ".concat(this.adRequestQueue.length + 1, ")"));
4152
- }
4153
- this.adRequestQueue.push(newAdUrl);
4154
- this.totalAdsInBreak++;
4155
- return [
4156
- 4,
4157
- new Promise(function(resolve) {
4158
- return setTimeout(resolve, 500);
4159
- })
4160
- ];
4161
- case 10:
4162
- _state.sent();
4163
- return [
4164
- 3,
4165
- 13
4166
- ];
4167
- case 11:
4168
- error = _state.sent();
4169
- if (this.config.debugAdTiming) {
4170
- console.log("[CONTINUOUS-FETCH] \u274C Ad fetch failed:", error.message);
4171
- }
4172
- this.failedVastUrls.add(newAdUrl);
4173
- return [
4174
- 4,
4175
- new Promise(function(resolve) {
4176
- return setTimeout(resolve, 2e3);
4177
- })
4178
- ];
4179
- case 12:
4180
- _state.sent();
4181
- return [
4356
+ case 2:
4357
+ _ret = _state.sent();
4358
+ if (_ret === "break") return [
4182
4359
  3,
4183
- 13
4360
+ 3
4184
4361
  ];
4185
- case 13:
4186
4362
  return [
4187
4363
  3,
4188
- 0
4364
+ 1
4189
4365
  ];
4190
- case 14:
4366
+ case 3:
4191
4367
  if (this.config.debugAdTiming) {
4192
- console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Continuous fetch loop ended");
4368
+ console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Continuous fetch loop ended (total requests: ".concat(this.totalAdRequestsInBreak, ", empty responses: ").concat(this.consecutiveEmptyResponses, ")"));
4193
4369
  }
4194
4370
  return [
4195
4371
  2
@@ -4879,7 +5055,12 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4879
5055
  return [
4880
5056
  4,
4881
5057
  fetch(vastTagUrl, {
4882
- mode: "cors"
5058
+ mode: "cors",
5059
+ credentials: "include",
5060
+ headers: {
5061
+ "Accept": "application/xml, text/xml, */*"
5062
+ },
5063
+ referrerPolicy: "no-referrer-when-downgrade"
4883
5064
  })
4884
5065
  ];
4885
5066
  case 1:
@@ -4978,7 +5159,12 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4978
5159
  return [
4979
5160
  4,
4980
5161
  fetch(vastTagUrl, {
4981
- mode: "cors"
5162
+ mode: "cors",
5163
+ credentials: "include",
5164
+ headers: {
5165
+ "Accept": "application/xml, text/xml, */*"
5166
+ },
5167
+ referrerPolicy: "no-referrer-when-downgrade"
4982
5168
  })
4983
5169
  ];
4984
5170
  case 1:
@@ -5145,10 +5331,12 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5145
5331
  4,
5146
5332
  fetch(mediaUrl, {
5147
5333
  mode: "cors",
5334
+ credentials: "include",
5148
5335
  method: "GET",
5149
5336
  headers: {
5150
5337
  Range: "bytes=0-1048576"
5151
- }
5338
+ },
5339
+ referrerPolicy: "no-referrer-when-downgrade"
5152
5340
  })
5153
5341
  ];
5154
5342
  case 2:
@@ -5957,11 +6145,17 @@ var StormcloudVideoPlayerComponent = import_react.default.memo(function(props) {
5957
6145
  if (!playerRef.current) return;
5958
6146
  var checkAdStatus = function() {
5959
6147
  if (playerRef.current) {
5960
- var showAds = playerRef.current.isShowingAds();
6148
+ var _videoRef_current_dataset, _videoRef_current;
6149
+ var showAdsFromMethod = playerRef.current.isShowingAds();
6150
+ 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";
6151
+ var showAds = showAdsFromMethod || showAdsFromAttribute;
5961
6152
  var currentIndex = playerRef.current.getCurrentAdIndex();
5962
6153
  var totalAds = playerRef.current.getTotalAdsInBreak();
5963
6154
  setAdStatus(function(prev) {
5964
6155
  if (prev.showAds !== showAds || prev.currentIndex !== currentIndex || prev.totalAds !== totalAds) {
6156
+ if (showAds && !prev.showAds) {
6157
+ setShowCenterPlay(false);
6158
+ }
5965
6159
  return {
5966
6160
  showAds: showAds,
5967
6161
  currentIndex: currentIndex,
@@ -5972,7 +6166,7 @@ var StormcloudVideoPlayerComponent = import_react.default.memo(function(props) {
5972
6166
  });
5973
6167
  }
5974
6168
  };
5975
- var interval = setInterval(checkAdStatus, 100);
6169
+ var interval = setInterval(checkAdStatus, 50);
5976
6170
  return function() {
5977
6171
  return clearInterval(interval);
5978
6172
  };
@@ -6100,7 +6294,9 @@ var StormcloudVideoPlayerComponent = import_react.default.memo(function(props) {
6100
6294
  }
6101
6295
  };
6102
6296
  var handlePause = function() {
6103
- if (playerRef.current && !playerRef.current.isShowingAds()) {
6297
+ var _playerRef_current, _videoRef_current_dataset, _videoRef_current;
6298
+ 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";
6299
+ if (playerRef.current && !isAdActive) {
6104
6300
  setShowCenterPlay(true);
6105
6301
  } else {
6106
6302
  setShowCenterPlay(false);