stormcloud-video-player 0.5.7 → 0.5.8

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.
@@ -526,8 +526,8 @@ function createEmptyTrackingState() {
526
526
  complete: false
527
527
  };
528
528
  }
529
- function fireTrackingPixels(urls, sessionId, licenseKey) {
530
- var logPrefix = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : "[VastParser]";
529
+ function fireTrackingPixels(urls, sessionId) {
530
+ var logPrefix = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "[VastParser]";
531
531
  if (!urls || urls.length === 0) return;
532
532
  urls.forEach(function(url) {
533
533
  try {
@@ -535,10 +535,8 @@ function fireTrackingPixels(urls, sessionId, licenseKey) {
535
535
  if (sessionId) {
536
536
  trackingUrl = "".concat(trackingUrl).concat(trackingUrl.includes("?") ? "&" : "?", "session_id=").concat(sessionId);
537
537
  }
538
- if (licenseKey) {
539
- trackingUrl = "".concat(trackingUrl).concat(trackingUrl.includes("?") ? "&" : "?", "license_key=").concat(licenseKey);
540
- }
541
538
  var img = new Image(1, 1);
539
+ img.onerror = function() {};
542
540
  img.src = trackingUrl;
543
541
  console.log("".concat(logPrefix, " Fired tracking pixel: ").concat(trackingUrl));
544
542
  } catch (error) {
@@ -939,7 +937,7 @@ function createPrebidController(contentVideo, options) {
939
937
  return "session-".concat(Date.now(), "-").concat(Math.random().toString(36).substr(2, 9));
940
938
  }
941
939
  function fireTrackingPixels2(urls) {
942
- fireTrackingPixels(urls, sessionId, licenseKey, LOG);
940
+ fireTrackingPixels(urls, sessionId, LOG);
943
941
  }
944
942
  function getMainStreamQuality() {
945
943
  if (!mainHlsInstance || !mainHlsInstance.levels) {
@@ -2676,6 +2674,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
2676
2674
  this.totalAdRequestsInBreak = 0;
2677
2675
  this.maxTotalAdRequestsPerBreak = 20;
2678
2676
  this.pendingAdBreak = null;
2677
+ this.prefetchAdPromise = null;
2678
+ this.savedMutedStateBeforeScte = null;
2679
2679
  this.consecutiveFailures = 0;
2680
2680
  this.maxConsecutiveFailures = 5;
2681
2681
  this.lastAdRequestTime = 0;
@@ -3151,6 +3151,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3151
3151
  }
3152
3152
  }
3153
3153
  console.error("[AD-ERROR]", errorMessage, errorPayload || "");
3154
+ _this.adController.stop().catch(function() {});
3154
3155
  _this.handleAdFailure();
3155
3156
  });
3156
3157
  this.adController.on("content_pause", function() {
@@ -3213,6 +3214,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3213
3214
  {
3214
3215
  key: "recreateAdController",
3215
3216
  value: function recreateAdController() {
3217
+ this.prefetchAdPromise = null;
3216
3218
  var shouldShowPlaceholder = this.inAdBreak && this.showAds;
3217
3219
  if (shouldShowPlaceholder && this.adController) {
3218
3220
  this.showPlaceholderLayer();
@@ -3541,6 +3543,11 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3541
3543
  if (marker.type === "start") {
3542
3544
  var _this_config_immediateManifestAds;
3543
3545
  var _this_pendingAdBreak;
3546
+ this.savedMutedStateBeforeScte = {
3547
+ muted: this.video.muted,
3548
+ volume: this.video.volume
3549
+ };
3550
+ this.adController.updateOriginalMutedState(this.video.muted, this.video.volume);
3544
3551
  if (!this.video.muted) {
3545
3552
  this.video.muted = true;
3546
3553
  this.video.volume = 0;
@@ -3982,6 +3989,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3982
3989
  {
3983
3990
  key: "startAdPrefetch",
3984
3991
  value: function startAdPrefetch(marker, fragmentSn) {
3992
+ var _this = this;
3985
3993
  if (this.pendingAdBreak || this.inAdBreak) {
3986
3994
  return;
3987
3995
  }
@@ -3993,8 +4001,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3993
4001
  isFetching: false,
3994
4002
  fetchStartTime: Date.now()
3995
4003
  });
4004
+ this.prefetchAdPromise = this.adController.requestAds().catch(function() {
4005
+ if (_this.config.debugAdTiming) {
4006
+ console.log("[PREFETCH] Prebid auction prefetch failed, will request at playback time");
4007
+ }
4008
+ });
3996
4009
  if (this.config.debugAdTiming) {
3997
- console.log("[PREFETCH] Ad break marker registered, auction runs at playback time via controller");
4010
+ console.log("[PREFETCH] Ad break marker registered, auction prefetch started");
3998
4011
  }
3999
4012
  }
4000
4013
  },
@@ -4005,6 +4018,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4005
4018
  clearTimeout(this.prefetchTimerId);
4006
4019
  this.prefetchTimerId = void 0;
4007
4020
  }
4021
+ this.prefetchAdPromise = null;
4008
4022
  this.pendingAdBreak = null;
4009
4023
  }
4010
4024
  },
@@ -4012,7 +4026,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4012
4026
  key: "handleAdStart",
4013
4027
  value: function handleAdStart(_marker) {
4014
4028
  return _async_to_generator(function() {
4015
- var adBreakDurationMs, mode, currentMuted, currentVolume, adLoadedInfo, adVolume, error;
4029
+ var _this_savedMutedStateBeforeScte, adBreakDurationMs, mode, state, unused, unused1, adLoadedInfo, adVolume, error;
4016
4030
  return _ts_generator(this, function(_state) {
4017
4031
  switch(_state.label){
4018
4032
  case 0:
@@ -4025,9 +4039,12 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4025
4039
  this.continuousFetchingActive = true;
4026
4040
  this.isShowingPlaceholder = false;
4027
4041
  this.totalAdRequestsInBreak = 0;
4028
- currentMuted = this.video.muted;
4029
- currentVolume = this.video.volume;
4030
- this.adController.updateOriginalMutedState(currentMuted, currentVolume);
4042
+ state = (_this_savedMutedStateBeforeScte = this.savedMutedStateBeforeScte) !== null && _this_savedMutedStateBeforeScte !== void 0 ? _this_savedMutedStateBeforeScte : {
4043
+ muted: this.video.muted,
4044
+ volume: this.video.volume
4045
+ };
4046
+ this.adController.updateOriginalMutedState(state.muted, state.volume);
4047
+ this.savedMutedStateBeforeScte = null;
4031
4048
  if (!this.video.muted) {
4032
4049
  this.video.muted = true;
4033
4050
  this.video.volume = 0;
@@ -4046,25 +4063,94 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4046
4063
  if (this.expectedAdBreakDurationMs == null && adBreakDurationMs != null) {
4047
4064
  this.expectedAdBreakDurationMs = adBreakDurationMs;
4048
4065
  }
4049
- this.clearPendingAdBreak();
4050
4066
  if (this.config.debugAdTiming) {
4051
- console.log("[CONTINUOUS-FETCH] \uD83D\uDCCB Prebid auction via requestAds()");
4067
+ console.log("[CONTINUOUS-FETCH] \uD83D\uDCCB Prebid auction (prefetch or requestAds)");
4052
4068
  }
4053
4069
  _state.label = 1;
4054
4070
  case 1:
4055
4071
  _state.trys.push([
4056
4072
  1,
4057
- 4,
4073
+ 6,
4058
4074
  ,
4059
- 6
4075
+ 12
4060
4076
  ]);
4061
4077
  this.lastAdRequestTime = Date.now();
4078
+ if (!this.prefetchAdPromise) return [
4079
+ 3,
4080
+ 3
4081
+ ];
4062
4082
  return [
4063
4083
  4,
4064
- this.adController.requestAds()
4084
+ this.prefetchAdPromise
4065
4085
  ];
4066
4086
  case 2:
4067
4087
  _state.sent();
4088
+ this.prefetchAdPromise = null;
4089
+ return [
4090
+ 3,
4091
+ 5
4092
+ ];
4093
+ case 3:
4094
+ return [
4095
+ 4,
4096
+ this.adController.requestAds()
4097
+ ];
4098
+ case 4:
4099
+ _state.sent();
4100
+ _state.label = 5;
4101
+ case 5:
4102
+ return [
4103
+ 3,
4104
+ 12
4105
+ ];
4106
+ case 6:
4107
+ unused = _state.sent();
4108
+ _state.label = 7;
4109
+ case 7:
4110
+ _state.trys.push([
4111
+ 7,
4112
+ 9,
4113
+ ,
4114
+ 11
4115
+ ]);
4116
+ return [
4117
+ 4,
4118
+ this.adController.requestAds()
4119
+ ];
4120
+ case 8:
4121
+ _state.sent();
4122
+ return [
4123
+ 3,
4124
+ 11
4125
+ ];
4126
+ case 9:
4127
+ unused1 = _state.sent();
4128
+ this.clearPendingAdBreak();
4129
+ this.consecutiveFailures++;
4130
+ return [
4131
+ 4,
4132
+ this.tryNextAvailableAdWithRateLimit()
4133
+ ];
4134
+ case 10:
4135
+ _state.sent();
4136
+ return [
4137
+ 2
4138
+ ];
4139
+ case 11:
4140
+ return [
4141
+ 3,
4142
+ 12
4143
+ ];
4144
+ case 12:
4145
+ this.clearPendingAdBreak();
4146
+ _state.label = 13;
4147
+ case 13:
4148
+ _state.trys.push([
4149
+ 13,
4150
+ 15,
4151
+ ,
4152
+ 17
4153
+ ]);
4068
4154
  if (this.config.licenseKey) {
4069
4155
  adLoadedInfo = {
4070
4156
  source: this.getAdSource(),
@@ -4081,19 +4167,19 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4081
4167
  4,
4082
4168
  this.adController.play()
4083
4169
  ];
4084
- case 3:
4170
+ case 14:
4085
4171
  _state.sent();
4086
4172
  if (this.expectedAdBreakDurationMs != null) {
4087
4173
  this.currentAdBreakStartWallClockMs = Date.now();
4088
4174
  this.scheduleAdStopCountdown(this.expectedAdBreakDurationMs);
4089
4175
  }
4090
- adVolume = currentMuted ? 0 : currentVolume;
4176
+ adVolume = state.muted ? 0 : state.volume;
4091
4177
  this.adController.setAdVolume(adVolume);
4092
4178
  return [
4093
4179
  3,
4094
- 6
4180
+ 17
4095
4181
  ];
4096
- case 4:
4182
+ case 15:
4097
4183
  error = _state.sent();
4098
4184
  if (this.config.debugAdTiming) {
4099
4185
  console.warn("[CONTINUOUS-FETCH] \u26A0\uFE0F First ad request failed:", error);
@@ -4103,13 +4189,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4103
4189
  4,
4104
4190
  this.tryNextAvailableAdWithRateLimit()
4105
4191
  ];
4106
- case 5:
4192
+ case 16:
4107
4193
  _state.sent();
4108
4194
  return [
4109
4195
  3,
4110
- 6
4196
+ 17
4111
4197
  ];
4112
- case 6:
4198
+ case 17:
4113
4199
  return [
4114
4200
  2
4115
4201
  ];