stormcloud-video-player 0.7.10 → 0.7.11
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 +291 -230
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +21 -0
- package/lib/index.d.ts +21 -0
- package/lib/index.js +291 -230
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +244 -181
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/player/StormcloudVideoPlayer.d.cts +21 -1
- package/lib/players/HlsPlayer.cjs +244 -181
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.d.cts +1 -1
- package/lib/players/index.cjs +244 -181
- package/lib/players/index.cjs.map +1 -1
- package/lib/sdk/adstormPlayer.d.cts +1 -1
- package/lib/{types-ClqQZM3U.d.cts → types-jU4lq0ST.d.cts} +1 -0
- package/lib/ui/StormcloudVideoPlayer.cjs +291 -230
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.d.cts +1 -1
- package/lib/utils/tracking.d.cts +1 -1
- package/package.json +1 -1
|
@@ -2790,6 +2790,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
2790
2790
|
this.isInAdTransition = false;
|
|
2791
2791
|
this.maxPlaceholderDurationMs = 5e3;
|
|
2792
2792
|
this.isShowingPlaceholder = false;
|
|
2793
|
+
this.lastAdInsertionPoint = null;
|
|
2794
|
+
this.processedAdInsertionUpdatedAt = null;
|
|
2793
2795
|
this.totalAdRequestsInBreak = 0;
|
|
2794
2796
|
this.maxTotalAdRequestsPerBreak = 20;
|
|
2795
2797
|
this.pendingAdBreak = null;
|
|
@@ -2807,6 +2809,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
2807
2809
|
this.preloadedTokens = [];
|
|
2808
2810
|
this.debugLogEntries = [];
|
|
2809
2811
|
this.scteMarkerHistory = [];
|
|
2812
|
+
this.adInsertionDebugHistory = [];
|
|
2810
2813
|
initializePolyfills();
|
|
2811
2814
|
var browserOverrides = getBrowserConfigOverrides();
|
|
2812
2815
|
this.config = _object_spread({}, browserOverrides, config);
|
|
@@ -2991,6 +2994,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
2991
2994
|
_state.sent();
|
|
2992
2995
|
_state.label = 2;
|
|
2993
2996
|
case 2:
|
|
2997
|
+
if (!this.config.disableAds && this.config.projectId) {
|
|
2998
|
+
this.startAdInsertionPolling();
|
|
2999
|
+
}
|
|
2994
3000
|
return [
|
|
2995
3001
|
2
|
|
2996
3002
|
];
|
|
@@ -2998,78 +3004,11 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
2998
3004
|
});
|
|
2999
3005
|
}).call(_this);
|
|
3000
3006
|
});
|
|
3001
|
-
this.hls.on(import_hls.default.Events.LEVEL_LOADED, function(
|
|
3007
|
+
this.hls.on(import_hls.default.Events.LEVEL_LOADED, function() {
|
|
3002
3008
|
if (_this.inAdBreak || _this.pendingAdBreak) {
|
|
3003
3009
|
return;
|
|
3004
3010
|
}
|
|
3005
|
-
|
|
3006
|
-
if (!details || !details.fragments || details.fragments.length === 0) {
|
|
3007
|
-
return;
|
|
3008
|
-
}
|
|
3009
|
-
var fragmentsToScan = Math.min(5, details.fragments.length);
|
|
3010
|
-
for(var i = 0; i < fragmentsToScan; i++){
|
|
3011
|
-
var frag = details.fragments[i];
|
|
3012
|
-
var tagList = frag === null || frag === void 0 ? void 0 : frag.tagList;
|
|
3013
|
-
if (!Array.isArray(tagList)) continue;
|
|
3014
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
3015
|
-
try {
|
|
3016
|
-
for(var _iterator = tagList[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
3017
|
-
var entry = _step.value;
|
|
3018
|
-
var tag = "";
|
|
3019
|
-
var value = "";
|
|
3020
|
-
if (Array.isArray(entry)) {
|
|
3021
|
-
var _entry_, _entry_1;
|
|
3022
|
-
tag = String((_entry_ = entry[0]) !== null && _entry_ !== void 0 ? _entry_ : "");
|
|
3023
|
-
value = String((_entry_1 = entry[1]) !== null && _entry_1 !== void 0 ? _entry_1 : "");
|
|
3024
|
-
} else if (typeof entry === "string") {
|
|
3025
|
-
var idx = entry.indexOf(":");
|
|
3026
|
-
if (idx >= 0) {
|
|
3027
|
-
tag = entry.substring(0, idx);
|
|
3028
|
-
value = entry.substring(idx + 1);
|
|
3029
|
-
} else {
|
|
3030
|
-
tag = entry;
|
|
3031
|
-
}
|
|
3032
|
-
}
|
|
3033
|
-
if (!tag) continue;
|
|
3034
|
-
if (tag.includes("EXT-X-CUE-OUT") || tag.includes("EXT-X-DATERANGE")) {
|
|
3035
|
-
var attrs = tag.includes("EXT-X-DATERANGE") ? _this.parseAttributeList(value) : {};
|
|
3036
|
-
var hasScteOut = tag.includes("EXT-X-CUE-OUT") || "SCTE35-OUT" in attrs || attrs["SCTE35-OUT"] !== void 0;
|
|
3037
|
-
if (hasScteOut) {
|
|
3038
|
-
var durationSeconds = _this.parseCueOutDuration(value);
|
|
3039
|
-
var marker = _object_spread_props(_object_spread({
|
|
3040
|
-
type: "start"
|
|
3041
|
-
}, durationSeconds !== void 0 ? {
|
|
3042
|
-
durationSeconds: durationSeconds
|
|
3043
|
-
} : {}), {
|
|
3044
|
-
raw: {
|
|
3045
|
-
tag: tag,
|
|
3046
|
-
value: value,
|
|
3047
|
-
earlyDetection: true
|
|
3048
|
-
}
|
|
3049
|
-
});
|
|
3050
|
-
if (_this.config.debugAdTiming) {
|
|
3051
|
-
console.log("[StormcloudVideoPlayer] \uD83C\uDFAF EARLY SCTE-35 DETECTION: Ad break marker found in fragment", i, "- starting pre-fetch (NOT playing yet)");
|
|
3052
|
-
}
|
|
3053
|
-
_this.startAdPrefetch(marker, frag === null || frag === void 0 ? void 0 : frag.sn);
|
|
3054
|
-
return;
|
|
3055
|
-
}
|
|
3056
|
-
}
|
|
3057
|
-
}
|
|
3058
|
-
} catch (err) {
|
|
3059
|
-
_didIteratorError = true;
|
|
3060
|
-
_iteratorError = err;
|
|
3061
|
-
} finally{
|
|
3062
|
-
try {
|
|
3063
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
3064
|
-
_iterator.return();
|
|
3065
|
-
}
|
|
3066
|
-
} finally{
|
|
3067
|
-
if (_didIteratorError) {
|
|
3068
|
-
throw _iteratorError;
|
|
3069
|
-
}
|
|
3070
|
-
}
|
|
3071
|
-
}
|
|
3072
|
-
}
|
|
3011
|
+
_this.checkAdInsertionInManifest();
|
|
3073
3012
|
});
|
|
3074
3013
|
this.hls.on(import_hls.default.Events.FRAG_BUFFERED, function(_evt, data) {
|
|
3075
3014
|
return _async_to_generator(function() {
|
|
@@ -3131,124 +3070,42 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3131
3070
|
});
|
|
3132
3071
|
}).call(_this);
|
|
3133
3072
|
});
|
|
3134
|
-
this.hls.on(import_hls.default.Events.FRAG_PARSING_METADATA, function(_evt, data) {
|
|
3135
|
-
var id3Tags = ((data === null || data === void 0 ? void 0 : data.samples) || []).map(function(s) {
|
|
3136
|
-
return {
|
|
3137
|
-
key: "ID3",
|
|
3138
|
-
value: s === null || s === void 0 ? void 0 : s.data,
|
|
3139
|
-
ptsSeconds: s === null || s === void 0 ? void 0 : s.pts
|
|
3140
|
-
};
|
|
3141
|
-
});
|
|
3142
|
-
id3Tags.forEach(function(tag) {
|
|
3143
|
-
return _this.onId3Tag(tag);
|
|
3144
|
-
});
|
|
3145
|
-
});
|
|
3146
3073
|
this.hls.on(import_hls.default.Events.FRAG_CHANGED, function(_evt, data) {
|
|
3147
3074
|
var frag = data === null || data === void 0 ? void 0 : data.frag;
|
|
3148
|
-
|
|
3149
|
-
if (!
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
var
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
var idx = entry.indexOf(":");
|
|
3162
|
-
if (idx >= 0) {
|
|
3163
|
-
tag = entry.substring(0, idx);
|
|
3164
|
-
value = entry.substring(idx + 1);
|
|
3165
|
-
} else {
|
|
3166
|
-
tag = entry;
|
|
3167
|
-
value = "";
|
|
3168
|
-
}
|
|
3075
|
+
if (!frag) return;
|
|
3076
|
+
if (_this.lastAdInsertionPoint && !_this.inAdBreak && _this.lastAdInsertionPoint.updated_at !== _this.processedAdInsertionUpdatedAt) {
|
|
3077
|
+
var segmentName = _this.lastAdInsertionPoint.segment_ts_name;
|
|
3078
|
+
if (_this.fragmentMatchesSegment(frag, segmentName)) {
|
|
3079
|
+
var _ref;
|
|
3080
|
+
_this.processedAdInsertionUpdatedAt = _this.lastAdInsertionPoint.updated_at;
|
|
3081
|
+
var offsetMs = (_this.lastAdInsertionPoint.offset_seconds || 0) * 1e3;
|
|
3082
|
+
_this.pushAdInsertionDebug("segment_playing", segmentName, {
|
|
3083
|
+
offsetSeconds: _this.lastAdInsertionPoint.offset_seconds,
|
|
3084
|
+
detail: "sn=".concat((_ref = frag === null || frag === void 0 ? void 0 : frag.sn) !== null && _ref !== void 0 ? _ref : "?")
|
|
3085
|
+
});
|
|
3086
|
+
if (_this.config.debugAdTiming) {
|
|
3087
|
+
console.log('[StormcloudVideoPlayer] Ad insertion segment "'.concat(segmentName, '" now playing — scheduling ad start in ').concat(offsetMs, "ms"));
|
|
3169
3088
|
}
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
raw: {
|
|
3181
|
-
tag: tag,
|
|
3182
|
-
value: value
|
|
3183
|
-
}
|
|
3089
|
+
_this.pushAdInsertionDebug("ad_scheduled", segmentName, {
|
|
3090
|
+
offsetSeconds: _this.lastAdInsertionPoint.offset_seconds,
|
|
3091
|
+
detail: "in ".concat(offsetMs, "ms, dur=60s")
|
|
3092
|
+
});
|
|
3093
|
+
_this.clearAdInsertionOffsetTimer();
|
|
3094
|
+
_this.adInsertionOffsetTimerId = window.setTimeout(function() {
|
|
3095
|
+
_this.adInsertionOffsetTimerId = void 0;
|
|
3096
|
+
if (_this.inAdBreak) return;
|
|
3097
|
+
_this.pushAdInsertionDebug("ad_triggered", segmentName, {
|
|
3098
|
+
detail: "ad break started (60s)"
|
|
3184
3099
|
});
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
var marker1 = _object_spread_props(_object_spread({
|
|
3189
|
-
type: "start"
|
|
3190
|
-
}, durationSeconds !== void 0 ? {
|
|
3191
|
-
durationSeconds: durationSeconds
|
|
3192
|
-
} : {}), {
|
|
3100
|
+
var marker = {
|
|
3101
|
+
type: "start",
|
|
3102
|
+
durationSeconds: 60,
|
|
3193
3103
|
raw: {
|
|
3194
|
-
|
|
3195
|
-
value: value
|
|
3104
|
+
apiInsertionPoint: _this.lastAdInsertionPoint
|
|
3196
3105
|
}
|
|
3197
|
-
}
|
|
3198
|
-
_this.onScte35Marker(
|
|
3199
|
-
}
|
|
3200
|
-
_this.onScte35Marker({
|
|
3201
|
-
type: "end",
|
|
3202
|
-
raw: {
|
|
3203
|
-
tag: tag,
|
|
3204
|
-
value: value
|
|
3205
|
-
}
|
|
3206
|
-
});
|
|
3207
|
-
} else if (tag.includes("EXT-X-DATERANGE")) {
|
|
3208
|
-
var _attrs_CLASS;
|
|
3209
|
-
var attrs = _this.parseAttributeList(value);
|
|
3210
|
-
var hasScteOut = "SCTE35-OUT" in attrs || attrs["SCTE35-OUT"] !== void 0;
|
|
3211
|
-
var hasScteIn = "SCTE35-IN" in attrs || attrs["SCTE35-IN"] !== void 0;
|
|
3212
|
-
var klass = String((_attrs_CLASS = attrs["CLASS"]) !== null && _attrs_CLASS !== void 0 ? _attrs_CLASS : "");
|
|
3213
|
-
var duration = _this.toNumber(attrs["DURATION"]);
|
|
3214
|
-
if (hasScteOut || /com\.apple\.hls\.cue/i.test(klass)) {
|
|
3215
|
-
var marker2 = _object_spread_props(_object_spread({
|
|
3216
|
-
type: "start"
|
|
3217
|
-
}, duration !== void 0 ? {
|
|
3218
|
-
durationSeconds: duration
|
|
3219
|
-
} : {}), {
|
|
3220
|
-
raw: {
|
|
3221
|
-
tag: tag,
|
|
3222
|
-
value: value,
|
|
3223
|
-
attrs: attrs
|
|
3224
|
-
}
|
|
3225
|
-
});
|
|
3226
|
-
_this.onScte35Marker(marker2);
|
|
3227
|
-
}
|
|
3228
|
-
if (hasScteIn) {
|
|
3229
|
-
_this.onScte35Marker({
|
|
3230
|
-
type: "end",
|
|
3231
|
-
raw: {
|
|
3232
|
-
tag: tag,
|
|
3233
|
-
value: value,
|
|
3234
|
-
attrs: attrs
|
|
3235
|
-
}
|
|
3236
|
-
});
|
|
3237
|
-
}
|
|
3238
|
-
}
|
|
3239
|
-
}
|
|
3240
|
-
} catch (err) {
|
|
3241
|
-
_didIteratorError = true;
|
|
3242
|
-
_iteratorError = err;
|
|
3243
|
-
} finally{
|
|
3244
|
-
try {
|
|
3245
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
3246
|
-
_iterator.return();
|
|
3247
|
-
}
|
|
3248
|
-
} finally{
|
|
3249
|
-
if (_didIteratorError) {
|
|
3250
|
-
throw _iteratorError;
|
|
3251
|
-
}
|
|
3106
|
+
};
|
|
3107
|
+
_this.onScte35Marker(marker);
|
|
3108
|
+
}, offsetMs);
|
|
3252
3109
|
}
|
|
3253
3110
|
}
|
|
3254
3111
|
});
|
|
@@ -4448,6 +4305,182 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4448
4305
|
this.preloadedTokens = [];
|
|
4449
4306
|
}
|
|
4450
4307
|
},
|
|
4308
|
+
{
|
|
4309
|
+
key: "startAdInsertionPolling",
|
|
4310
|
+
value: function startAdInsertionPolling() {
|
|
4311
|
+
var _this = this;
|
|
4312
|
+
if (this.adInsertionPollingId != null) return;
|
|
4313
|
+
this.fetchAdInsertionPoint();
|
|
4314
|
+
this.adInsertionPollingId = window.setInterval(function() {
|
|
4315
|
+
_this.fetchAdInsertionPoint();
|
|
4316
|
+
}, 1e3);
|
|
4317
|
+
}
|
|
4318
|
+
},
|
|
4319
|
+
{
|
|
4320
|
+
key: "stopAdInsertionPolling",
|
|
4321
|
+
value: function stopAdInsertionPolling() {
|
|
4322
|
+
if (this.adInsertionPollingId != null) {
|
|
4323
|
+
clearInterval(this.adInsertionPollingId);
|
|
4324
|
+
this.adInsertionPollingId = void 0;
|
|
4325
|
+
}
|
|
4326
|
+
}
|
|
4327
|
+
},
|
|
4328
|
+
{
|
|
4329
|
+
key: "fetchAdInsertionPoint",
|
|
4330
|
+
value: function fetchAdInsertionPoint() {
|
|
4331
|
+
return _async_to_generator(function() {
|
|
4332
|
+
var _this_lastAdInsertionPoint, resp, data, isNew, unused;
|
|
4333
|
+
return _ts_generator(this, function(_state) {
|
|
4334
|
+
switch(_state.label){
|
|
4335
|
+
case 0:
|
|
4336
|
+
if (!this.config.projectId) return [
|
|
4337
|
+
2
|
|
4338
|
+
];
|
|
4339
|
+
_state.label = 1;
|
|
4340
|
+
case 1:
|
|
4341
|
+
_state.trys.push([
|
|
4342
|
+
1,
|
|
4343
|
+
4,
|
|
4344
|
+
,
|
|
4345
|
+
5
|
|
4346
|
+
]);
|
|
4347
|
+
return [
|
|
4348
|
+
4,
|
|
4349
|
+
fetch("https://adstorm.co/api-adstorm-dev/adstorm/swirl/projects/".concat(encodeURIComponent(this.config.projectId), "/ad-insertion-point"))
|
|
4350
|
+
];
|
|
4351
|
+
case 2:
|
|
4352
|
+
resp = _state.sent();
|
|
4353
|
+
if (!resp.ok) return [
|
|
4354
|
+
2
|
|
4355
|
+
];
|
|
4356
|
+
return [
|
|
4357
|
+
4,
|
|
4358
|
+
resp.json()
|
|
4359
|
+
];
|
|
4360
|
+
case 3:
|
|
4361
|
+
data = _state.sent();
|
|
4362
|
+
isNew = data.updated_at !== ((_this_lastAdInsertionPoint = this.lastAdInsertionPoint) === null || _this_lastAdInsertionPoint === void 0 ? void 0 : _this_lastAdInsertionPoint.updated_at);
|
|
4363
|
+
this.lastAdInsertionPoint = data;
|
|
4364
|
+
if (isNew) {
|
|
4365
|
+
this.pushAdInsertionDebug("api_response", data.segment_ts_name, {
|
|
4366
|
+
offsetSeconds: data.offset_seconds,
|
|
4367
|
+
updatedAt: data.updated_at,
|
|
4368
|
+
detail: "project=".concat(data.project_id)
|
|
4369
|
+
});
|
|
4370
|
+
}
|
|
4371
|
+
if (this.config.debugAdTiming) {
|
|
4372
|
+
console.log("[StormcloudVideoPlayer] Ad insertion point API response:", data);
|
|
4373
|
+
}
|
|
4374
|
+
return [
|
|
4375
|
+
3,
|
|
4376
|
+
5
|
|
4377
|
+
];
|
|
4378
|
+
case 4:
|
|
4379
|
+
unused = _state.sent();
|
|
4380
|
+
if (this.config.debugAdTiming) {
|
|
4381
|
+
console.warn("[StormcloudVideoPlayer] Ad insertion point API fetch failed");
|
|
4382
|
+
}
|
|
4383
|
+
return [
|
|
4384
|
+
3,
|
|
4385
|
+
5
|
|
4386
|
+
];
|
|
4387
|
+
case 5:
|
|
4388
|
+
return [
|
|
4389
|
+
2
|
|
4390
|
+
];
|
|
4391
|
+
}
|
|
4392
|
+
});
|
|
4393
|
+
}).call(this);
|
|
4394
|
+
}
|
|
4395
|
+
},
|
|
4396
|
+
{
|
|
4397
|
+
key: "checkAdInsertionInManifest",
|
|
4398
|
+
value: function checkAdInsertionInManifest() {
|
|
4399
|
+
var _this_hls;
|
|
4400
|
+
if (!this.lastAdInsertionPoint) return;
|
|
4401
|
+
if (this.inAdBreak || this.pendingAdBreak) return;
|
|
4402
|
+
if (this.lastAdInsertionPoint.updated_at === this.processedAdInsertionUpdatedAt) return;
|
|
4403
|
+
var segmentName = this.lastAdInsertionPoint.segment_ts_name;
|
|
4404
|
+
var levels = (_this_hls = this.hls) === null || _this_hls === void 0 ? void 0 : _this_hls.levels;
|
|
4405
|
+
if (!levels) return;
|
|
4406
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
4407
|
+
try {
|
|
4408
|
+
for(var _iterator = levels[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
4409
|
+
var level = _step.value;
|
|
4410
|
+
var _level_details;
|
|
4411
|
+
var fragments = (_level_details = level.details) === null || _level_details === void 0 ? void 0 : _level_details.fragments;
|
|
4412
|
+
if (!Array.isArray(fragments)) continue;
|
|
4413
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
4414
|
+
try {
|
|
4415
|
+
for(var _iterator1 = fragments[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
4416
|
+
var frag = _step1.value;
|
|
4417
|
+
if (this.fragmentMatchesSegment(frag, segmentName)) {
|
|
4418
|
+
var _ref;
|
|
4419
|
+
this.pushAdInsertionDebug("segment_found", segmentName, {
|
|
4420
|
+
detail: "sn=".concat((_ref = frag === null || frag === void 0 ? void 0 : frag.sn) !== null && _ref !== void 0 ? _ref : "?")
|
|
4421
|
+
});
|
|
4422
|
+
if (this.config.debugAdTiming) {
|
|
4423
|
+
console.log('[StormcloudVideoPlayer] Ad insertion segment "'.concat(segmentName, '" found in manifest — starting pre-fetch'));
|
|
4424
|
+
}
|
|
4425
|
+
var marker = {
|
|
4426
|
+
type: "start",
|
|
4427
|
+
durationSeconds: 60,
|
|
4428
|
+
raw: {
|
|
4429
|
+
apiInsertionPoint: this.lastAdInsertionPoint,
|
|
4430
|
+
earlyDetection: true
|
|
4431
|
+
}
|
|
4432
|
+
};
|
|
4433
|
+
this.startAdPrefetch(marker, frag === null || frag === void 0 ? void 0 : frag.sn);
|
|
4434
|
+
return;
|
|
4435
|
+
}
|
|
4436
|
+
}
|
|
4437
|
+
} catch (err) {
|
|
4438
|
+
_didIteratorError1 = true;
|
|
4439
|
+
_iteratorError1 = err;
|
|
4440
|
+
} finally{
|
|
4441
|
+
try {
|
|
4442
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
4443
|
+
_iterator1.return();
|
|
4444
|
+
}
|
|
4445
|
+
} finally{
|
|
4446
|
+
if (_didIteratorError1) {
|
|
4447
|
+
throw _iteratorError1;
|
|
4448
|
+
}
|
|
4449
|
+
}
|
|
4450
|
+
}
|
|
4451
|
+
}
|
|
4452
|
+
} catch (err) {
|
|
4453
|
+
_didIteratorError = true;
|
|
4454
|
+
_iteratorError = err;
|
|
4455
|
+
} finally{
|
|
4456
|
+
try {
|
|
4457
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
4458
|
+
_iterator.return();
|
|
4459
|
+
}
|
|
4460
|
+
} finally{
|
|
4461
|
+
if (_didIteratorError) {
|
|
4462
|
+
throw _iteratorError;
|
|
4463
|
+
}
|
|
4464
|
+
}
|
|
4465
|
+
}
|
|
4466
|
+
}
|
|
4467
|
+
},
|
|
4468
|
+
{
|
|
4469
|
+
key: "fragmentMatchesSegment",
|
|
4470
|
+
value: function fragmentMatchesSegment(frag, segmentName) {
|
|
4471
|
+
var url = (frag === null || frag === void 0 ? void 0 : frag.url) || (frag === null || frag === void 0 ? void 0 : frag.relurl) || "";
|
|
4472
|
+
return url.endsWith(segmentName) || url.includes("/" + segmentName);
|
|
4473
|
+
}
|
|
4474
|
+
},
|
|
4475
|
+
{
|
|
4476
|
+
key: "clearAdInsertionOffsetTimer",
|
|
4477
|
+
value: function clearAdInsertionOffsetTimer() {
|
|
4478
|
+
if (this.adInsertionOffsetTimerId != null) {
|
|
4479
|
+
clearTimeout(this.adInsertionOffsetTimerId);
|
|
4480
|
+
this.adInsertionOffsetTimerId = void 0;
|
|
4481
|
+
}
|
|
4482
|
+
}
|
|
4483
|
+
},
|
|
4451
4484
|
{
|
|
4452
4485
|
key: "startContinuousFetchLoop",
|
|
4453
4486
|
value: function startContinuousFetchLoop() {
|
|
@@ -5369,6 +5402,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5369
5402
|
}
|
|
5370
5403
|
this.clearAdRequestWatchdog();
|
|
5371
5404
|
this.clearAdFailsafeTimer();
|
|
5405
|
+
this.clearAdInsertionOffsetTimer();
|
|
5372
5406
|
this.activeAdRequestToken = null;
|
|
5373
5407
|
this.isInAdTransition = false;
|
|
5374
5408
|
this.stopContinuousFetching();
|
|
@@ -5699,6 +5733,32 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5699
5733
|
});
|
|
5700
5734
|
}
|
|
5701
5735
|
},
|
|
5736
|
+
{
|
|
5737
|
+
key: "pushAdInsertionDebug",
|
|
5738
|
+
value: function pushAdInsertionDebug(event, segmentName, opts) {
|
|
5739
|
+
if (!this.config.debugAdTiming) return;
|
|
5740
|
+
this.adInsertionDebugHistory.push(_object_spread({
|
|
5741
|
+
timestampMs: Date.now(),
|
|
5742
|
+
event: event,
|
|
5743
|
+
segmentName: segmentName
|
|
5744
|
+
}, (opts === null || opts === void 0 ? void 0 : opts.offsetSeconds) !== void 0 ? {
|
|
5745
|
+
offsetSeconds: opts.offsetSeconds
|
|
5746
|
+
} : {}, (opts === null || opts === void 0 ? void 0 : opts.updatedAt) ? {
|
|
5747
|
+
updatedAt: opts.updatedAt
|
|
5748
|
+
} : {}, (opts === null || opts === void 0 ? void 0 : opts.detail) ? {
|
|
5749
|
+
detail: opts.detail
|
|
5750
|
+
} : {}));
|
|
5751
|
+
if (this.adInsertionDebugHistory.length > DEBUG_HISTORY_LIMIT) {
|
|
5752
|
+
this.adInsertionDebugHistory = this.adInsertionDebugHistory.slice(-DEBUG_HISTORY_LIMIT);
|
|
5753
|
+
}
|
|
5754
|
+
}
|
|
5755
|
+
},
|
|
5756
|
+
{
|
|
5757
|
+
key: "getAdInsertionDebugLog",
|
|
5758
|
+
value: function getAdInsertionDebugLog() {
|
|
5759
|
+
return this.adInsertionDebugHistory.slice();
|
|
5760
|
+
}
|
|
5761
|
+
},
|
|
5702
5762
|
{
|
|
5703
5763
|
key: "getDebugLogs",
|
|
5704
5764
|
value: function getDebugLogs() {
|
|
@@ -5965,6 +6025,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5965
6025
|
key: "destroy",
|
|
5966
6026
|
value: function destroy() {
|
|
5967
6027
|
var _this_hls, _this_adLayer;
|
|
6028
|
+
this.stopAdInsertionPolling();
|
|
6029
|
+
this.clearAdInsertionOffsetTimer();
|
|
5968
6030
|
this.stopContinuousFetching();
|
|
5969
6031
|
this.stopFillerBreakTimer();
|
|
5970
6032
|
this.clearAdStartTimer();
|
|
@@ -5996,6 +6058,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5996
6058
|
this.consecutiveFailures = 0;
|
|
5997
6059
|
this.debugLogEntries = [];
|
|
5998
6060
|
this.scteMarkerHistory = [];
|
|
6061
|
+
this.adInsertionDebugHistory = [];
|
|
5999
6062
|
}
|
|
6000
6063
|
}
|
|
6001
6064
|
]);
|
|
@@ -7372,7 +7435,7 @@ var AI_CONTEXT_MIN_POLL_MS = 800;
|
|
|
7372
7435
|
var PANEL_BASE_RIGHT_OFFSET = 10;
|
|
7373
7436
|
var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props) {
|
|
7374
7437
|
var _ref;
|
|
7375
|
-
var _aiLiveContext_context
|
|
7438
|
+
var _aiLiveContext_context;
|
|
7376
7439
|
var src = props.src, autoplay = props.autoplay, muted = props.muted, lowLatencyMode = props.lowLatencyMode, allowNativeHls = props.allowNativeHls, driftToleranceMs = props.driftToleranceMs, immediateManifestAds = props.immediateManifestAds, debugAdTiming = props.debugAdTiming, showCustomControls = props.showCustomControls, hideLoadingIndicator = props.hideLoadingIndicator, onVolumeToggle = props.onVolumeToggle, onFullscreenToggle = props.onFullscreenToggle, onControlClick = props.onControlClick, onReady = props.onReady, wrapperClassName = props.wrapperClassName, wrapperStyle = props.wrapperStyle, className = props.className, style = props.style, controls = props.controls, playsInline = props.playsInline, preload = props.preload, poster = props.poster, children = props.children, licenseKey = props.licenseKey, minSegmentsBeforePlay = props.minSegmentsBeforePlay, disableAds = props.disableAds, disableFiller = props.disableFiller, swirlProjectId = props.swirlProjectId, restVideoAttrs = _object_without_properties(props, [
|
|
7377
7440
|
"src",
|
|
7378
7441
|
"autoplay",
|
|
@@ -7464,13 +7527,39 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
|
|
|
7464
7527
|
return "--:--:--";
|
|
7465
7528
|
}
|
|
7466
7529
|
};
|
|
7467
|
-
var
|
|
7468
|
-
|
|
7469
|
-
|
|
7470
|
-
|
|
7471
|
-
|
|
7472
|
-
|
|
7473
|
-
|
|
7530
|
+
var formatAdInsertionEvent = function formatAdInsertionEvent(event) {
|
|
7531
|
+
switch(event){
|
|
7532
|
+
case "api_response":
|
|
7533
|
+
return {
|
|
7534
|
+
label: "API",
|
|
7535
|
+
color: "#60a5fa"
|
|
7536
|
+
};
|
|
7537
|
+
case "segment_found":
|
|
7538
|
+
return {
|
|
7539
|
+
label: "FOUND",
|
|
7540
|
+
color: "#a78bfa"
|
|
7541
|
+
};
|
|
7542
|
+
case "segment_playing":
|
|
7543
|
+
return {
|
|
7544
|
+
label: "PLAYING",
|
|
7545
|
+
color: "#fbbf24"
|
|
7546
|
+
};
|
|
7547
|
+
case "ad_scheduled":
|
|
7548
|
+
return {
|
|
7549
|
+
label: "SCHED",
|
|
7550
|
+
color: "#fb923c"
|
|
7551
|
+
};
|
|
7552
|
+
case "ad_triggered":
|
|
7553
|
+
return {
|
|
7554
|
+
label: "TRIGGER",
|
|
7555
|
+
color: "#34d399"
|
|
7556
|
+
};
|
|
7557
|
+
default:
|
|
7558
|
+
return {
|
|
7559
|
+
label: event,
|
|
7560
|
+
color: "rgba(255,255,255,0.68)"
|
|
7561
|
+
};
|
|
7562
|
+
}
|
|
7474
7563
|
};
|
|
7475
7564
|
var formatAiRelativeTime = function formatAiRelativeTime(timestamp) {
|
|
7476
7565
|
var epochMs = Date.parse(timestamp);
|
|
@@ -7883,7 +7972,7 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
|
|
|
7883
7972
|
var updateDebugData = function updateDebugData() {
|
|
7884
7973
|
var player = playerRef.current;
|
|
7885
7974
|
if (!player) return;
|
|
7886
|
-
setDebugMarkers(player.
|
|
7975
|
+
setDebugMarkers(player.getAdInsertionDebugLog().slice(-DEBUG_PANEL_MARKER_LIMIT).reverse());
|
|
7887
7976
|
};
|
|
7888
7977
|
updateDebugData();
|
|
7889
7978
|
var interval = window.setInterval(updateDebugData, 500);
|
|
@@ -8418,34 +8507,7 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
|
|
|
8418
8507
|
whiteSpace: "pre-wrap"
|
|
8419
8508
|
},
|
|
8420
8509
|
children: (_ref = (_aiLiveContext_context = aiLiveContext.context) === null || _aiLiveContext_context === void 0 ? void 0 : _aiLiveContext_context.context) !== null && _ref !== void 0 ? _ref : aiLiveContext.isLoading ? "Analyzing live stream..." : "Waiting for AI context response."
|
|
8421
|
-
})
|
|
8422
|
-
((_aiLiveContext_context1 = aiLiveContext.context) === null || _aiLiveContext_context1 === void 0 ? void 0 : (_aiLiveContext_context_keywords = _aiLiveContext_context1.keywords) === null || _aiLiveContext_context_keywords === void 0 ? void 0 : _aiLiveContext_context_keywords.length) ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", {
|
|
8423
|
-
style: {
|
|
8424
|
-
marginTop: "10px",
|
|
8425
|
-
display: "flex",
|
|
8426
|
-
flexWrap: "wrap",
|
|
8427
|
-
gap: "6px"
|
|
8428
|
-
},
|
|
8429
|
-
children: aiLiveContext.context.keywords.slice(0, 12).map(function(kw) {
|
|
8430
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", {
|
|
8431
|
-
style: {
|
|
8432
|
-
fontSize: "10px",
|
|
8433
|
-
fontWeight: 600,
|
|
8434
|
-
padding: "4px 7px",
|
|
8435
|
-
borderRadius: "999px",
|
|
8436
|
-
background: "rgba(236, 72, 153, 0.2)",
|
|
8437
|
-
border: "1px solid rgba(244, 114, 182, 0.42)",
|
|
8438
|
-
color: "#fce7f3",
|
|
8439
|
-
maxWidth: "100%",
|
|
8440
|
-
overflow: "hidden",
|
|
8441
|
-
textOverflow: "ellipsis",
|
|
8442
|
-
whiteSpace: "nowrap"
|
|
8443
|
-
},
|
|
8444
|
-
title: kw,
|
|
8445
|
-
children: kw
|
|
8446
|
-
}, kw);
|
|
8447
|
-
})
|
|
8448
|
-
}) : null
|
|
8510
|
+
})
|
|
8449
8511
|
]
|
|
8450
8512
|
})
|
|
8451
8513
|
]
|
|
@@ -8487,7 +8549,7 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
|
|
|
8487
8549
|
fontWeight: 700,
|
|
8488
8550
|
letterSpacing: "0.02em"
|
|
8489
8551
|
},
|
|
8490
|
-
children: "
|
|
8552
|
+
children: "Ad Insertion Debug"
|
|
8491
8553
|
}),
|
|
8492
8554
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", {
|
|
8493
8555
|
className: "sc-ctrl-btn",
|
|
@@ -8528,7 +8590,7 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
|
|
|
8528
8590
|
color: "rgba(255,255,255,0.68)",
|
|
8529
8591
|
marginBottom: "8px"
|
|
8530
8592
|
},
|
|
8531
|
-
children: "
|
|
8593
|
+
children: "Ad Insertion Points"
|
|
8532
8594
|
}),
|
|
8533
8595
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", {
|
|
8534
8596
|
style: {
|
|
@@ -8540,12 +8602,13 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
|
|
|
8540
8602
|
fontSize: "12px",
|
|
8541
8603
|
color: "rgba(255,255,255,0.55)"
|
|
8542
8604
|
},
|
|
8543
|
-
children: "No
|
|
8605
|
+
children: "No ad insertion events yet."
|
|
8544
8606
|
}) : debugMarkers.map(function(entry, idx) {
|
|
8607
|
+
var evt = formatAdInsertionEvent(entry.event);
|
|
8545
8608
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", {
|
|
8546
8609
|
style: {
|
|
8547
8610
|
display: "grid",
|
|
8548
|
-
gridTemplateColumns: "56px
|
|
8611
|
+
gridTemplateColumns: "56px 54px 1fr",
|
|
8549
8612
|
gap: "8px",
|
|
8550
8613
|
alignItems: "center",
|
|
8551
8614
|
fontFamily: "'SF Mono', 'Cascadia Code', monospace",
|
|
@@ -8564,11 +8627,11 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
|
|
|
8564
8627
|
}),
|
|
8565
8628
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", {
|
|
8566
8629
|
style: {
|
|
8567
|
-
textTransform: "uppercase",
|
|
8568
8630
|
fontWeight: 700,
|
|
8569
|
-
color:
|
|
8631
|
+
color: evt.color,
|
|
8632
|
+
fontSize: "10px"
|
|
8570
8633
|
},
|
|
8571
|
-
children:
|
|
8634
|
+
children: evt.label
|
|
8572
8635
|
}),
|
|
8573
8636
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", {
|
|
8574
8637
|
style: {
|
|
@@ -8584,11 +8647,9 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
|
|
|
8584
8647
|
whiteSpace: "nowrap"
|
|
8585
8648
|
},
|
|
8586
8649
|
children: [
|
|
8587
|
-
entry.
|
|
8588
|
-
" ",
|
|
8589
|
-
entry.
|
|
8590
|
-
" ",
|
|
8591
|
-
formatDebugRaw(entry.raw)
|
|
8650
|
+
entry.segmentName,
|
|
8651
|
+
entry.offsetSeconds != null ? " +".concat(entry.offsetSeconds, "s") : "",
|
|
8652
|
+
entry.detail ? " (".concat(entry.detail, ")") : ""
|
|
8592
8653
|
]
|
|
8593
8654
|
})
|
|
8594
8655
|
})
|