stormcloud-video-player 0.5.7 → 0.5.9
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/dist/stormcloud-vp.min.js +1 -1
- package/lib/index.cjs +117 -25
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +2 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +117 -25
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +117 -25
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/player/StormcloudVideoPlayer.d.cts +2 -0
- package/lib/players/HlsPlayer.cjs +117 -25
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/index.cjs +117 -25
- package/lib/players/index.cjs.map +1 -1
- package/lib/sdk/prebidController.cjs +4 -6
- package/lib/sdk/prebidController.cjs.map +1 -1
- package/lib/sdk/vastParser.cjs +3 -5
- package/lib/sdk/vastParser.cjs.map +1 -1
- package/lib/sdk/vastParser.d.cts +1 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +117 -25
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/package.json +1 -1
|
@@ -40,6 +40,8 @@ declare class StormcloudVideoPlayer {
|
|
|
40
40
|
private readonly maxTotalAdRequestsPerBreak;
|
|
41
41
|
private pendingAdBreak;
|
|
42
42
|
private prefetchTimerId;
|
|
43
|
+
private prefetchAdPromise;
|
|
44
|
+
private savedMutedStateBeforeScte;
|
|
43
45
|
private consecutiveFailures;
|
|
44
46
|
private readonly maxConsecutiveFailures;
|
|
45
47
|
private lastAdRequestTime;
|
|
@@ -578,8 +578,8 @@ function createEmptyTrackingState() {
|
|
|
578
578
|
complete: false
|
|
579
579
|
};
|
|
580
580
|
}
|
|
581
|
-
function fireTrackingPixels(urls, sessionId
|
|
582
|
-
var logPrefix = arguments.length >
|
|
581
|
+
function fireTrackingPixels(urls, sessionId) {
|
|
582
|
+
var logPrefix = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "[VastParser]";
|
|
583
583
|
if (!urls || urls.length === 0) return;
|
|
584
584
|
urls.forEach(function(url) {
|
|
585
585
|
try {
|
|
@@ -587,10 +587,8 @@ function fireTrackingPixels(urls, sessionId, licenseKey) {
|
|
|
587
587
|
if (sessionId) {
|
|
588
588
|
trackingUrl = "".concat(trackingUrl).concat(trackingUrl.includes("?") ? "&" : "?", "session_id=").concat(sessionId);
|
|
589
589
|
}
|
|
590
|
-
if (licenseKey) {
|
|
591
|
-
trackingUrl = "".concat(trackingUrl).concat(trackingUrl.includes("?") ? "&" : "?", "license_key=").concat(licenseKey);
|
|
592
|
-
}
|
|
593
590
|
var img = new Image(1, 1);
|
|
591
|
+
img.onerror = function() {};
|
|
594
592
|
img.src = trackingUrl;
|
|
595
593
|
console.log("".concat(logPrefix, " Fired tracking pixel: ").concat(trackingUrl));
|
|
596
594
|
} catch (error) {
|
|
@@ -991,7 +989,7 @@ function createPrebidController(contentVideo, options) {
|
|
|
991
989
|
return "session-".concat(Date.now(), "-").concat(Math.random().toString(36).substr(2, 9));
|
|
992
990
|
}
|
|
993
991
|
function fireTrackingPixels2(urls) {
|
|
994
|
-
fireTrackingPixels(urls, sessionId,
|
|
992
|
+
fireTrackingPixels(urls, sessionId, LOG);
|
|
995
993
|
}
|
|
996
994
|
function getMainStreamQuality() {
|
|
997
995
|
if (!mainHlsInstance || !mainHlsInstance.levels) {
|
|
@@ -2728,6 +2726,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
2728
2726
|
this.totalAdRequestsInBreak = 0;
|
|
2729
2727
|
this.maxTotalAdRequestsPerBreak = 20;
|
|
2730
2728
|
this.pendingAdBreak = null;
|
|
2729
|
+
this.prefetchAdPromise = null;
|
|
2730
|
+
this.savedMutedStateBeforeScte = null;
|
|
2731
2731
|
this.consecutiveFailures = 0;
|
|
2732
2732
|
this.maxConsecutiveFailures = 5;
|
|
2733
2733
|
this.lastAdRequestTime = 0;
|
|
@@ -3203,6 +3203,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3203
3203
|
}
|
|
3204
3204
|
}
|
|
3205
3205
|
console.error("[AD-ERROR]", errorMessage, errorPayload || "");
|
|
3206
|
+
_this.adController.stop().catch(function() {});
|
|
3206
3207
|
_this.handleAdFailure();
|
|
3207
3208
|
});
|
|
3208
3209
|
this.adController.on("content_pause", function() {
|
|
@@ -3245,6 +3246,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3245
3246
|
_this.activeAdRequestToken = null;
|
|
3246
3247
|
_this.showAds = false;
|
|
3247
3248
|
if (!_this.inAdBreak) {
|
|
3249
|
+
if (_this.config.debugAdTiming) {
|
|
3250
|
+
console.log("[StormcloudVideoPlayer] content_resume: break already ended (e.g. by CUE-IN or handleAdPodComplete), skipping next-ad path");
|
|
3251
|
+
}
|
|
3248
3252
|
return;
|
|
3249
3253
|
}
|
|
3250
3254
|
_this.consecutiveFailures = 0;
|
|
@@ -3257,6 +3261,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3257
3261
|
if (remaining > 500) {
|
|
3258
3262
|
_this.tryNextAvailableAdWithRateLimit();
|
|
3259
3263
|
} else {
|
|
3264
|
+
if (_this.config.debugAdTiming) {
|
|
3265
|
+
console.log("[StormcloudVideoPlayer] content_resume: remaining time too low to try next ad, ending ad pod");
|
|
3266
|
+
}
|
|
3260
3267
|
_this.handleAdPodComplete();
|
|
3261
3268
|
}
|
|
3262
3269
|
});
|
|
@@ -3265,6 +3272,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3265
3272
|
{
|
|
3266
3273
|
key: "recreateAdController",
|
|
3267
3274
|
value: function recreateAdController() {
|
|
3275
|
+
this.prefetchAdPromise = null;
|
|
3268
3276
|
var shouldShowPlaceholder = this.inAdBreak && this.showAds;
|
|
3269
3277
|
if (shouldShowPlaceholder && this.adController) {
|
|
3270
3278
|
this.showPlaceholderLayer();
|
|
@@ -3593,6 +3601,11 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3593
3601
|
if (marker.type === "start") {
|
|
3594
3602
|
var _this_config_immediateManifestAds;
|
|
3595
3603
|
var _this_pendingAdBreak;
|
|
3604
|
+
this.savedMutedStateBeforeScte = {
|
|
3605
|
+
muted: this.video.muted,
|
|
3606
|
+
volume: this.video.volume
|
|
3607
|
+
};
|
|
3608
|
+
this.adController.updateOriginalMutedState(this.video.muted, this.video.volume);
|
|
3596
3609
|
if (!this.video.muted) {
|
|
3597
3610
|
this.video.muted = true;
|
|
3598
3611
|
this.video.volume = 0;
|
|
@@ -3715,9 +3728,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3715
3728
|
activeAdRequest: this.activeAdRequestToken !== null
|
|
3716
3729
|
});
|
|
3717
3730
|
}
|
|
3718
|
-
if (adPlaying || remaining >
|
|
3731
|
+
if (adPlaying || remaining > 500) {
|
|
3719
3732
|
if (this.config.debugAdTiming) {
|
|
3720
|
-
console.log("[StormcloudVideoPlayer] Ignoring premature SCTE-35 end marker - ads still active");
|
|
3733
|
+
console.log("[StormcloudVideoPlayer] Ignoring premature SCTE-35 end marker - ads still active or time remaining");
|
|
3721
3734
|
}
|
|
3722
3735
|
return;
|
|
3723
3736
|
}
|
|
@@ -4034,6 +4047,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4034
4047
|
{
|
|
4035
4048
|
key: "startAdPrefetch",
|
|
4036
4049
|
value: function startAdPrefetch(marker, fragmentSn) {
|
|
4050
|
+
var _this = this;
|
|
4037
4051
|
if (this.pendingAdBreak || this.inAdBreak) {
|
|
4038
4052
|
return;
|
|
4039
4053
|
}
|
|
@@ -4045,8 +4059,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4045
4059
|
isFetching: false,
|
|
4046
4060
|
fetchStartTime: Date.now()
|
|
4047
4061
|
});
|
|
4062
|
+
this.prefetchAdPromise = this.adController.requestAds().catch(function() {
|
|
4063
|
+
if (_this.config.debugAdTiming) {
|
|
4064
|
+
console.log("[PREFETCH] Prebid auction prefetch failed, will request at playback time");
|
|
4065
|
+
}
|
|
4066
|
+
});
|
|
4048
4067
|
if (this.config.debugAdTiming) {
|
|
4049
|
-
console.log("[PREFETCH] Ad break marker registered, auction
|
|
4068
|
+
console.log("[PREFETCH] Ad break marker registered, auction prefetch started");
|
|
4050
4069
|
}
|
|
4051
4070
|
}
|
|
4052
4071
|
},
|
|
@@ -4057,6 +4076,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4057
4076
|
clearTimeout(this.prefetchTimerId);
|
|
4058
4077
|
this.prefetchTimerId = void 0;
|
|
4059
4078
|
}
|
|
4079
|
+
this.prefetchAdPromise = null;
|
|
4060
4080
|
this.pendingAdBreak = null;
|
|
4061
4081
|
}
|
|
4062
4082
|
},
|
|
@@ -4064,7 +4084,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4064
4084
|
key: "handleAdStart",
|
|
4065
4085
|
value: function handleAdStart(_marker) {
|
|
4066
4086
|
return _async_to_generator(function() {
|
|
4067
|
-
var adBreakDurationMs, mode,
|
|
4087
|
+
var _this_savedMutedStateBeforeScte, adBreakDurationMs, mode, state, unused, unused1, adLoadedInfo, adVolume, error;
|
|
4068
4088
|
return _ts_generator(this, function(_state) {
|
|
4069
4089
|
switch(_state.label){
|
|
4070
4090
|
case 0:
|
|
@@ -4077,9 +4097,12 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4077
4097
|
this.continuousFetchingActive = true;
|
|
4078
4098
|
this.isShowingPlaceholder = false;
|
|
4079
4099
|
this.totalAdRequestsInBreak = 0;
|
|
4080
|
-
|
|
4081
|
-
|
|
4082
|
-
|
|
4100
|
+
state = (_this_savedMutedStateBeforeScte = this.savedMutedStateBeforeScte) !== null && _this_savedMutedStateBeforeScte !== void 0 ? _this_savedMutedStateBeforeScte : {
|
|
4101
|
+
muted: this.video.muted,
|
|
4102
|
+
volume: this.video.volume
|
|
4103
|
+
};
|
|
4104
|
+
this.adController.updateOriginalMutedState(state.muted, state.volume);
|
|
4105
|
+
this.savedMutedStateBeforeScte = null;
|
|
4083
4106
|
if (!this.video.muted) {
|
|
4084
4107
|
this.video.muted = true;
|
|
4085
4108
|
this.video.volume = 0;
|
|
@@ -4098,25 +4121,94 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4098
4121
|
if (this.expectedAdBreakDurationMs == null && adBreakDurationMs != null) {
|
|
4099
4122
|
this.expectedAdBreakDurationMs = adBreakDurationMs;
|
|
4100
4123
|
}
|
|
4101
|
-
this.clearPendingAdBreak();
|
|
4102
4124
|
if (this.config.debugAdTiming) {
|
|
4103
|
-
console.log("[CONTINUOUS-FETCH] \uD83D\uDCCB Prebid auction
|
|
4125
|
+
console.log("[CONTINUOUS-FETCH] \uD83D\uDCCB Prebid auction (prefetch or requestAds)");
|
|
4104
4126
|
}
|
|
4105
4127
|
_state.label = 1;
|
|
4106
4128
|
case 1:
|
|
4107
4129
|
_state.trys.push([
|
|
4108
4130
|
1,
|
|
4109
|
-
|
|
4131
|
+
6,
|
|
4110
4132
|
,
|
|
4111
|
-
|
|
4133
|
+
12
|
|
4112
4134
|
]);
|
|
4113
4135
|
this.lastAdRequestTime = Date.now();
|
|
4136
|
+
if (!this.prefetchAdPromise) return [
|
|
4137
|
+
3,
|
|
4138
|
+
3
|
|
4139
|
+
];
|
|
4114
4140
|
return [
|
|
4115
4141
|
4,
|
|
4116
|
-
this.
|
|
4142
|
+
this.prefetchAdPromise
|
|
4117
4143
|
];
|
|
4118
4144
|
case 2:
|
|
4119
4145
|
_state.sent();
|
|
4146
|
+
this.prefetchAdPromise = null;
|
|
4147
|
+
return [
|
|
4148
|
+
3,
|
|
4149
|
+
5
|
|
4150
|
+
];
|
|
4151
|
+
case 3:
|
|
4152
|
+
return [
|
|
4153
|
+
4,
|
|
4154
|
+
this.adController.requestAds()
|
|
4155
|
+
];
|
|
4156
|
+
case 4:
|
|
4157
|
+
_state.sent();
|
|
4158
|
+
_state.label = 5;
|
|
4159
|
+
case 5:
|
|
4160
|
+
return [
|
|
4161
|
+
3,
|
|
4162
|
+
12
|
|
4163
|
+
];
|
|
4164
|
+
case 6:
|
|
4165
|
+
unused = _state.sent();
|
|
4166
|
+
_state.label = 7;
|
|
4167
|
+
case 7:
|
|
4168
|
+
_state.trys.push([
|
|
4169
|
+
7,
|
|
4170
|
+
9,
|
|
4171
|
+
,
|
|
4172
|
+
11
|
|
4173
|
+
]);
|
|
4174
|
+
return [
|
|
4175
|
+
4,
|
|
4176
|
+
this.adController.requestAds()
|
|
4177
|
+
];
|
|
4178
|
+
case 8:
|
|
4179
|
+
_state.sent();
|
|
4180
|
+
return [
|
|
4181
|
+
3,
|
|
4182
|
+
11
|
|
4183
|
+
];
|
|
4184
|
+
case 9:
|
|
4185
|
+
unused1 = _state.sent();
|
|
4186
|
+
this.clearPendingAdBreak();
|
|
4187
|
+
this.consecutiveFailures++;
|
|
4188
|
+
return [
|
|
4189
|
+
4,
|
|
4190
|
+
this.tryNextAvailableAdWithRateLimit()
|
|
4191
|
+
];
|
|
4192
|
+
case 10:
|
|
4193
|
+
_state.sent();
|
|
4194
|
+
return [
|
|
4195
|
+
2
|
|
4196
|
+
];
|
|
4197
|
+
case 11:
|
|
4198
|
+
return [
|
|
4199
|
+
3,
|
|
4200
|
+
12
|
|
4201
|
+
];
|
|
4202
|
+
case 12:
|
|
4203
|
+
this.clearPendingAdBreak();
|
|
4204
|
+
_state.label = 13;
|
|
4205
|
+
case 13:
|
|
4206
|
+
_state.trys.push([
|
|
4207
|
+
13,
|
|
4208
|
+
15,
|
|
4209
|
+
,
|
|
4210
|
+
17
|
|
4211
|
+
]);
|
|
4120
4212
|
if (this.config.licenseKey) {
|
|
4121
4213
|
adLoadedInfo = {
|
|
4122
4214
|
source: this.getAdSource(),
|
|
@@ -4133,19 +4225,19 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4133
4225
|
4,
|
|
4134
4226
|
this.adController.play()
|
|
4135
4227
|
];
|
|
4136
|
-
case
|
|
4228
|
+
case 14:
|
|
4137
4229
|
_state.sent();
|
|
4138
4230
|
if (this.expectedAdBreakDurationMs != null) {
|
|
4139
4231
|
this.currentAdBreakStartWallClockMs = Date.now();
|
|
4140
4232
|
this.scheduleAdStopCountdown(this.expectedAdBreakDurationMs);
|
|
4141
4233
|
}
|
|
4142
|
-
adVolume =
|
|
4234
|
+
adVolume = state.muted ? 0 : state.volume;
|
|
4143
4235
|
this.adController.setAdVolume(adVolume);
|
|
4144
4236
|
return [
|
|
4145
4237
|
3,
|
|
4146
|
-
|
|
4238
|
+
17
|
|
4147
4239
|
];
|
|
4148
|
-
case
|
|
4240
|
+
case 15:
|
|
4149
4241
|
error = _state.sent();
|
|
4150
4242
|
if (this.config.debugAdTiming) {
|
|
4151
4243
|
console.warn("[CONTINUOUS-FETCH] \u26A0\uFE0F First ad request failed:", error);
|
|
@@ -4155,13 +4247,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4155
4247
|
4,
|
|
4156
4248
|
this.tryNextAvailableAdWithRateLimit()
|
|
4157
4249
|
];
|
|
4158
|
-
case
|
|
4250
|
+
case 16:
|
|
4159
4251
|
_state.sent();
|
|
4160
4252
|
return [
|
|
4161
4253
|
3,
|
|
4162
|
-
|
|
4254
|
+
17
|
|
4163
4255
|
];
|
|
4164
|
-
case
|
|
4256
|
+
case 17:
|
|
4165
4257
|
return [
|
|
4166
4258
|
2
|
|
4167
4259
|
];
|