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.
@@ -2803,6 +2803,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
2803
2803
  this.maxTotalAdRequestsPerBreak = 20;
2804
2804
  this.pendingAdBreak = null;
2805
2805
  this.savedMutedStateBeforeAd = null;
2806
+ this.adLayerInitialized = false;
2806
2807
  this.consecutiveFailures = 0;
2807
2808
  this.maxConsecutiveFailures = 5;
2808
2809
  this.lastAdRequestTime = 0;
@@ -3451,12 +3452,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3451
3452
  this.video.autoplay = !!this.config.autoplay;
3452
3453
  this.video.muted = !!this.config.muted;
3453
3454
  if (!this.config.disableAds) {
3454
- this.adLayer.initialize();
3455
- if (!this.config.disableFiller) {
3456
- this.ensureFillerVideo();
3457
- }
3458
- this.adLayer.updateOriginalMutedState(this.video.muted, this.video.volume);
3459
- this.attachAdLayerEventListeners();
3455
+ this.initializeAdLayer();
3460
3456
  }
3461
3457
  this.timeUpdateHandler = function() {
3462
3458
  _this.onTimeUpdate(_this.video.currentTime);
@@ -3557,6 +3553,31 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3557
3553
  return this.showAds;
3558
3554
  }
3559
3555
  },
3556
+ {
3557
+ key: "initializeAdLayer",
3558
+ value: function initializeAdLayer() {
3559
+ if (this.adLayerInitialized) return;
3560
+ this.adLayer.initialize();
3561
+ if (!this.config.disableFiller) {
3562
+ this.ensureFillerVideo();
3563
+ }
3564
+ this.adLayer.updateOriginalMutedState(this.video.muted, this.video.volume);
3565
+ this.attachAdLayerEventListeners();
3566
+ this.adLayerInitialized = true;
3567
+ }
3568
+ },
3569
+ {
3570
+ key: "setDisableAds",
3571
+ value: function setDisableAds(disabled) {
3572
+ this.config.disableAds = disabled;
3573
+ if (!disabled && this.attached) {
3574
+ this.initializeAdLayer();
3575
+ }
3576
+ if (this.config.debugAdTiming) {
3577
+ console.log("[StormcloudVideoPlayer] setDisableAds:", disabled);
3578
+ }
3579
+ }
3580
+ },
3560
3581
  {
3561
3582
  key: "syncMainContentAudioWhenVisible",
3562
3583
  value: function syncMainContentAudioWhenVisible() {
@@ -4081,14 +4102,21 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4081
4102
  }
4082
4103
  }
4083
4104
  },
4105
+ {
4106
+ key: "extractTsFilename",
4107
+ value: function extractTsFilename(url) {
4108
+ var _parts_;
4109
+ var clean = url.includes("?") ? url.slice(0, url.indexOf("?")) : url;
4110
+ var parts = clean.split("/");
4111
+ return (_parts_ = parts[parts.length - 1]) !== null && _parts_ !== void 0 ? _parts_ : clean;
4112
+ }
4113
+ },
4084
4114
  {
4085
4115
  key: "fragmentMatchesSegment",
4086
4116
  value: function fragmentMatchesSegment(frag, segmentName) {
4087
- var _rawUrl_split_;
4088
4117
  var rawUrl = (frag === null || frag === void 0 ? void 0 : frag.url) || (frag === null || frag === void 0 ? void 0 : frag.relurl) || "";
4089
- var url = (_rawUrl_split_ = rawUrl.split("?")[0]) !== null && _rawUrl_split_ !== void 0 ? _rawUrl_split_ : "";
4090
- var name = segmentName.startsWith("/") ? segmentName : "/" + segmentName;
4091
- return url.endsWith(name) || url.includes(name);
4118
+ if (!rawUrl) return false;
4119
+ return this.extractTsFilename(rawUrl) === this.extractTsFilename(segmentName);
4092
4120
  }
4093
4121
  },
4094
4122
  {