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.cjs CHANGED
@@ -336,6 +336,20 @@ function _ts_generator(thisArg, body) {
336
336
  };
337
337
  }
338
338
  }
339
+ function _ts_values(o) {
340
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
341
+ if (m) return m.call(o);
342
+ if (o && typeof o.length === "number") return {
343
+ next: function() {
344
+ if (o && i >= o.length) o = void 0;
345
+ return {
346
+ value: o && o[i++],
347
+ done: !o
348
+ };
349
+ }
350
+ };
351
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
352
+ }
339
353
  var __create = Object.create;
340
354
  var __defProp = Object.defineProperty;
341
355
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -1455,6 +1469,7 @@ function createImaController(video, options) {
1455
1469
  },
1456
1470
  showPlaceholder: function showPlaceholder() {
1457
1471
  ensurePlaceholderContainer();
1472
+ hideContentVideo();
1458
1473
  if (adContainerEl) {
1459
1474
  adContainerEl.style.display = "flex";
1460
1475
  adContainerEl.style.backgroundColor = "#000";
@@ -1474,6 +1489,9 @@ function createImaController(video, options) {
1474
1489
  }
1475
1490
  }, 300);
1476
1491
  }
1492
+ if (!adPlaying) {
1493
+ showContentVideo();
1494
+ }
1477
1495
  }
1478
1496
  };
1479
1497
  }
@@ -2248,6 +2266,8 @@ function createHlsAdPlayer(contentVideo, options) {
2248
2266
  return 1;
2249
2267
  },
2250
2268
  showPlaceholder: function showPlaceholder() {
2269
+ contentVideo.style.opacity = "0";
2270
+ contentVideo.style.visibility = "hidden";
2251
2271
  if (!adContainerEl) {
2252
2272
  var _contentVideo_parentElement;
2253
2273
  var container = document.createElement("div");
@@ -2275,6 +2295,10 @@ function createHlsAdPlayer(contentVideo, options) {
2275
2295
  adContainerEl.style.display = "none";
2276
2296
  adContainerEl.style.pointerEvents = "none";
2277
2297
  }
2298
+ if (!adPlaying) {
2299
+ contentVideo.style.visibility = "visible";
2300
+ contentVideo.style.opacity = "1";
2301
+ }
2278
2302
  }
2279
2303
  };
2280
2304
  }
@@ -2929,6 +2953,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
2929
2953
  this.maxPlaceholderDurationMs = 5e3;
2930
2954
  this.placeholderStartTimeMs = null;
2931
2955
  this.isShowingPlaceholder = false;
2956
+ this.consecutiveEmptyResponses = 0;
2957
+ this.totalAdRequestsInBreak = 0;
2958
+ this.lastEmptyResponseTimeMs = 0;
2959
+ this.maxTotalAdRequestsPerBreak = 20;
2960
+ this.maxConsecutiveEmptyResponses = 5;
2961
+ this.baseEmptyResponseDelayMs = 2e3;
2962
+ this.maxEmptyResponseDelayMs = 3e4;
2932
2963
  initializePolyfills();
2933
2964
  var browserOverrides = getBrowserConfigOverrides();
2934
2965
  this.config = _object_spread({}, config, browserOverrides);
@@ -3118,6 +3149,87 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3118
3149
  });
3119
3150
  }).call(_this);
3120
3151
  });
