stormcloud-video-player 0.7.13 → 0.7.16

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.
@@ -2715,6 +2715,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
2715
2715
  this.maxTotalAdRequestsPerBreak = 20;
2716
2716
  this.pendingAdBreak = null;
2717
2717
  this.savedMutedStateBeforeAd = null;
2718
+ this.adLayerInitialized = false;
2718
2719
  this.consecutiveFailures = 0;
2719
2720
  this.maxConsecutiveFailures = 5;
2720
2721
  this.lastAdRequestTime = 0;
@@ -3363,12 +3364,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3363
3364
  this.video.autoplay = !!this.config.autoplay;
3364
3365
  this.video.muted = !!this.config.muted;
3365
3366
  if (!this.config.disableAds) {
3366
- this.adLayer.initialize();
3367
- if (!this.config.disableFiller) {
3368
- this.ensureFillerVideo();
3369
- }
3370
- this.adLayer.updateOriginalMutedState(this.video.muted, this.video.volume);
3371
- this.attachAdLayerEventListeners();
3367
+ this.initializeAdLayer();
3372
3368
  }
3373
3369
  this.timeUpdateHandler = function() {
3374
3370
  _this.onTimeUpdate(_this.video.currentTime);
@@ -3469,6 +3465,31 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3469
3465
  return this.showAds;
3470
3466
  }
3471
3467
  },
3468
+ {
3469
+ key: "initializeAdLayer",
3470
+ value: function initializeAdLayer() {
3471
+ if (this.adLayerInitialized) return;
3472
+ this.adLayer.initialize();
3473
+ if (!this.config.disableFiller) {
3474
+ this.ensureFillerVideo();
3475
+ }
3476
+ this.adLayer.updateOriginalMutedState(this.video.muted, this.video.volume);
3477
+ this.attachAdLayerEventListeners();
3478
+ this.adLayerInitialized = true;
3479
+ }
3480
+ },
3481
+ {
3482
+ key: "setDisableAds",
3483
+ value: function setDisableAds(disabled) {
3484
+ this.config.disableAds = disabled;
3485
+ if (!disabled && this.attached) {
3486
+ this.initializeAdLayer();
3487
+ }
3488
+ if (this.config.debugAdTiming) {
3489
+ console.log("[StormcloudVideoPlayer] setDisableAds:", disabled);
3490
+ }
3491
+ }
3492
+ },
3472
3493
  {
3473
3494
  key: "syncMainContentAudioWhenVisible",
3474
3495
  value: function syncMainContentAudioWhenVisible() {
@@ -3993,14 +4014,21 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3993
4014
  }
3994
4015
  }
3995
4016
  },
4017
+ {
4018
+ key: "extractTsFilename",
4019
+ value: function extractTsFilename(url) {
4020
+ var _parts_;
4021
+ var clean = url.includes("?") ? url.slice(0, url.indexOf("?")) : url;
4022
+ var parts = clean.split("/");
4023
+ return (_parts_ = parts[parts.length - 1]) !== null && _parts_ !== void 0 ? _parts_ : clean;
4024
+ }
4025
+ },
3996
4026
  {
3997
4027
  key: "fragmentMatchesSegment",
3998
4028
  value: function fragmentMatchesSegment(frag, segmentName) {
3999
- var _rawUrl_split_;
4000
4029
  var rawUrl = (frag === null || frag === void 0 ? void 0 : frag.url) || (frag === null || frag === void 0 ? void 0 : frag.relurl) || "";
4001
- var url = (_rawUrl_split_ = rawUrl.split("?")[0]) !== null && _rawUrl_split_ !== void 0 ? _rawUrl_split_ : "";
4002
- var name = segmentName.startsWith("/") ? segmentName : "/" + segmentName;
4003
- return url.endsWith(name) || url.includes(name);
4030
+ if (!rawUrl) return false;
4031
+ return this.extractTsFilename(rawUrl) === this.extractTsFilename(segmentName);
4004
4032
  }
4005
4033
  },
4006
4034
  {