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
package/lib/index.js
CHANGED
|
@@ -2802,6 +2802,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
2802
2802
|
this.isInAdTransition = false;
|
|
2803
2803
|
this.maxPlaceholderDurationMs = 5e3;
|
|
2804
2804
|
this.isShowingPlaceholder = false;
|
|
2805
|
+
this.lastAdInsertionPoint = null;
|
|
2806
|
+
this.processedAdInsertionUpdatedAt = null;
|
|
2805
2807
|
this.totalAdRequestsInBreak = 0;
|
|
2806
2808
|
this.maxTotalAdRequestsPerBreak = 20;
|
|
2807
2809
|
this.pendingAdBreak = null;
|
|
@@ -2819,6 +2821,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
2819
2821
|
this.preloadedTokens = [];
|
|
2820
2822
|
this.debugLogEntries = [];
|
|
2821
2823
|
this.scteMarkerHistory = [];
|
|
2824
|
+
this.adInsertionDebugHistory = [];
|
|
2822
2825
|
initializePolyfills();
|
|
2823
2826
|
var browserOverrides = getBrowserConfigOverrides();
|
|
2824
2827
|
this.config = _object_spread({}, browserOverrides, config);
|
|
@@ -3003,6 +3006,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3003
3006
|
_state.sent();
|
|
3004
3007
|
_state.label = 2;
|
|
3005
3008
|
case 2:
|
|
3009
|
+
if (!this.config.disableAds && this.config.projectId) {
|
|
3010
|
+
this.startAdInsertionPolling();
|
|
3011
|
+
}
|
|
3006
3012
|
return [
|
|
3007
3013
|
2
|
|
3008
3014
|
];
|
|
@@ -3010,78 +3016,11 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3010
3016
|
});
|
|
3011
3017
|
}).call(_this);
|
|
3012
3018
|
});
|
|
3013
|
-
this.hls.on(Hls.Events.LEVEL_LOADED, function(
|
|
3019
|
+
this.hls.on(Hls.Events.LEVEL_LOADED, function() {
|
|
3014
3020
|
if (_this.inAdBreak || _this.pendingAdBreak) {
|
|
3015
3021
|
return;
|
|
3016
3022
|
}
|
|
3017
|
-
|
|
3018
|
-
if (!details || !details.fragments || details.fragments.length === 0) {
|
|
3019
|
-
return;
|
|
3020
|
-
}
|
|
3021
|
-
var fragmentsToScan = Math.min(5, details.fragments.length);
|
|
3022
|
-
for(var i = 0; i < fragmentsToScan; i++){
|
|
3023
|
-
var frag = details.fragments[i];
|
|
3024
|
-
var tagList = frag === null || frag === void 0 ? void 0 : frag.tagList;
|
|
3025
|
-
if (!Array.isArray(tagList)) continue;
|
|
3026
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
3027
|
-
try {
|
|
3028
|
-
for(var _iterator = tagList[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
3029
|
-
var entry = _step.value;
|
|
3030
|
-
var tag = "";
|
|
3031
|
-
var value = "";
|
|
3032
|
-
if (Array.isArray(entry)) {
|
|
3033
|
-
var _entry_, _entry_1;
|
|
3034
|
-
tag = String((_entry_ = entry[0]) !== null && _entry_ !== void 0 ? _entry_ : "");
|
|
3035
|
-
value = String((_entry_1 = entry[1]) !== null && _entry_1 !== void 0 ? _entry_1 : "");
|
|
3036
|
-
} else if (typeof entry === "string") {
|
|
3037
|
-
var idx = entry.indexOf(":");
|
|
3038
|
-
if (idx >= 0) {
|
|
3039
|
-
tag = entry.substring(0, idx);
|
|
3040
|
-
value = entry.substring(idx + 1);
|
|
3041
|
-
} else {
|
|
3042
|
-
tag = entry;
|
|
3043
|
-
}
|
|
3044
|
-
}
|
|
3045
|
-
if (!tag) continue;
|
|
3046
|
-
if (tag.includes("EXT-X-CUE-OUT") || tag.includes("EXT-X-DATERANGE")) {
|
|
3047
|
-
var attrs = tag.includes("EXT-X-DATERANGE") ? _this.parseAttributeList(value) : {};
|
|
3048
|
-
var hasScteOut = tag.includes("EXT-X-CUE-OUT") || "SCTE35-OUT" in attrs || attrs["SCTE35-OUT"] !== void 0;
|
|
3049
|
-
if (hasScteOut) {
|
|
3050
|
-
var durationSeconds = _this.parseCueOutDuration(value);
|
|
3051
|
-
var marker = _object_spread_props(_object_spread({
|
|
3052
|
-
type: "start"
|
|
3053
|
-
}, durationSeconds !== void 0 ? {
|
|
3054
|
-
durationSeconds: durationSeconds
|
|
3055
|
-
} : {}), {
|
|
3056
|
-
raw: {
|
|
3057
|
-
tag: tag,
|
|
3058
|
-
value: value,
|
|
3059
|
-
earlyDetection: true
|
|
3060
|
-
}
|
|
3061
|
-
});
|
|
3062
|
-
if (_this.config.debugAdTiming) {
|
|
3063
|
-
console.log("[StormcloudVideoPlayer] \uD83C\uDFAF EARLY SCTE-35 DETECTION: Ad break marker found in fragment", i, "- starting pre-fetch (NOT playing yet)");
|
|
3064
|
-
}
|
|
3065
|
-
_this.startAdPrefetch(marker, frag === null || frag === void 0 ? void 0 : frag.sn);
|
|
3066
|
-
return;
|
|
3067
|
-
}
|
|
3068
|
-
}
|
|
3069
|
-
}
|
|
3070
|
-
} catch (err) {
|
|
3071
|
-
_didIteratorError = true;
|
|
3072
|
-
_iteratorError = err;
|
|
3073
|
-
} finally{
|
|
3074
|
-
try {
|
|
3075
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
3076
|
-
_iterator.return();
|
|
3077
|
-
}
|
|
3078
|
-
} finally{
|
|
3079
|
-
if (_didIteratorError) {
|
|
3080
|
-
throw _iteratorError;
|
|
3081
|
-
}
|
|
3082
|
-
}
|
|
3083
|
-
}
|
|
3084
|
-
}
|
|
3023
|
+
_this.checkAdInsertionInManifest();
|
|
3085
3024
|
});
|
|
3086
3025
|
this.hls.on(Hls.Events.FRAG_BUFFERED, function(_evt, data) {
|
|
3087
3026
|
return _async_to_generator(function() {
|
|
@@ -3143,124 +3082,42 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3143
3082
|
});
|
|
3144
3083
|
}).call(_this);
|
|
3145
3084
|
});
|
|
3146
|
-
this.hls.on(Hls.Events.FRAG_PARSING_METADATA, function(_evt, data) {
|
|
3147
|
-
var id3Tags = ((data === null || data === void 0 ? void 0 : data.samples) || []).map(function(s) {
|
|
3148
|
-
return {
|
|
3149
|
-
key: "ID3",
|
|
3150
|
-
value: s === null || s === void 0 ? void 0 : s.data,
|
|
3151
|
-
ptsSeconds: s === null || s === void 0 ? void 0 : s.pts
|
|
3152
|
-
};
|
|
3153
|
-
});
|
|
3154
|
-
id3Tags.forEach(function(tag) {
|
|
3155
|
-
return _this.onId3Tag(tag);
|
|
3156
|
-
});
|
|
3157
|
-
});
|
|
3158
3085
|
this.hls.on(Hls.Events.FRAG_CHANGED, function(_evt, data) {
|
|
3159
3086
|
var frag = data === null || data === void 0 ? void 0 : data.frag;
|
|
3160
|
-
|
|
3161
|
-
if (!
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
var
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
var idx = entry.indexOf(":");
|
|
3174
|
-
if (idx >= 0) {
|
|
3175
|
-
tag = entry.substring(0, idx);
|
|
3176
|
-
value = entry.substring(idx + 1);
|
|
3177
|
-
} else {
|
|
3178
|
-
tag = entry;
|
|
3179
|
-
value = "";
|
|
3180
|
-
}
|
|
3087
|
+
if (!frag) return;
|
|
3088
|
+
if (_this.lastAdInsertionPoint && !_this.inAdBreak && _this.lastAdInsertionPoint.updated_at !== _this.processedAdInsertionUpdatedAt) {
|
|
3089
|
+
var segmentName = _this.lastAdInsertionPoint.segment_ts_name;
|
|
3090
|
+
if (_this.fragmentMatchesSegment(frag, segmentName)) {
|
|
3091
|
+
var _ref;
|
|
3092
|
+
_this.processedAdInsertionUpdatedAt = _this.lastAdInsertionPoint.updated_at;
|
|
3093
|
+
var offsetMs = (_this.lastAdInsertionPoint.offset_seconds || 0) * 1e3;
|
|
3094
|
+
_this.pushAdInsertionDebug("segment_playing", segmentName, {
|
|
3095
|
+
offsetSeconds: _this.lastAdInsertionPoint.offset_seconds,
|
|
3096
|
+
detail: "sn=".concat((_ref = frag === null || frag === void 0 ? void 0 : frag.sn) !== null && _ref !== void 0 ? _ref : "?")
|
|
3097
|
+
});
|
|
3098
|
+
if (_this.config.debugAdTiming) {
|
|
3099
|
+
console.log('[StormcloudVideoPlayer] Ad insertion segment "'.concat(segmentName, '" now playing — scheduling ad start in ').concat(offsetMs, "ms"));
|
|
3181
3100
|
}
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
raw: {
|
|
3193
|
-
tag: tag,
|
|
3194
|
-
value: value
|
|
3195
|
-
}
|
|
3101
|
+
_this.pushAdInsertionDebug("ad_scheduled", segmentName, {
|
|
3102
|
+
offsetSeconds: _this.lastAdInsertionPoint.offset_seconds,
|
|
3103
|
+
detail: "in ".concat(offsetMs, "ms, dur=60s")
|
|
3104
|
+
});
|
|
3105
|
+
_this.clearAdInsertionOffsetTimer();
|
|
3106
|
+
_this.adInsertionOffsetTimerId = window.setTimeout(function() {
|
|
3107
|
+
_this.adInsertionOffsetTimerId = void 0;
|
|
3108
|
+
if (_this.inAdBreak) return;
|
|
3109
|
+
_this.pushAdInsertionDebug("ad_triggered", segmentName, {
|
|
3110
|
+
detail: "ad break started (60s)"
|
|
3196
3111
|
});
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
var marker1 = _object_spread_props(_object_spread({
|
|
3201
|
-
type: "start"
|
|
3202
|
-
}, durationSeconds !== void 0 ? {
|
|
3203
|
-
durationSeconds: durationSeconds
|
|
3204
|
-
} : {}), {
|
|
3112
|
+
var marker = {
|
|
3113
|
+
type: "start",
|
|
3114
|
+
durationSeconds: 60,
|
|
3205
3115
|
raw: {
|
|
3206
|
-
|
|
3207
|
-
value: value
|
|
3116
|
+
apiInsertionPoint: _this.lastAdInsertionPoint
|
|
3208
3117
|
}
|
|
3209
|
-
}
|
|
3210
|
-
_this.onScte35Marker(
|
|
3211
|
-
}
|
|
3212
|
-
_this.onScte35Marker({
|
|
3213
|
-
type: "end",
|
|
3214
|
-
raw: {
|
|
3215
|
-
tag: tag,
|
|
3216
|
-
value: value
|
|
3217
|
-
}
|
|
3218
|
-
});
|
|
3219
|
-
} else if (tag.includes("EXT-X-DATERANGE")) {
|
|
3220
|
-
var _attrs_CLASS;
|
|
3221
|
-
var attrs = _this.parseAttributeList(value);
|
|
3222
|
-
var hasScteOut = "SCTE35-OUT" in attrs || attrs["SCTE35-OUT"] !== void 0;
|
|
3223
|
-
var hasScteIn = "SCTE35-IN" in attrs || attrs["SCTE35-IN"] !== void 0;
|
|
3224
|
-
var klass = String((_attrs_CLASS = attrs["CLASS"]) !== null && _attrs_CLASS !== void 0 ? _attrs_CLASS : "");
|
|
3225
|
-
var duration = _this.toNumber(attrs["DURATION"]);
|
|
3226
|
-
if (hasScteOut || /com\.apple\.hls\.cue/i.test(klass)) {
|
|
3227
|
-
var marker2 = _object_spread_props(_object_spread({
|
|
3228
|
-
type: "start"
|
|
3229
|
-
}, duration !== void 0 ? {
|
|
3230
|
-
durationSeconds: duration
|
|
3231
|
-
} : {}), {
|
|
3232
|
-
raw: {
|
|
3233
|
-
tag: tag,
|
|
3234
|
-
value: value,
|
|
3235
|
-
attrs: attrs
|
|
3236
|
-
}
|
|
3237
|
-
});
|
|
3238
|
-
_this.onScte35Marker(marker2);
|
|
3239
|
-
}
|
|
3240
|
-
if (hasScteIn) {
|
|
3241
|
-
_this.onScte35Marker({
|
|
3242
|
-
type: "end",
|
|
3243
|
-
raw: {
|
|
3244
|
-
tag: tag,
|
|
3245
|
-
value: value,
|
|
3246
|
-
attrs: attrs
|
|
3247
|
-
}
|
|
3248
|
-
});
|
|
3249
|
-
}
|
|
3250
|
-
}
|
|
3251
|
-
}
|
|
3252
|
-
} catch (err) {
|
|
3253
|
-
_didIteratorError = true;
|
|
3254
|
-
_iteratorError = err;
|
|
3255
|
-
} finally{
|
|
3256
|
-
try {
|
|
3257
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
3258
|
-
_iterator.return();
|
|
3259
|
-
}
|
|
3260
|
-
} finally{
|
|
3261
|
-
if (_didIteratorError) {
|
|
3262
|
-
throw _iteratorError;
|
|
3263
|
-
}
|
|
3118
|
+
};
|
|
3119
|
+
_this.onScte35Marker(marker);
|
|
3120
|
+
}, offsetMs);
|
|
3264
3121
|
}
|
|
3265
3122
|
}
|
|
3266
3123
|
});
|
|
@@ -4460,6 +4317,182 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4460
4317
|
this.preloadedTokens = [];
|
|
4461
4318
|
}
|
|
4462
4319
|
},
|
|
4320
|
+
{
|
|
4321
|
+
key: "startAdInsertionPolling",
|
|
4322
|
+
value: function startAdInsertionPolling() {
|
|
4323
|
+
var _this = this;
|
|
4324
|
+
if (this.adInsertionPollingId != null) return;
|
|
4325
|
+
this.fetchAdInsertionPoint();
|
|
4326
|
+
this.adInsertionPollingId = window.setInterval(function() {
|
|
4327
|
+
_this.fetchAdInsertionPoint();
|
|
4328
|
+
}, 1e3);
|
|
4329
|
+
}
|
|
4330
|
+
},
|
|
4331
|
+
{
|
|
4332
|
+
key: "stopAdInsertionPolling",
|
|
4333
|
+
value: function stopAdInsertionPolling() {
|
|
4334
|
+
if (this.adInsertionPollingId != null) {
|
|
4335
|
+
clearInterval(this.adInsertionPollingId);
|
|
4336
|
+
this.adInsertionPollingId = void 0;
|
|
4337
|
+
}
|
|
4338
|
+
}
|
|
4339
|
+
},
|
|
4340
|
+
{
|
|
4341
|
+
key: "fetchAdInsertionPoint",
|
|
4342
|
+
value: function fetchAdInsertionPoint() {
|
|
4343
|
+
return _async_to_generator(function() {
|
|
4344
|
+
var _this_lastAdInsertionPoint, resp, data, isNew, unused;
|
|
4345
|
+
return _ts_generator(this, function(_state) {
|
|
4346
|
+
switch(_state.label){
|
|
4347
|
+
case 0:
|
|
4348
|
+
if (!this.config.projectId) return [
|
|
4349
|
+
2
|
|
4350
|
+
];
|
|
4351
|
+
_state.label = 1;
|
|
4352
|
+
case 1:
|
|
4353
|
+
_state.trys.push([
|
|
4354
|
+
1,
|
|
4355
|
+
4,
|
|
4356
|
+
,
|
|
4357
|
+
5
|
|
4358
|
+
]);
|
|
4359
|
+
return [
|
|
4360
|
+
4,
|
|
4361
|
+
fetch("https://adstorm.co/api-adstorm-dev/adstorm/swirl/projects/".concat(encodeURIComponent(this.config.projectId), "/ad-insertion-point"))
|
|
4362
|
+
];
|
|
4363
|
+
case 2:
|
|
4364
|
+
resp = _state.sent();
|
|
4365
|
+
if (!resp.ok) return [
|
|
4366
|
+
2
|
|
4367
|
+
];
|
|
4368
|
+
return [
|
|
4369
|
+
4,
|
|
4370
|
+
resp.json()
|
|
4371
|
+
];
|
|
4372
|
+
case 3:
|
|
4373
|
+
data = _state.sent();
|
|
4374
|
+
isNew = data.updated_at !== ((_this_lastAdInsertionPoint = this.lastAdInsertionPoint) === null || _this_lastAdInsertionPoint === void 0 ? void 0 : _this_lastAdInsertionPoint.updated_at);
|
|
4375
|
+
this.lastAdInsertionPoint = data;
|
|
4376
|
+
if (isNew) {
|
|
4377
|
+
this.pushAdInsertionDebug("api_response", data.segment_ts_name, {
|
|
4378
|
+
offsetSeconds: data.offset_seconds,
|
|
4379
|
+
updatedAt: data.updated_at,
|
|
4380
|
+
detail: "project=".concat(data.project_id)
|
|
4381
|
+
});
|
|
4382
|
+
}
|
|
4383
|
+
if (this.config.debugAdTiming) {
|
|
4384
|
+
console.log("[StormcloudVideoPlayer] Ad insertion point API response:", data);
|
|
4385
|
+
}
|
|
4386
|
+
return [
|
|
4387
|
+
3,
|
|
4388
|
+
5
|
|
4389
|
+
];
|
|
4390
|
+
case 4:
|
|
4391
|
+
unused = _state.sent();
|
|
4392
|
+
if (this.config.debugAdTiming) {
|
|
4393
|
+
console.warn("[StormcloudVideoPlayer] Ad insertion point API fetch failed");
|
|
4394
|
+
}
|
|
4395
|
+
return [
|
|
4396
|
+
3,
|
|
4397
|
+
5
|
|
4398
|
+
];
|
|
4399
|
+
case 5:
|
|
4400
|
+
return [
|
|
4401
|
+
2
|
|
4402
|
+
];
|
|
4403
|
+
}
|
|
4404
|
+
});
|
|
4405
|
+
}).call(this);
|
|
4406
|
+
}
|
|
4407
|
+
},
|
|
4408
|
+
{
|
|
4409
|
+
key: "checkAdInsertionInManifest",
|
|
4410
|
+
value: function checkAdInsertionInManifest() {
|
|
4411
|
+
var _this_hls;
|
|
4412
|
+
if (!this.lastAdInsertionPoint) return;
|
|
4413
|
+
if (this.inAdBreak || this.pendingAdBreak) return;
|
|
4414
|
+
if (this.lastAdInsertionPoint.updated_at === this.processedAdInsertionUpdatedAt) return;
|
|
4415
|
+
var segmentName = this.lastAdInsertionPoint.segment_ts_name;
|
|
4416
|
+
var levels = (_this_hls = this.hls) === null || _this_hls === void 0 ? void 0 : _this_hls.levels;
|
|
4417
|
+
if (!levels) return;
|
|
4418
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
4419
|
+
try {
|
|
4420
|
+
for(var _iterator = levels[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
4421
|
+
var level = _step.value;
|
|
4422
|
+
var _level_details;
|
|
4423
|
+
var fragments = (_level_details = level.details) === null || _level_details === void 0 ? void 0 : _level_details.fragments;
|
|
4424
|
+
if (!Array.isArray(fragments)) continue;
|
|
4425
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
4426
|
+
try {
|
|
4427
|
+
for(var _iterator1 = fragments[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
4428
|
+
var frag = _step1.value;
|
|
4429
|
+
if (this.fragmentMatchesSegment(frag, segmentName)) {
|
|
4430
|
+
var _ref;
|
|
4431
|
+
this.pushAdInsertionDebug("segment_found", segmentName, {
|
|
4432
|
+
detail: "sn=".concat((_ref = frag === null || frag === void 0 ? void 0 : frag.sn) !== null && _ref !== void 0 ? _ref : "?")
|
|
4433
|
+
});
|
|
4434
|
+
if (this.config.debugAdTiming) {
|
|
4435
|
+
console.log('[StormcloudVideoPlayer] Ad insertion segment "'.concat(segmentName, '" found in manifest — starting pre-fetch'));
|
|
4436
|
+
}
|
|
4437
|
+
var marker = {
|
|
4438
|
+
type: "start",
|
|
4439
|
+
durationSeconds: 60,
|
|
4440
|
+
raw: {
|
|
4441
|
+
apiInsertionPoint: this.lastAdInsertionPoint,
|
|
4442
|
+
earlyDetection: true
|
|
4443
|
+
}
|
|
4444
|
+
};
|
|
4445
|
+
this.startAdPrefetch(marker, frag === null || frag === void 0 ? void 0 : frag.sn);
|
|
4446
|
+
return;
|
|
4447
|
+
}
|
|
4448
|
+
}
|
|
4449
|
+
} catch (err) {
|
|
4450
|
+
_didIteratorError1 = true;
|
|
4451
|
+
_iteratorError1 = err;
|
|
4452
|
+
} finally{
|
|
4453
|
+
try {
|
|
4454
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
4455
|
+
_iterator1.return();
|
|
4456
|
+
}
|
|
4457
|
+
} finally{
|
|
4458
|
+
if (_didIteratorError1) {
|
|
4459
|
+
throw _iteratorError1;
|
|
4460
|
+
}
|
|
4461
|
+
}
|
|
4462
|
+
}
|
|
4463
|
+
}
|
|
4464
|
+
} catch (err) {
|
|
4465
|
+
_didIteratorError = true;
|
|
4466
|
+
_iteratorError = err;
|
|
4467
|
+
} finally{
|
|
4468
|
+
try {
|
|
4469
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
4470
|
+
_iterator.return();
|
|
4471
|
+
}
|
|
4472
|
+
} finally{
|
|
4473
|
+
if (_didIteratorError) {
|
|
4474
|
+
throw _iteratorError;
|
|
4475
|
+
}
|
|
4476
|
+
}
|
|
4477
|
+
}
|
|
4478
|
+
}
|
|
4479
|
+
},
|
|
4480
|
+
{
|
|
4481
|
+
key: "fragmentMatchesSegment",
|
|
4482
|
+
value: function fragmentMatchesSegment(frag, segmentName) {
|
|
4483
|
+
var url = (frag === null || frag === void 0 ? void 0 : frag.url) || (frag === null || frag === void 0 ? void 0 : frag.relurl) || "";
|
|
4484
|
+
return url.endsWith(segmentName) || url.includes("/" + segmentName);
|
|
4485
|
+
}
|
|
4486
|
+
},
|
|
4487
|
+
{
|
|
4488
|
+
key: "clearAdInsertionOffsetTimer",
|
|
4489
|
+
value: function clearAdInsertionOffsetTimer() {
|
|
4490
|
+
if (this.adInsertionOffsetTimerId != null) {
|
|
4491
|
+
clearTimeout(this.adInsertionOffsetTimerId);
|
|
4492
|
+
this.adInsertionOffsetTimerId = void 0;
|
|
4493
|
+
}
|
|
4494
|
+
}
|
|
4495
|
+
},
|
|
4463
4496
|
{
|
|
4464
4497
|
key: "startContinuousFetchLoop",
|
|
4465
4498
|
value: function startContinuousFetchLoop() {
|
|
@@ -5381,6 +5414,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5381
5414
|
}
|
|
5382
5415
|
this.clearAdRequestWatchdog();
|
|
5383
5416
|
this.clearAdFailsafeTimer();
|
|
5417
|
+
this.clearAdInsertionOffsetTimer();
|
|
5384
5418
|
this.activeAdRequestToken = null;
|
|
5385
5419
|
this.isInAdTransition = false;
|
|
5386
5420
|
this.stopContinuousFetching();
|
|
@@ -5711,6 +5745,32 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5711
5745
|
});
|
|
5712
5746
|
}
|
|
5713
5747
|
},
|
|
5748
|
+
{
|
|
5749
|
+
key: "pushAdInsertionDebug",
|
|
5750
|
+
value: function pushAdInsertionDebug(event, segmentName, opts) {
|
|
5751
|
+
if (!this.config.debugAdTiming) return;
|
|
5752
|
+
this.adInsertionDebugHistory.push(_object_spread({
|
|
5753
|
+
timestampMs: Date.now(),
|
|
5754
|
+
event: event,
|
|
5755
|
+
segmentName: segmentName
|
|
5756
|
+
}, (opts === null || opts === void 0 ? void 0 : opts.offsetSeconds) !== void 0 ? {
|
|
5757
|
+
offsetSeconds: opts.offsetSeconds
|
|
5758
|
+
} : {}, (opts === null || opts === void 0 ? void 0 : opts.updatedAt) ? {
|
|
5759
|
+
updatedAt: opts.updatedAt
|
|
5760
|
+
} : {}, (opts === null || opts === void 0 ? void 0 : opts.detail) ? {
|
|
5761
|
+
detail: opts.detail
|
|
5762
|
+
} : {}));
|
|
5763
|
+
if (this.adInsertionDebugHistory.length > DEBUG_HISTORY_LIMIT) {
|
|
5764
|
+
this.adInsertionDebugHistory = this.adInsertionDebugHistory.slice(-DEBUG_HISTORY_LIMIT);
|
|
5765
|
+
}
|
|
5766
|
+
}
|
|
5767
|
+
},
|
|
5768
|
+
{
|
|
5769
|
+
key: "getAdInsertionDebugLog",
|
|
5770
|
+
value: function getAdInsertionDebugLog() {
|
|
5771
|
+
return this.adInsertionDebugHistory.slice();
|
|
5772
|
+
}
|
|
5773
|
+
},
|
|
5714
5774
|
{
|
|
5715
5775
|
key: "getDebugLogs",
|
|
5716
5776
|
value: function getDebugLogs() {
|
|
@@ -5977,6 +6037,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5977
6037
|
key: "destroy",
|
|
5978
6038
|
value: function destroy() {
|
|
5979
6039
|
var _this_hls, _this_adLayer;
|
|
6040
|
+
this.stopAdInsertionPolling();
|
|
6041
|
+
this.clearAdInsertionOffsetTimer();
|
|
5980
6042
|
this.stopContinuousFetching();
|
|
5981
6043
|
this.stopFillerBreakTimer();
|
|
5982
6044
|
this.clearAdStartTimer();
|
|
@@ -6008,6 +6070,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6008
6070
|
this.consecutiveFailures = 0;
|
|
6009
6071
|
this.debugLogEntries = [];
|
|
6010
6072
|
this.scteMarkerHistory = [];
|
|
6073
|
+
this.adInsertionDebugHistory = [];
|
|
6011
6074
|
}
|
|
6012
6075
|
}
|
|
6013
6076
|
]);
|
|
@@ -7384,7 +7447,7 @@ var AI_CONTEXT_MIN_POLL_MS = 800;
|
|
|
7384
7447
|
var PANEL_BASE_RIGHT_OFFSET = 10;
|
|
7385
7448
|
var StormcloudVideoPlayerComponent = React2.memo(function(props) {
|
|
7386
7449
|
var _ref;
|
|
7387
|
-
var _aiLiveContext_context
|
|
7450
|
+
var _aiLiveContext_context;
|
|
7388
7451
|
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, [
|
|
7389
7452
|
"src",
|
|
7390
7453
|
"autoplay",
|
|
@@ -7476,13 +7539,39 @@ var StormcloudVideoPlayerComponent = React2.memo(function(props) {
|
|
|
7476
7539
|
return "--:--:--";
|
|
7477
7540
|
}
|
|
7478
7541
|
};
|
|
7479
|
-
var
|
|
7480
|
-
|
|
7481
|
-
|
|
7482
|
-
|
|
7483
|
-
|
|
7484
|
-
|
|
7485
|
-
|
|
7542
|
+
var formatAdInsertionEvent = function formatAdInsertionEvent(event) {
|
|
7543
|
+
switch(event){
|
|
7544
|
+
case "api_response":
|
|
7545
|
+
return {
|
|
7546
|
+
label: "API",
|
|
7547
|
+
color: "#60a5fa"
|
|
7548
|
+
};
|
|
7549
|
+
case "segment_found":
|
|
7550
|
+
return {
|
|
7551
|
+
label: "FOUND",
|
|
7552
|
+
color: "#a78bfa"
|
|
7553
|
+
};
|
|
7554
|
+
case "segment_playing":
|
|
7555
|
+
return {
|
|
7556
|
+
label: "PLAYING",
|
|
7557
|
+
color: "#fbbf24"
|
|
7558
|
+
};
|
|
7559
|
+
case "ad_scheduled":
|
|
7560
|
+
return {
|
|
7561
|
+
label: "SCHED",
|
|
7562
|
+
color: "#fb923c"
|
|
7563
|
+
};
|
|
7564
|
+
case "ad_triggered":
|
|
7565
|
+
return {
|
|
7566
|
+
label: "TRIGGER",
|
|
7567
|
+
color: "#34d399"
|
|
7568
|
+
};
|
|
7569
|
+
default:
|
|
7570
|
+
return {
|
|
7571
|
+
label: event,
|
|
7572
|
+
color: "rgba(255,255,255,0.68)"
|
|
7573
|
+
};
|
|
7574
|
+
}
|
|
7486
7575
|
};
|
|
7487
7576
|
var formatAiRelativeTime = function formatAiRelativeTime(timestamp) {
|
|
7488
7577
|
var epochMs = Date.parse(timestamp);
|
|
@@ -7895,7 +7984,7 @@ var StormcloudVideoPlayerComponent = React2.memo(function(props) {
|
|
|
7895
7984
|
var updateDebugData = function updateDebugData() {
|
|
7896
7985
|
var player = playerRef.current;
|
|
7897
7986
|
if (!player) return;
|
|
7898
|
-
setDebugMarkers(player.
|
|
7987
|
+
setDebugMarkers(player.getAdInsertionDebugLog().slice(-DEBUG_PANEL_MARKER_LIMIT).reverse());
|
|
7899
7988
|
};
|
|
7900
7989
|
updateDebugData();
|
|
7901
7990
|
var interval = window.setInterval(updateDebugData, 500);
|
|
@@ -8430,34 +8519,7 @@ var StormcloudVideoPlayerComponent = React2.memo(function(props) {
|
|
|
8430
8519
|
whiteSpace: "pre-wrap"
|
|
8431
8520
|
},
|
|
8432
8521
|
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."
|
|
8433
|
-
})
|
|
8434
|
-
((_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__ */ jsx2("div", {
|
|
8435
|
-
style: {
|
|
8436
|
-
marginTop: "10px",
|
|
8437
|
-
display: "flex",
|
|
8438
|
-
flexWrap: "wrap",
|
|
8439
|
-
gap: "6px"
|
|
8440
|
-
},
|
|
8441
|
-
children: aiLiveContext.context.keywords.slice(0, 12).map(function(kw) {
|
|
8442
|
-
return /* @__PURE__ */ jsx2("span", {
|
|
8443
|
-
style: {
|
|
8444
|
-
fontSize: "10px",
|
|
8445
|
-
fontWeight: 600,
|
|
8446
|
-
padding: "4px 7px",
|
|
8447
|
-
borderRadius: "999px",
|
|
8448
|
-
background: "rgba(236, 72, 153, 0.2)",
|
|
8449
|
-
border: "1px solid rgba(244, 114, 182, 0.42)",
|
|
8450
|
-
color: "#fce7f3",
|
|
8451
|
-
maxWidth: "100%",
|
|
8452
|
-
overflow: "hidden",
|
|
8453
|
-
textOverflow: "ellipsis",
|
|
8454
|
-
whiteSpace: "nowrap"
|
|
8455
|
-
},
|
|
8456
|
-
title: kw,
|
|
8457
|
-
children: kw
|
|
8458
|
-
}, kw);
|
|
8459
|
-
})
|
|
8460
|
-
}) : null
|
|
8522
|
+
})
|
|
8461
8523
|
]
|
|
8462
8524
|
})
|
|
8463
8525
|
]
|
|
@@ -8499,7 +8561,7 @@ var StormcloudVideoPlayerComponent = React2.memo(function(props) {
|
|
|
8499
8561
|
fontWeight: 700,
|
|
8500
8562
|
letterSpacing: "0.02em"
|
|
8501
8563
|
},
|
|
8502
|
-
children: "
|
|
8564
|
+
children: "Ad Insertion Debug"
|
|
8503
8565
|
}),
|
|
8504
8566
|
/* @__PURE__ */ jsx2("button", {
|
|
8505
8567
|
className: "sc-ctrl-btn",
|
|
@@ -8540,7 +8602,7 @@ var StormcloudVideoPlayerComponent = React2.memo(function(props) {
|
|
|
8540
8602
|
color: "rgba(255,255,255,0.68)",
|
|
8541
8603
|
marginBottom: "8px"
|
|
8542
8604
|
},
|
|
8543
|
-
children: "
|
|
8605
|
+
children: "Ad Insertion Points"
|
|
8544
8606
|
}),
|
|
8545
8607
|
/* @__PURE__ */ jsx2("div", {
|
|
8546
8608
|
style: {
|
|
@@ -8552,12 +8614,13 @@ var StormcloudVideoPlayerComponent = React2.memo(function(props) {
|
|
|
8552
8614
|
fontSize: "12px",
|
|
8553
8615
|
color: "rgba(255,255,255,0.55)"
|
|
8554
8616
|
},
|
|
8555
|
-
children: "No
|
|
8617
|
+
children: "No ad insertion events yet."
|
|
8556
8618
|
}) : debugMarkers.map(function(entry, idx) {
|
|
8619
|
+
var evt = formatAdInsertionEvent(entry.event);
|
|
8557
8620
|
return /* @__PURE__ */ jsxs2("div", {
|
|
8558
8621
|
style: {
|
|
8559
8622
|
display: "grid",
|
|
8560
|
-
gridTemplateColumns: "56px
|
|
8623
|
+
gridTemplateColumns: "56px 54px 1fr",
|
|
8561
8624
|
gap: "8px",
|
|
8562
8625
|
alignItems: "center",
|
|
8563
8626
|
fontFamily: "'SF Mono', 'Cascadia Code', monospace",
|
|
@@ -8576,11 +8639,11 @@ var StormcloudVideoPlayerComponent = React2.memo(function(props) {
|
|
|
8576
8639
|
}),
|
|
8577
8640
|
/* @__PURE__ */ jsx2("span", {
|
|
8578
8641
|
style: {
|
|
8579
|
-
textTransform: "uppercase",
|
|
8580
8642
|
fontWeight: 700,
|
|
8581
|
-
color:
|
|
8643
|
+
color: evt.color,
|
|
8644
|
+
fontSize: "10px"
|
|
8582
8645
|
},
|
|
8583
|
-
children:
|
|
8646
|
+
children: evt.label
|
|
8584
8647
|
}),
|
|
8585
8648
|
/* @__PURE__ */ jsx2("span", {
|
|
8586
8649
|
style: {
|
|
@@ -8596,11 +8659,9 @@ var StormcloudVideoPlayerComponent = React2.memo(function(props) {
|
|
|
8596
8659
|
whiteSpace: "nowrap"
|
|
8597
8660
|
},
|
|
8598
8661
|
children: [
|
|
8599
|
-
entry.
|
|
8600
|
-
" ",
|
|
8601
|
-
entry.
|
|
8602
|
-
" ",
|
|
8603
|
-
formatDebugRaw(entry.raw)
|
|
8662
|
+
entry.segmentName,
|
|
8663
|
+
entry.offsetSeconds != null ? " +".concat(entry.offsetSeconds, "s") : "",
|
|
8664
|
+
entry.detail ? " (".concat(entry.detail, ")") : ""
|
|
8604
8665
|
]
|
|
8605
8666
|
})
|
|
8606
8667
|
})
|