stormcloud-video-player 0.8.81 → 0.8.83
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/Player.d.cts +1 -1
- package/lib/StormcloudPlayer.cjs +145 -10
- package/lib/StormcloudPlayer.cjs.map +1 -1
- package/lib/index.cjs +145 -10
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.ts +5 -0
- package/lib/index.js +145 -10
- package/lib/index.js.map +1 -1
- package/lib/player/AdBreakOrchestrator.cjs +63 -3
- package/lib/player/AdBreakOrchestrator.cjs.map +1 -1
- package/lib/player/AdBreakOrchestrator.d.cts +1 -0
- package/lib/player/AdConfigManager.cjs +54 -3
- package/lib/player/AdConfigManager.cjs.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +145 -10
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/player/StormcloudVideoPlayer.d.cts +2 -0
- package/lib/players/HlsPlayer.cjs +145 -10
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/index.cjs +145 -10
- package/lib/players/index.cjs.map +1 -1
- package/lib/sdk/hlsAdPlayer.cjs +13 -0
- package/lib/sdk/hlsAdPlayer.cjs.map +1 -1
- package/lib/types.d.cts +1 -0
- package/lib/ui/StormcloudVideoPlayer.cjs +145 -10
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/utils/__tests__/adSignals.test.cjs +30 -3
- package/lib/utils/__tests__/adSignals.test.cjs.map +1 -1
- package/lib/utils/adIdentity.cjs +34 -1
- package/lib/utils/adIdentity.cjs.map +1 -1
- package/lib/utils/adIdentity.d.cts +2 -1
- package/lib/utils/browserCompat.cjs +33 -0
- package/lib/utils/browserCompat.cjs.map +1 -1
- package/lib/utils/browserCompat.d.cts +3 -1
- package/lib/utils/contentMetadata.cjs +15 -4
- package/lib/utils/contentMetadata.cjs.map +1 -1
- package/lib/utils/contentMetadata.d.cts +2 -0
- package/lib/utils/partnerSignals.cjs +13 -2
- package/lib/utils/partnerSignals.cjs.map +1 -1
- package/lib/utils/partnerSignals.d.cts +2 -1
- package/lib/utils/vastMacros.cjs +1 -0
- package/lib/utils/vastMacros.cjs.map +1 -1
- package/lib/utils/vastMacros.d.cts +1 -0
- package/package.json +1 -1
|
@@ -2440,6 +2440,28 @@ function getScreenInactiveReason() {
|
|
|
2440
2440
|
if (bridgeSaysStandby()) return "bridge_standby";
|
|
2441
2441
|
return void 0;
|
|
2442
2442
|
}
|
|
2443
|
+
// src/utils/browserCompat.ts
|
|
2444
|
+
var LEARNED_SINGLE_DECODER_KEY = "stormcloud.singleDecoder.learned.v1";
|
|
2445
|
+
var learnedSingleDecoder;
|
|
2446
|
+
function readLearnedSingleDecoder() {
|
|
2447
|
+
if (learnedSingleDecoder !== void 0) return learnedSingleDecoder;
|
|
2448
|
+
try {
|
|
2449
|
+
var _window_localStorage;
|
|
2450
|
+
learnedSingleDecoder = typeof window !== "undefined" && ((_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.getItem(LEARNED_SINGLE_DECODER_KEY)) === "1";
|
|
2451
|
+
} catch (unused) {
|
|
2452
|
+
learnedSingleDecoder = false;
|
|
2453
|
+
}
|
|
2454
|
+
return learnedSingleDecoder;
|
|
2455
|
+
}
|
|
2456
|
+
function markSingleDecoderLearned() {
|
|
2457
|
+
if (readLearnedSingleDecoder()) return false;
|
|
2458
|
+
learnedSingleDecoder = true;
|
|
2459
|
+
try {
|
|
2460
|
+
var _window_localStorage;
|
|
2461
|
+
(_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.setItem(LEARNED_SINGLE_DECODER_KEY, "1");
|
|
2462
|
+
} catch (unused) {}
|
|
2463
|
+
return true;
|
|
2464
|
+
}
|
|
2443
2465
|
// src/player/AdBreakOrchestrator.ts
|
|
2444
2466
|
var REQUEST_FAILURE_STAGES = /* @__PURE__ */ new Set([
|
|
2445
2467
|
"no_fill",
|
|
@@ -2462,6 +2484,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
2462
2484
|
this.adDetectSentForCurrentBreak = false;
|
|
2463
2485
|
this.slotState = "IDLE";
|
|
2464
2486
|
this.unusableResponsesInBreak = 0;
|
|
2487
|
+
this.playedAdIdsInBreak = /* @__PURE__ */ new Set();
|
|
2465
2488
|
this.controllerGeneration = 0;
|
|
2466
2489
|
this.requestDiagnostics = /* @__PURE__ */ new Map();
|
|
2467
2490
|
this.breakFunnel = {};
|
|
@@ -2558,6 +2581,11 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
2558
2581
|
_this.recordRequestDiagnostic(payload);
|
|
2559
2582
|
});
|
|
2560
2583
|
adPlayer.on("ad_impression", function() {
|
|
2584
|
+
var _this_host_getAdPlayer_getLoadedAdId, _this_host_getAdPlayer;
|
|
2585
|
+
var impressionAdId = (_this_host_getAdPlayer_getLoadedAdId = (_this_host_getAdPlayer = _this.host.getAdPlayer()).getLoadedAdId) === null || _this_host_getAdPlayer_getLoadedAdId === void 0 ? void 0 : _this_host_getAdPlayer_getLoadedAdId.call(_this_host_getAdPlayer);
|
|
2586
|
+
if (impressionAdId != null && impressionAdId !== "") {
|
|
2587
|
+
_this.playedAdIdsInBreak.add(String(impressionAdId));
|
|
2588
|
+
}
|
|
2561
2589
|
_this.timing.consecutiveFailures = 0;
|
|
2562
2590
|
_this.setSlotState("PLAYING", "impression");
|
|
2563
2591
|
if (!_this.playbackStartedForCurrentRequest) {
|
|
@@ -2749,6 +2777,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
2749
2777
|
this.resetEdgeStateForBreak();
|
|
2750
2778
|
this.followUpBaseVastUrl = void 0;
|
|
2751
2779
|
this.unusableResponsesInBreak = 0;
|
|
2780
|
+
this.playedAdIdsInBreak.clear();
|
|
2752
2781
|
this.timing.totalAdRequestsInBreak = 0;
|
|
2753
2782
|
this.setSlotState("NEEDS_NEXT_AD", "vmap_break_start");
|
|
2754
2783
|
this.noteOpportunity("vmap", breakKey, position);
|
|
@@ -2799,6 +2828,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
2799
2828
|
this.breakSource = "scte35";
|
|
2800
2829
|
this.followUpBaseVastUrl = baseVastUrl;
|
|
2801
2830
|
this.unusableResponsesInBreak = 0;
|
|
2831
|
+
this.playedAdIdsInBreak.clear();
|
|
2802
2832
|
this.resetEdgeStateForBreak();
|
|
2803
2833
|
this.setSlotState("NEEDS_NEXT_AD", "scte35_break_start");
|
|
2804
2834
|
if (this.adConfig.podAssignedByPrefetch) {
|
|
@@ -3638,6 +3668,8 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
3638
3668
|
var outcome;
|
|
3639
3669
|
if (message.includes("ad_duration_exceeds_budget")) {
|
|
3640
3670
|
outcome = "discarded_budget";
|
|
3671
|
+
} else if (message.includes("ad_repeated_in_break")) {
|
|
3672
|
+
outcome = "discarded_duplicate";
|
|
3641
3673
|
} else if (message.includes("VAST fill rejected")) {
|
|
3642
3674
|
outcome = "fill_rejected";
|
|
3643
3675
|
} else if (/no ads available|no fill|nofill/i.test(message)) {
|
|
@@ -3652,7 +3684,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
3652
3684
|
outcome = "request_failed";
|
|
3653
3685
|
}
|
|
3654
3686
|
this.timing.consecutiveFailures++;
|
|
3655
|
-
if (outcome === "no_fill" || outcome === "fill_rejected" || outcome === "discarded_budget") {
|
|
3687
|
+
if (outcome === "no_fill" || outcome === "fill_rejected" || outcome === "discarded_budget" || outcome === "discarded_duplicate") {
|
|
3656
3688
|
this.unusableResponsesInBreak++;
|
|
3657
3689
|
}
|
|
3658
3690
|
if (outcome === "no_fill") {
|
|
@@ -3666,7 +3698,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
3666
3698
|
}) ? diag.dispatchedUrl : vastTagUrl;
|
|
3667
3699
|
if (this.timing.isTemporaryAdError(error)) {
|
|
3668
3700
|
this.timing.temporaryFailureUrls.set(failureKey, Date.now());
|
|
3669
|
-
} else if (outcome !== "discarded_budget") {
|
|
3701
|
+
} else if (outcome !== "discarded_budget" && outcome !== "discarded_duplicate") {
|
|
3670
3702
|
this.timing.failedVastUrls.add(failureKey);
|
|
3671
3703
|
}
|
|
3672
3704
|
this.countFunnelStage("request_outcome:".concat(outcome));
|
|
@@ -4038,7 +4070,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
4038
4070
|
value: function playSingleAd(vastTagUrl) {
|
|
4039
4071
|
var trigger = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "vmap";
|
|
4040
4072
|
return _async_to_generator(function() {
|
|
4041
|
-
var epoch, generation, requestToken, ap, requestUrl, _this_currentVastUrl, finalizeRequestUrl, _ap_getLoadedAdDuration, adDurationS, remainingMs, error;
|
|
4073
|
+
var epoch, generation, requestToken, ap, requestUrl, _this_currentVastUrl, _ref, _ap_getLoadedAdId, _ap_getPodAdCount, finalizeRequestUrl, loadedAdId, _ap_getLoadedAdDuration, adDurationS, remainingMs, error;
|
|
4042
4074
|
return _ts_generator(this, function(_state) {
|
|
4043
4075
|
switch(_state.label){
|
|
4044
4076
|
case 0:
|
|
@@ -4151,6 +4183,16 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
4151
4183
|
vastUrl: (_this_currentVastUrl = this.currentVastUrl) !== null && _this_currentVastUrl !== void 0 ? _this_currentVastUrl : requestUrl,
|
|
4152
4184
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
4153
4185
|
}, this.analyticsContext).catch(function() {});
|
|
4186
|
+
loadedAdId = (_ap_getLoadedAdId = ap.getLoadedAdId) === null || _ap_getLoadedAdId === void 0 ? void 0 : _ap_getLoadedAdId.call(ap);
|
|
4187
|
+
if (!this.host.config.allowRepeatAdsInBreak && loadedAdId != null && loadedAdId !== "" && ((_ref = (_ap_getPodAdCount = ap.getPodAdCount) === null || _ap_getPodAdCount === void 0 ? void 0 : _ap_getPodAdCount.call(ap)) !== null && _ref !== void 0 ? _ref : 1) <= 1 && this.playedAdIdsInBreak.has(String(loadedAdId))) {
|
|
4188
|
+
if (this.debug) {
|
|
4189
|
+
console.log("[AD-DURATION] Rejected ad id=".concat(loadedAdId, ": already played in this break — requesting another ad"));
|
|
4190
|
+
}
|
|
4191
|
+
this.logOrchestratorFunnel("discarded_duplicate", {
|
|
4192
|
+
adId: String(loadedAdId)
|
|
4193
|
+
});
|
|
4194
|
+
throw new Error("ad_repeated_in_break");
|
|
4195
|
+
}
|
|
4154
4196
|
if (!this.timing.ensureLoadedAdFitsBudget(ap)) {
|
|
4155
4197
|
;
|
|
4156
4198
|
adDurationS = (_ap_getLoadedAdDuration = ap.getLoadedAdDuration) === null || _ap_getLoadedAdDuration === void 0 ? void 0 : _ap_getLoadedAdDuration.call(ap);
|
|
@@ -4204,6 +4246,8 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
4204
4246
|
this.recordRequestFailure(error, vastTagUrl);
|
|
4205
4247
|
if ((error === null || error === void 0 ? void 0 : error.message) === "ad_duration_exceeds_budget") {
|
|
4206
4248
|
this.recreateAdController("discarded_budget");
|
|
4249
|
+
} else if ((error === null || error === void 0 ? void 0 : error.message) === "ad_repeated_in_break") {
|
|
4250
|
+
this.recreateAdController("discarded_duplicate");
|
|
4207
4251
|
}
|
|
4208
4252
|
throw error;
|
|
4209
4253
|
case 10:
|
|
@@ -4277,6 +4321,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
4277
4321
|
tagAllowsAudio: count("tag_allows_audio"),
|
|
4278
4322
|
missingImpression: count("vast_missing_impression"),
|
|
4279
4323
|
discardedBudget: count("discarded_budget"),
|
|
4324
|
+
discardedDuplicate: count("discarded_duplicate"),
|
|
4280
4325
|
mediaCandidates: count("media_candidate:accepted") + count("media_candidate:rejected"),
|
|
4281
4326
|
mediaRejected: count("media_candidate:rejected"),
|
|
4282
4327
|
mediaFallbacks: count("media_fallback"),
|
|
@@ -4352,6 +4397,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
4352
4397
|
this.breakSource = void 0;
|
|
4353
4398
|
this.followUpBaseVastUrl = void 0;
|
|
4354
4399
|
this.unusableResponsesInBreak = 0;
|
|
4400
|
+
this.playedAdIdsInBreak.clear();
|
|
4355
4401
|
this.resetEdgeStateForBreak();
|
|
4356
4402
|
adPlayer.stop().catch(function() {});
|
|
4357
4403
|
if (!alreadyEnded) this.logBreakFunnel(reason);
|
|
@@ -4452,9 +4498,18 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
4452
4498
|
var maxMonitorMs = 45e3;
|
|
4453
4499
|
var startTime = Date.now();
|
|
4454
4500
|
var baseline = resumeBaseline;
|
|
4501
|
+
var lastSeenTime = resumeBaseline;
|
|
4455
4502
|
var recoveries = 0;
|
|
4456
4503
|
var lastRecoveryAt = 0;
|
|
4457
4504
|
var video = this.host.video;
|
|
4505
|
+
var onDecodeError = function onDecodeError() {
|
|
4506
|
+
var _video_error;
|
|
4507
|
+
if (needsReset || ((_video_error = video.error) === null || _video_error === void 0 ? void 0 : _video_error.code) !== 3) return;
|
|
4508
|
+
if (markSingleDecoderLearned() && _this.debug) {
|
|
4509
|
+
console.warn("[StormcloudVideoPlayer] Decoder error while resuming after ads \u2014 using single-decoder mode on this device from the next break");
|
|
4510
|
+
}
|
|
4511
|
+
};
|
|
4512
|
+
video.addEventListener("error", onDecodeError);
|
|
4458
4513
|
var listenersAttached = false;
|
|
4459
4514
|
var onMediaEvent;
|
|
4460
4515
|
var diagEvents = [
|
|
@@ -4504,6 +4559,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
4504
4559
|
console.log("[ResumeDiag] +0.0s monitor start — ".concat(this.describeVideoState()));
|
|
4505
4560
|
}
|
|
4506
4561
|
var cleanup = function cleanup() {
|
|
4562
|
+
video.removeEventListener("error", onDecodeError);
|
|
4507
4563
|
if (listenersAttached && onMediaEvent) {
|
|
4508
4564
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
4509
4565
|
try {
|
|
@@ -4534,6 +4590,10 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
4534
4590
|
return;
|
|
4535
4591
|
}
|
|
4536
4592
|
var currentTime = video.currentTime;
|
|
4593
|
+
if (currentTime + 1 < lastSeenTime) {
|
|
4594
|
+
baseline = currentTime;
|
|
4595
|
+
}
|
|
4596
|
+
lastSeenTime = currentTime;
|
|
4537
4597
|
var advanced = currentTime > baseline + 0.5;
|
|
4538
4598
|
var playing = !video.paused && video.readyState >= 3;
|
|
4539
4599
|
if (advanced && playing) {
|