3152
+ this.hls.on(import_hls2.default.Events.LEVEL_LOADED, function(_evt, data) {
3153
+ if (_this.inAdBreak) {
3154
+ return;
3155
+ }
3156
+ var details = data === null || data === void 0 ? void 0 : data.details;
3157
+ if (!details || !details.fragments || details.fragments.length === 0) {
3158
+ return;
3159
+ }
3160
+ var fragmentsToScan = Math.min(5, details.fragments.length);
3161
+ for(var i = 0; i < fragmentsToScan; i++){
3162
+ var frag = details.fragments[i];
3163
+ var tagList = frag === null || frag === void 0 ? void 0 : frag.tagList;
3164
+ if (!Array.isArray(tagList)) continue;
3165
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
3166
+ try {
3167
+ for(var _iterator = tagList[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
3168
+ var entry = _step.value;
3169
+ var tag = "";
3170
+ var value = "";
3171
+ if (Array.isArray(entry)) {
3172
+ var _entry_;
3173
+ tag = String((_entry_ = entry[0]) !== null && _entry_ !== void 0 ? _entry_ : "");
3174
+ var _entry_1;
3175
+ value = String((_entry_1 = entry[1]) !== null && _entry_1 !== void 0 ? _entry_1 : "");
3176
+ } else if (typeof entry === "string") {
3177
+ var idx = entry.indexOf(":");
3178
+ if (idx >= 0) {
3179
+ tag = entry.substring(0, idx);
3180
+ value = entry.substring(idx + 1);
3181
+ } else {
3182
+ tag = entry;
3183
+ }
3184
+ }
3185
+ if (!tag) continue;
3186
+ if (tag.includes("EXT-X-CUE-OUT") || tag.includes("EXT-X-DATERANGE")) {
3187
+ var attrs = tag.includes("EXT-X-DATERANGE") ? _this.parseAttributeList(value) : {};
3188
+ var hasScteOut = tag.includes("EXT-X-CUE-OUT") || "SCTE35-OUT" in attrs || attrs["SCTE35-OUT"] !== void 0;
3189
+ if (hasScteOut) {
3190
+ if (_this.config.debugAdTiming) {
3191
+ console.log("[StormcloudVideoPlayer] \uD83C\uDFAF EARLY SCTE-35 DETECTION: Ad break marker found in fragment", i, "- triggering ad handling immediately");
3192
+ }
3193
+ var durationSeconds = _this.parseCueOutDuration(value);
3194
+ var marker = _object_spread_props(_object_spread({
3195
+ type: "start"
3196
+ }, durationSeconds !== void 0 ? {
3197
+ durationSeconds: durationSeconds
3198
+ } : {}), {
3199
+ raw: {
3200
+ tag: tag,
3201
+ value: value,
3202
+ earlyDetection: true
3203
+ }
3204
+ });
3205
+ _this.inAdBreak = true;
3206
+ _this.expectedAdBreakDurationMs = durationSeconds ? durationSeconds * 1e3 : void 0;
3207
+ _this.currentAdBreakStartWallClockMs = Date.now();
3208
+ _this.clearAdStartTimer();
3209
+ _this.handleAdStart(marker);
3210
+ if (_this.expectedAdBreakDurationMs != null) {
3211
+ _this.scheduleAdStopCountdown(_this.expectedAdBreakDurationMs);
3212
+ }
3213
+ return;
3214
+ }
3215
+ }
3216
+ }
3217
+ } catch (err) {
3218
+ _didIteratorError = true;
3219
+ _iteratorError = err;
3220
+ } finally{
3221
+ try {
3222
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
3223
+ _iterator.return();
3224
+ }
3225
+ } finally{
3226
+ if (_didIteratorError) {
3227
+ throw _iteratorError;
3228
+ }
3229
+ }
3230
+ }
3231
+ }
3232
+ });
3121
3233
  this.hls.on(import_hls2.default.Events.FRAG_BUFFERED, function(_evt, data) {
3122
3234
  return _async_to_generator(function() {
3123
3235
  var _this, _this_config_minSegmentsBeforePlay, minSegments, _this_video_play;
@@ -3325,11 +3437,16 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3325
3437
  this.ima.initialize();
3326
3438
  this.ima.updateOriginalMutedState(this.video.muted, this.video.volume);
3327
3439
  this.ima.on("all_ads_completed", function() {
3440
+ var remaining = _this.getRemainingAdMs();
3328
3441
  if (_this.config.debugAdTiming) {
3329
- console.log("[StormcloudVideoPlayer] IMA all_ads_completed event received - ending ad break");
3442
+ console.log("[StormcloudVideoPlayer] IMA all_ads_completed event received - remaining=".concat(remaining, "ms, queued ads=").concat(_this.adRequestQueue.length));
3330
3443
  }
3331
3444
  if (_this.inAdBreak) {
3332
- _this.handleAdPodComplete();
3445
+ if (remaining > 500) {
3446
+ _this.tryNextAvailableAd();
3447
+ } else {
3448
+ _this.handleAdPodComplete();
3449
+ }
3333
3450
  }
3334
3451
  });
3335
3452
  this.ima.on("ad_error", function(errorPayload) {
@@ -4124,6 +4241,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4124
4241
  this.continuousFetchingActive = true;
4125
4242
  this.isShowingPlaceholder = false;
4126
4243
  this.placeholderStartTimeMs = null;
4244
+ this.consecutiveEmptyResponses = 0;
4245
+ this.totalAdRequestsInBreak = 0;
4246
+ this.lastEmptyResponseTimeMs = 0;
4127
4247
  currentMuted = this.video.muted;
4128
4248
  currentVolume = this.video.volume;
4129
4249
  this.ima.updateOriginalMutedState(currentMuted, currentVolume);
@@ -4131,6 +4251,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4131
4251
  this.currentAdIndex = 0;
4132
4252
  this.totalAdsInBreak = 1;
4133
4253
  this.adPodQueue = [];
4254
+ this.showAds = true;
4255
+ this.ima.showPlaceholder();
4134
4256
  if (this.expectedAdBreakDurationMs == null && adBreakDurationMs != null) {
4135
4257
  this.expectedAdBreakDurationMs = adBreakDurationMs;
4136
4258
  this.currentAdBreakStartWallClockMs = Date.now();
@@ -4217,158 +4339,200 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4217
4339
  key: "continuousFetchLoop",
4218
4340
  value: function continuousFetchLoop(baseVastUrl) {
4219
4341
  return _async_to_generator(function() {
4220
- var remaining, maxQueueSize, newAdUrl, response, xmlText, parser, xmlDoc, mediaFiles, error;
4342
+ var _this, _loop, _ret;
4221
4343
  return _ts_generator(this, function(_state) {
4222
4344
  switch(_state.label){
4223
4345
  case 0:
4224
- if (!(this.continuousFetchingActive && this.inAdBreak)) return [
4225
- 3,
4226
- 14
4227
- ];
4228
- remaining = this.getRemainingAdMs();
4229
- if (remaining <= 0) {
4230
- if (this.config.debugAdTiming) {
4231
- console.log("[CONTINUOUS-FETCH] \u23F9\uFE0F Ad break time expired, stopping fetch loop");
4232
- }
4233
- return [
4234
- 3,
4235
- 14
4236
- ];
4237
- }
4238
- maxQueueSize = 3;
4239
- if (!(this.adRequestQueue.length >= maxQueueSize)) return [
4240
- 3,
4241
- 2
4242
- ];
4243
- if (this.config.debugAdTiming) {
4244
- console.log("[CONTINUOUS-FETCH] ⏸️ Queue full (".concat(this.adRequestQueue.length, "), pausing fetching..."));
4245
- }
4246
- return [
4247
- 4,
4248
- new Promise(function(resolve) {
4249
- return setTimeout(resolve, 2e3);
4250
- })
4251
- ];
4346
+ _loop = function() {
4347
+ var remaining, maxQueueSize, newAdUrl, _this_ima_hasPreloadedAd, _this_ima, _this_ima_hasPreloadedAd1, hasPreloadedAd, backoffDelay, error, backoffDelay1;
4348
+ return _ts_generator(this, function(_state) {
4349
+ switch(_state.label){
4350
+ case 0:
4351
+ remaining = _this.getRemainingAdMs();
4352
+ if (remaining <= 0) {
4353
+ if (_this.config.debugAdTiming) {
4354
+ console.log("[CONTINUOUS-FETCH] \u23F9\uFE0F Ad break time expired, stopping fetch loop");
4355
+ }
4356
+ return [
4357
+ 2,
4358
+ "break"
4359
+ ];
4360
+ }
4361
+ if (_this.totalAdRequestsInBreak >= _this.maxTotalAdRequestsPerBreak) {
4362
+ if (_this.config.debugAdTiming) {
4363
+ console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Maximum ad requests reached (".concat(_this.maxTotalAdRequestsPerBreak, "), stopping fetch loop to prevent server blocks"));
4364
+ }
4365
+ return [
4366
+ 2,
4367
+ "break"
4368
+ ];
4369
+ }
4370
+ if (_this.consecutiveEmptyResponses >= _this.maxConsecutiveEmptyResponses) {
4371
+ if (_this.config.debugAdTiming) {
4372
+ console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Too many consecutive empty responses (".concat(_this.maxConsecutiveEmptyResponses, "), stopping fetch loop"));
4373
+ }
4374
+ return [
4375
+ 2,
4376
+ "break"
4377
+ ];
4378
+ }
4379
+ maxQueueSize = 3;
4380
+ if (!(_this.adRequestQueue.length >= maxQueueSize)) return [
4381
+ 3,
4382
+ 2
4383
+ ];
4384
+ if (_this.config.debugAdTiming) {
4385
+ console.log("[CONTINUOUS-FETCH] ⏸️ Queue full (".concat(_this.adRequestQueue.length, "), pausing fetching..."));
4386
+ }
4387
+ return [
4388
+ 4,
4389
+ new Promise(function(resolve) {
4390
+ return setTimeout(resolve, 2e3);
4391
+ })
4392
+ ];
4393
+ case 1:
4394
+ _state.sent();
4395
+ return [
4396
+ 2,
4397
+ "continue"
4398
+ ];
4399
+ case 2:
4400
+ newAdUrl = _this.generateVastUrlsWithCorrelators(baseVastUrl, 1)[0];
4401
+ if (!(!newAdUrl || _this.failedVastUrls.has(newAdUrl))) return [
4402
+ 3,
4403
+ 4
4404
+ ];
4405
+ return [
4406
+ 4,
4407
+ new Promise(function(resolve) {
4408
+ return setTimeout(resolve, 1e3);
4409
+ })
4410
+ ];
4411
+ case 3:
4412
+ _state.sent();
4413
+ return [
4414
+ 2,
4415
+ "continue"
4416
+ ];
4417
+ case 4:
4418
+ _this.totalAdRequestsInBreak++;
4419
+ if (_this.config.debugAdTiming) {
4420
+ console.log("[CONTINUOUS-FETCH] \uD83D\uDCE1 Attempting to fetch ad (request ".concat(_this.totalAdRequestsInBreak, "/").concat(_this.maxTotalAdRequestsPerBreak, ", queue: ").concat(_this.adRequestQueue.length, ")..."));
4421
+ }
4422
+ _state.label = 5;
4423
+ case 5:
4424
+ _state.trys.push([
4425
+ 5,
4426
+ 11,
4427
+ ,
4428
+ 13
4429
+ ]);
4430
+ if (!_this.ima.preloadAds) return [
4431
+ 3,
4432
+ 7
4433
+ ];
4434
+ return [
4435
+ 4,
4436
+ _this.ima.preloadAds(newAdUrl)
4437
+ ];
4438
+ case 6:
4439
+ _state.sent();
4440
+ _state.label = 7;
4441
+ case 7:
4442
+ 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;
4443
+ if (!!hasPreloadedAd) return [
4444
+ 3,
4445
+ 9
4446
+ ];
4447
+ _this.consecutiveEmptyResponses++;
4448
+ _this.lastEmptyResponseTimeMs = Date.now();
4449
+ backoffDelay = Math.min(_this.baseEmptyResponseDelayMs * Math.pow(2, _this.consecutiveEmptyResponses - 1), _this.maxEmptyResponseDelayMs);
4450
+ if (_this.config.debugAdTiming) {
4451
+ console.log("[CONTINUOUS-FETCH] ⚠️ Empty/invalid VAST response (".concat(_this.consecutiveEmptyResponses, "/").concat(_this.maxConsecutiveEmptyResponses, " consecutive), backing off for ").concat(backoffDelay, "ms"));
4452
+ }
4453
+ _this.failedVastUrls.add(newAdUrl);
4454
+ return [
4455
+ 4,
4456
+ new Promise(function(resolve) {
4457
+ return setTimeout(resolve, backoffDelay);
4458
+ })
4459
+ ];
4460
+ case 8:
4461
+ _state.sent();
4462
+ return [
4463
+ 2,
4464
+ "continue"
4465
+ ];
4466
+ case 9:
4467
+ _this.consecutiveEmptyResponses = 0;
4468
+ if (_this.config.debugAdTiming) {
4469
+ console.log("[CONTINUOUS-FETCH] ✅ Successfully preloaded ad, adding to queue (queue size: ".concat(_this.adRequestQueue.length + 1, ")"));
4470
+ }
4471
+ _this.adRequestQueue.push(newAdUrl);
4472
+ _this.totalAdsInBreak++;
4473
+ return [
4474
+ 4,
4475
+ new Promise(function(resolve) {
4476
+ return setTimeout(resolve, 500);
4477
+ })
4478
+ ];
4479
+ case 10:
4480
+ _state.sent();
4481
+ return [
4482
+ 3,
4483
+ 13
4484
+ ];
4485
+ case 11:
4486
+ error = _state.sent();
4487
+ if (_this.config.debugAdTiming) {
4488
+ console.log("[CONTINUOUS-FETCH] \u274C Ad preload failed:", error.message);
4489
+ }
4490
+ _this.failedVastUrls.add(newAdUrl);
4491
+ _this.consecutiveEmptyResponses++;
4492
+ backoffDelay1 = Math.min(_this.baseEmptyResponseDelayMs * Math.pow(2, _this.consecutiveEmptyResponses - 1), _this.maxEmptyResponseDelayMs);
4493
+ return [
4494
+ 4,
4495
+ new Promise(function(resolve) {
4496
+ return setTimeout(resolve, backoffDelay1);
4497
+ })
4498
+ ];
4499
+ case 12:
4500
+ _state.sent();
4501
+ return [
4502
+ 3,
4503
+ 13
4504
+ ];
4505
+ case 13:
4506
+ return [
4507
+ 2
4508
+ ];
4509
+ }
4510
+ });
4511
+ };
4512
+ _state.label = 1;
4252
4513
  case 1:
4253
- _state.sent();
4254
- return [
4255
- 3,
4256
- 0
4257
- ];
4258
- case 2:
4259
- newAdUrl = this.generateVastUrlsWithCorrelators(baseVastUrl, 1)[0];
4260
- if (!(!newAdUrl || this.failedVastUrls.has(newAdUrl))) return [
4514
+ if (!(this.continuousFetchingActive && this.inAdBreak)) return [
4261
4515
  3,
4262
- 4
4516
+ 3
4263
4517
  ];
4518
+ _this = this;
4264
4519
  return [
4265
- 4,
4266
- new Promise(function(resolve) {
4267
- return setTimeout(resolve, 1e3);
4268
- })
4269
- ];
4270
- case 3:
4271
- _state.sent();
4272
- return [
4273
- 3,
4274
- 0
4275
- ];
4276
- case 4:
4277
- if (this.config.debugAdTiming) {
4278
- console.log("[CONTINUOUS-FETCH] \uD83D\uDCE1 Attempting to fetch ad (".concat(this.successfulAdRequests.length + this.adRequestQueue.length + 1, " total)..."));
4279
- }
4280
- _state.label = 5;
4281
- case 5:
4282
- _state.trys.push([
4283
4520
  5,
4284
- 11,
4285
- ,
4286
- 13
4287
- ]);
4288
- return [
4289
- 4,
4290
- fetch(newAdUrl, {
4291
- mode: "cors"
4292
- })
4293
- ];
4294
- case 6:
4295
- response = _state.sent();
4296
- if (!response.ok) {
4297
- throw new Error("Failed to fetch VAST: ".concat(response.status));
4298
- }
4299
- return [
4300
- 4,
4301
- response.text()
4302
- ];
4303
- case 7:
4304
- xmlText = _state.sent();
4305
- parser = new DOMParser();
4306
- xmlDoc = parser.parseFromString(xmlText, "text/xml");
4307
- mediaFiles = xmlDoc.querySelectorAll("MediaFile");
4308
- if (!(mediaFiles.length === 0)) return [
4309
- 3,
4310
- 9
4311
- ];
4312
- if (this.config.debugAdTiming) {
4313
- console.log("[CONTINUOUS-FETCH] \u26A0\uFE0F VAST response has no media files, skipping");
4314
- }
4315
- this.failedVastUrls.add(newAdUrl);
4316
- return [
4317
- 4,
4318
- new Promise(function(resolve) {
4319
- return setTimeout(resolve, 1e3);
4320
- })
4521
+ _ts_values(_loop())
4321
4522
  ];
4322
- case 8:
4323
- _state.sent();
4324
- return [
4325
- 3,
4326
- 0
4327
- ];
4328
- case 9:
4329
- if (this.config.debugAdTiming) {
4330
- console.log("[CONTINUOUS-FETCH] ✅ Successfully fetched ad, adding to queue (queue size: ".concat(this.adRequestQueue.length + 1, ")"));
4331
- }
4332
- this.adRequestQueue.push(newAdUrl);
4333
- this.totalAdsInBreak++;
4334
- return [
4335
- 4,
4336
- new Promise(function(resolve) {
4337
- return setTimeout(resolve, 500);
4338
- })
4339
- ];
4340
- case 10:
4341
- _state.sent();
4342
- return [
4343
- 3,
4344
- 13
4345
- ];
4346
- case 11:
4347
- error = _state.sent();
4348
- if (this.config.debugAdTiming) {
4349
- console.log("[CONTINUOUS-FETCH] \u274C Ad fetch failed:", error.message);
4350
- }
4351
- this.failedVastUrls.add(newAdUrl);
4352
- return [
4353
- 4,
4354
- new Promise(function(resolve) {
4355
- return setTimeout(resolve, 2e3);
4356
- })
4357
- ];
4358
- case 12:
4359
- _state.sent();
4360
- return [
4523
+ case 2:
4524
+ _ret = _state.sent();
4525
+ if (_ret === "break") return [
4361
4526
  3,
4362
- 13
4527
+ 3
4363
4528
  ];
4364
- case 13:
4365
4529
  return [
4366
4530
  3,
4367
- 0
4531
+ 1
4368
4532
  ];
4369
- case 14:
4533
+ case 3:
4370
4534
  if (this.config.debugAdTiming) {
4371
- console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Continuous fetch loop ended");
4535
+ console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Continuous fetch loop ended (total requests: ".concat(this.totalAdRequestsInBreak, ", empty responses: ").concat(this.consecutiveEmptyResponses, ")"));
4372
4536
  }
4373
4537
  return [
4374
4538
  2
@@ -6136,11 +6300,17 @@ var StormcloudVideoPlayerComponent = import_react.default.memo(function(props) {
6136
6300
  if (!playerRef.current) return;
6137
6301
  var checkAdStatus = function() {
6138
6302
  if (playerRef.current) {
6139
- var showAds = playerRef.current.isShowingAds();
6303
+ var _videoRef_current_dataset, _videoRef_current;
6304
+ var showAdsFromMethod = playerRef.current.isShowingAds();
6305
+ 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";
6306
+ var showAds = showAdsFromMethod || showAdsFromAttribute;
6140
6307
  var currentIndex = playerRef.current.getCurrentAdIndex();
6141
6308
  var totalAds = playerRef.current.getTotalAdsInBreak();
6142
6309
  setAdStatus(function(prev) {
6143
6310
  if (prev.showAds !== showAds || prev.currentIndex !== currentIndex || prev.totalAds !== totalAds) {
6311
+ if (showAds && !prev.showAds) {
6312
+ setShowCenterPlay(false);
6313
+ }
6144
6314
  return {
6145
6315
  showAds: showAds,
6146
6316
  currentIndex: currentIndex,
@@ -6151,7 +6321,7 @@ var StormcloudVideoPlayerComponent = import_react.default.memo(function(props) {
6151
6321
  });
6152
6322
  }
6153
6323
  };
6154
- var interval = setInterval(checkAdStatus, 100);
6324
+ var interval = setInterval(checkAdStatus, 50);
6155
6325
  return function() {
6156
6326
  return clearInterval(interval);
6157
6327
  };
@@ -6279,7 +6449,9 @@ var StormcloudVideoPlayerComponent = import_react.default.memo(function(props) {
6279
6449
  }
6280
6450
  };
6281
6451
  var handlePause = function() {
6282
- if (playerRef.current && !playerRef.current.isShowingAds()) {
6452
+ var _playerRef_current, _videoRef_current_dataset, _videoRef_current;
6453
+ 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";
6454
+ if (playerRef.current && !isAdActive) {
6283
6455
  setShowCenterPlay(true);
6284
6456
  } else {
6285
6457
  setShowCenterPlay(false);