stormcloud-video-player 0.7.9 → 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 +474 -236
- 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 +477 -239
- 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/OverlayRenderer.cjs +247 -6
- package/lib/ui/OverlayRenderer.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +474 -236
- 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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as StormcloudVideoPlayerConfig, a as Scte35Marker } from '../types-
|
|
1
|
+
import { S as StormcloudVideoPlayerConfig, a as Scte35Marker } from '../types-jU4lq0ST.cjs';
|
|
2
2
|
|
|
3
3
|
type DebugLogLevel = "info" | "warn" | "error";
|
|
4
4
|
declare class StormcloudVideoPlayer {
|
|
@@ -38,6 +38,10 @@ declare class StormcloudVideoPlayer {
|
|
|
38
38
|
private isShowingPlaceholder;
|
|
39
39
|
private timeUpdateHandler?;
|
|
40
40
|
private emptiedHandler?;
|
|
41
|
+
private adInsertionPollingId;
|
|
42
|
+
private lastAdInsertionPoint;
|
|
43
|
+
private processedAdInsertionUpdatedAt;
|
|
44
|
+
private adInsertionOffsetTimerId;
|
|
41
45
|
private totalAdRequestsInBreak;
|
|
42
46
|
private readonly maxTotalAdRequestsPerBreak;
|
|
43
47
|
private pendingAdBreak;
|
|
@@ -59,6 +63,7 @@ declare class StormcloudVideoPlayer {
|
|
|
59
63
|
private fillerBreakTimerId;
|
|
60
64
|
private debugLogEntries;
|
|
61
65
|
private scteMarkerHistory;
|
|
66
|
+
private adInsertionDebugHistory;
|
|
62
67
|
constructor(config: StormcloudVideoPlayerConfig);
|
|
63
68
|
private adRequest;
|
|
64
69
|
load(): Promise<void>;
|
|
@@ -96,6 +101,12 @@ declare class StormcloudVideoPlayer {
|
|
|
96
101
|
private runAdPrefetch;
|
|
97
102
|
private clearPendingAdBreak;
|
|
98
103
|
private cancelAndClearPreloadedTokens;
|
|
104
|
+
private startAdInsertionPolling;
|
|
105
|
+
private stopAdInsertionPolling;
|
|
106
|
+
private fetchAdInsertionPoint;
|
|
107
|
+
private checkAdInsertionInManifest;
|
|
108
|
+
private fragmentMatchesSegment;
|
|
109
|
+
private clearAdInsertionOffsetTimer;
|
|
99
110
|
private startContinuousFetchLoop;
|
|
100
111
|
private runContinuousFetchLoop;
|
|
101
112
|
private handleAdStart;
|
|
@@ -127,6 +138,15 @@ declare class StormcloudVideoPlayer {
|
|
|
127
138
|
durationSeconds?: number;
|
|
128
139
|
raw?: unknown;
|
|
129
140
|
}>;
|
|
141
|
+
private pushAdInsertionDebug;
|
|
142
|
+
getAdInsertionDebugLog(): ReadonlyArray<{
|
|
143
|
+
timestampMs: number;
|
|
144
|
+
event: string;
|
|
145
|
+
segmentName: string;
|
|
146
|
+
offsetSeconds?: number;
|
|
147
|
+
updatedAt?: string;
|
|
148
|
+
detail?: string;
|
|
149
|
+
}>;
|
|
130
150
|
getDebugLogs(): ReadonlyArray<{
|
|
131
151
|
timestampMs: number;
|
|
132
152
|
level: DebugLogLevel;
|
|
@@ -2804,6 +2804,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
2804
2804
|
this.isInAdTransition = false;
|
|
2805
2805
|
this.maxPlaceholderDurationMs = 5e3;
|
|
2806
2806
|
this.isShowingPlaceholder = false;
|
|
2807
|
+
this.lastAdInsertionPoint = null;
|
|
2808
|
+
this.processedAdInsertionUpdatedAt = null;
|
|
2807
2809
|
this.totalAdRequestsInBreak = 0;
|
|
2808
2810
|
this.maxTotalAdRequestsPerBreak = 20;
|
|
2809
2811
|
this.pendingAdBreak = null;
|
|
@@ -2821,6 +2823,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
2821
2823
|
this.preloadedTokens = [];
|
|
2822
2824
|
this.debugLogEntries = [];
|
|
2823
2825
|
this.scteMarkerHistory = [];
|
|
2826
|
+
this.adInsertionDebugHistory = [];
|
|
2824
2827
|
initializePolyfills();
|
|
2825
2828
|
var browserOverrides = getBrowserConfigOverrides();
|
|
2826
2829
|
this.config = _object_spread({}, browserOverrides, config);
|
|
@@ -3005,6 +3008,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3005
3008
|
_state.sent();
|
|
3006
3009
|
_state.label = 2;
|
|
3007
3010
|
case 2:
|
|
3011
|
+
if (!this.config.disableAds && this.config.projectId) {
|
|
3012
|
+
this.startAdInsertionPolling();
|
|
3013
|
+
}
|
|
3008
3014
|
return [
|
|
3009
3015
|
2
|
|
3010
3016
|
];
|
|
@@ -3012,78 +3018,11 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3012
3018
|
});
|
|
3013
3019
|
}).call(_this);
|
|
3014
3020
|
});
|
|
3015
|
-
this.hls.on(import_hls.default.Events.LEVEL_LOADED, function(
|
|
3021
|
+
this.hls.on(import_hls.default.Events.LEVEL_LOADED, function() {
|
|
3016
3022
|
if (_this.inAdBreak || _this.pendingAdBreak) {
|
|
3017
3023
|
return;
|
|
3018
3024
|
}
|
|
3019
|
-
|
|
3020
|
-
if (!details || !details.fragments || details.fragments.length === 0) {
|
|
3021
|
-
return;
|
|
3022
|
-
}
|
|
3023
|
-
var fragmentsToScan = Math.min(5, details.fragments.length);
|
|
3024
|
-
for(var i = 0; i < fragmentsToScan; i++){
|
|
3025
|
-
var frag = details.fragments[i];
|
|
3026
|
-
var tagList = frag === null || frag === void 0 ? void 0 : frag.tagList;
|
|
3027
|
-
if (!Array.isArray(tagList)) continue;
|
|
3028
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
3029
|
-
try {
|
|
3030
|
-
for(var _iterator = tagList[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
3031
|
-
var entry = _step.value;
|
|
3032
|
-
var tag = "";
|
|
3033
|
-
var value = "";
|
|
3034
|
-
if (Array.isArray(entry)) {
|
|
3035
|
-
var _entry_, _entry_1;
|
|
3036
|
-
tag = String((_entry_ = entry[0]) !== null && _entry_ !== void 0 ? _entry_ : "");
|
|
3037
|
-
value = String((_entry_1 = entry[1]) !== null && _entry_1 !== void 0 ? _entry_1 : "");
|
|
3038
|
-
} else if (typeof entry === "string") {
|
|
3039
|
-
var idx = entry.indexOf(":");
|
|
3040
|
-
if (idx >= 0) {
|
|
3041
|
-
tag = entry.substring(0, idx);
|
|
3042
|
-
value = entry.substring(idx + 1);
|
|
3043
|
-
} else {
|
|
3044
|
-
tag = entry;
|
|
3045
|
-
}
|
|
3046
|
-
}
|
|
3047
|
-
if (!tag) continue;
|
|
3048
|
-
if (tag.includes("EXT-X-CUE-OUT") || tag.includes("EXT-X-DATERANGE")) {
|
|
3049
|
-
var attrs = tag.includes("EXT-X-DATERANGE") ? _this.parseAttributeList(value) : {};
|
|
3050
|
-
var hasScteOut = tag.includes("EXT-X-CUE-OUT") || "SCTE35-OUT" in attrs || attrs["SCTE35-OUT"] !== void 0;
|
|
3051
|
-
if (hasScteOut) {
|
|
3052
|
-
var durationSeconds = _this.parseCueOutDuration(value);
|
|
3053
|
-
var marker = _object_spread_props(_object_spread({
|
|
3054
|
-
type: "start"
|
|
3055
|
-
}, durationSeconds !== void 0 ? {
|
|
3056
|
-
durationSeconds: durationSeconds
|
|
3057
|
-
} : {}), {
|
|
3058
|
-
raw: {
|
|
3059
|
-
tag: tag,
|
|
3060
|
-
value: value,
|
|
3061
|
-
earlyDetection: true
|
|
3062
|
-
}
|
|
3063
|
-
});
|
|
3064
|
-
if (_this.config.debugAdTiming) {
|
|
3065
|
-
console.log("[StormcloudVideoPlayer] \uD83C\uDFAF EARLY SCTE-35 DETECTION: Ad break marker found in fragment", i, "- starting pre-fetch (NOT playing yet)");
|
|
3066
|
-
}
|
|
3067
|
-
_this.startAdPrefetch(marker, frag === null || frag === void 0 ? void 0 : frag.sn);
|
|
3068
|
-
return;
|
|
3069
|
-
}
|
|
3070
|
-
}
|
|
3071
|
-
}
|
|
3072
|
-
} catch (err) {
|
|
3073
|
-
_didIteratorError = true;
|
|
3074
|
-
_iteratorError = err;
|
|
3075
|
-
} finally{
|
|
3076
|
-
try {
|
|
3077
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
3078
|
-
_iterator.return();
|
|
3079
|
-
}
|
|
3080
|
-
} finally{
|
|
3081
|
-
if (_didIteratorError) {
|
|
3082
|
-
throw _iteratorError;
|
|
3083
|
-
}
|
|
3084
|
-
}
|
|
3085
|
-
}
|
|
3086
|
-
}
|
|
3025
|
+
_this.checkAdInsertionInManifest();
|
|
3087
3026
|
});
|
|
3088
3027
|
this.hls.on(import_hls.default.Events.FRAG_BUFFERED, function(_evt, data) {
|
|
3089
3028
|
return _async_to_generator(function() {
|
|
@@ -3145,124 +3084,42 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3145
3084
|
});
|
|
3146
3085
|
}).call(_this);
|
|
3147
3086
|
});
|
|
3148
|
-
this.hls.on(import_hls.default.Events.FRAG_PARSING_METADATA, function(_evt, data) {
|
|
3149
|
-
var id3Tags = ((data === null || data === void 0 ? void 0 : data.samples) || []).map(function(s) {
|
|
3150
|
-
return {
|
|
3151
|
-
key: "ID3",
|
|
3152
|
-
value: s === null || s === void 0 ? void 0 : s.data,
|
|
3153
|
-
ptsSeconds: s === null || s === void 0 ? void 0 : s.pts
|
|
3154
|
-
};
|
|
3155
|
-
});
|
|
3156
|
-
id3Tags.forEach(function(tag) {
|
|
3157
|
-
return _this.onId3Tag(tag);
|
|
3158
|
-
});
|
|
3159
|
-
});
|
|
3160
3087
|
this.hls.on(import_hls.default.Events.FRAG_CHANGED, function(_evt, data) {
|
|
3161
3088
|
var frag = data === null || data === void 0 ? void 0 : data.frag;
|
|
3162
|
-
|
|
3163
|
-
if (!
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
var
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
var idx = entry.indexOf(":");
|
|
3176
|
-
if (idx >= 0) {
|
|
3177
|
-
tag = entry.substring(0, idx);
|
|
3178
|
-
value = entry.substring(idx + 1);
|
|
3179
|
-
} else {
|
|
3180
|
-
tag = entry;
|
|
3181
|
-
value = "";
|
|
3182
|
-
}
|
|
3089
|
+
if (!frag) return;
|
|
3090
|
+
if (_this.lastAdInsertionPoint && !_this.inAdBreak && _this.lastAdInsertionPoint.updated_at !== _this.processedAdInsertionUpdatedAt) {
|
|
3091
|
+
var segmentName = _this.lastAdInsertionPoint.segment_ts_name;
|
|
3092
|
+
if (_this.fragmentMatchesSegment(frag, segmentName)) {
|
|
3093
|
+
var _ref;
|
|
3094
|
+
_this.processedAdInsertionUpdatedAt = _this.lastAdInsertionPoint.updated_at;
|
|
3095
|
+
var offsetMs = (_this.lastAdInsertionPoint.offset_seconds || 0) * 1e3;
|
|
3096
|
+
_this.pushAdInsertionDebug("segment_playing", segmentName, {
|
|
3097
|
+
offsetSeconds: _this.lastAdInsertionPoint.offset_seconds,
|
|
3098
|
+
detail: "sn=".concat((_ref = frag === null || frag === void 0 ? void 0 : frag.sn) !== null && _ref !== void 0 ? _ref : "?")
|
|
3099
|
+
});
|
|
3100
|
+
if (_this.config.debugAdTiming) {
|
|
3101
|
+
console.log('[StormcloudVideoPlayer] Ad insertion segment "'.concat(segmentName, '" now playing — scheduling ad start in ').concat(offsetMs, "ms"));
|
|
3183
3102
|
}
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
raw: {
|
|
3195
|
-
tag: tag,
|
|
3196
|
-
value: value
|
|
3197
|
-
}
|
|
3103
|
+
_this.pushAdInsertionDebug("ad_scheduled", segmentName, {
|
|
3104
|
+
offsetSeconds: _this.lastAdInsertionPoint.offset_seconds,
|
|
3105
|
+
detail: "in ".concat(offsetMs, "ms, dur=60s")
|
|
3106
|
+
});
|
|
3107
|
+
_this.clearAdInsertionOffsetTimer();
|
|
3108
|
+
_this.adInsertionOffsetTimerId = window.setTimeout(function() {
|
|
3109
|
+
_this.adInsertionOffsetTimerId = void 0;
|
|
3110
|
+
if (_this.inAdBreak) return;
|
|
3111
|
+
_this.pushAdInsertionDebug("ad_triggered", segmentName, {
|
|
3112
|
+
detail: "ad break started (60s)"
|
|
3198
3113
|
});
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
var marker1 = _object_spread_props(_object_spread({
|
|
3203
|
-
type: "start"
|
|
3204
|
-
}, durationSeconds !== void 0 ? {
|
|
3205
|
-
durationSeconds: durationSeconds
|
|
3206
|
-
} : {}), {
|
|
3114
|
+
var marker = {
|
|
3115
|
+
type: "start",
|
|
3116
|
+
durationSeconds: 60,
|
|
3207
3117
|
raw: {
|
|
3208
|
-
|
|
3209
|
-
value: value
|
|
3118
|
+
apiInsertionPoint: _this.lastAdInsertionPoint
|
|
3210
3119
|
}
|
|
3211
|
-
}
|
|
3212
|
-
_this.onScte35Marker(
|
|
3213
|
-
}
|
|
3214
|
-
_this.onScte35Marker({
|
|
3215
|
-
type: "end",
|
|
3216
|
-
raw: {
|
|
3217
|
-
tag: tag,
|
|
3218
|
-
value: value
|
|
3219
|
-
}
|
|
3220
|
-
});
|
|
3221
|
-
} else if (tag.includes("EXT-X-DATERANGE")) {
|
|
3222
|
-
var _attrs_CLASS;
|
|
3223
|
-
var attrs = _this.parseAttributeList(value);
|
|
3224
|
-
var hasScteOut = "SCTE35-OUT" in attrs || attrs["SCTE35-OUT"] !== void 0;
|
|
3225
|
-
var hasScteIn = "SCTE35-IN" in attrs || attrs["SCTE35-IN"] !== void 0;
|
|
3226
|
-
var klass = String((_attrs_CLASS = attrs["CLASS"]) !== null && _attrs_CLASS !== void 0 ? _attrs_CLASS : "");
|
|
3227
|
-
var duration = _this.toNumber(attrs["DURATION"]);
|
|
3228
|
-
if (hasScteOut || /com\.apple\.hls\.cue/i.test(klass)) {
|
|
3229
|
-
var marker2 = _object_spread_props(_object_spread({
|
|
3230
|
-
type: "start"
|
|
3231
|
-
}, duration !== void 0 ? {
|
|
3232
|
-
durationSeconds: duration
|
|
3233
|
-
} : {}), {
|
|
3234
|
-
raw: {
|
|
3235
|
-
tag: tag,
|
|
3236
|
-
value: value,
|
|
3237
|
-
attrs: attrs
|
|
3238
|
-
}
|
|
3239
|
-
});
|
|
3240
|
-
_this.onScte35Marker(marker2);
|
|
3241
|
-
}
|
|
3242
|
-
if (hasScteIn) {
|
|
3243
|
-
_this.onScte35Marker({
|
|
3244
|
-
type: "end",
|
|
3245
|
-
raw: {
|
|
3246
|
-
tag: tag,
|
|
3247
|
-
value: value,
|
|
3248
|
-
attrs: attrs
|
|
3249
|
-
}
|
|
3250
|
-
});
|
|
3251
|
-
}
|
|
3252
|
-
}
|
|
3253
|
-
}
|
|
3254
|
-
} catch (err) {
|
|
3255
|
-
_didIteratorError = true;
|
|
3256
|
-
_iteratorError = err;
|
|
3257
|
-
} finally{
|
|
3258
|
-
try {
|
|
3259
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
3260
|
-
_iterator.return();
|
|
3261
|
-
}
|
|
3262
|
-
} finally{
|
|
3263
|
-
if (_didIteratorError) {
|
|
3264
|
-
throw _iteratorError;
|
|
3265
|
-
}
|
|
3120
|
+
};
|
|
3121
|
+
_this.onScte35Marker(marker);
|
|
3122
|
+
}, offsetMs);
|
|
3266
3123
|
}
|
|
3267
3124
|
}
|
|
3268
3125
|
});
|
|
@@ -4462,6 +4319,182 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4462
4319
|
this.preloadedTokens = [];
|
|
4463
4320
|
}
|
|
4464
4321
|
},
|
|
4322
|
+
{
|
|
4323
|
+
key: "startAdInsertionPolling",
|
|
4324
|
+
value: function startAdInsertionPolling() {
|
|
4325
|
+
var _this = this;
|
|
4326
|
+
if (this.adInsertionPollingId != null) return;
|
|
4327
|
+
this.fetchAdInsertionPoint();
|
|
4328
|
+
this.adInsertionPollingId = window.setInterval(function() {
|
|
4329
|
+
_this.fetchAdInsertionPoint();
|
|
4330
|
+
}, 1e3);
|
|
4331
|
+
}
|
|
4332
|
+
},
|
|
4333
|
+
{
|
|
4334
|
+
key: "stopAdInsertionPolling",
|
|
4335
|
+
value: function stopAdInsertionPolling() {
|
|
4336
|
+
if (this.adInsertionPollingId != null) {
|
|
4337
|
+
clearInterval(this.adInsertionPollingId);
|
|
4338
|
+
this.adInsertionPollingId = void 0;
|
|
4339
|
+
}
|
|
4340
|
+
}
|
|
4341
|
+
},
|
|
4342
|
+
{
|
|
4343
|
+
key: "fetchAdInsertionPoint",
|
|
4344
|
+
value: function fetchAdInsertionPoint() {
|
|
4345
|
+
return _async_to_generator(function() {
|
|
4346
|
+
var _this_lastAdInsertionPoint, resp, data, isNew, unused;
|
|
4347
|
+
return _ts_generator(this, function(_state) {
|
|
4348
|
+
switch(_state.label){
|
|
4349
|
+
case 0:
|
|
4350
|
+
if (!this.config.projectId) return [
|
|
4351
|
+
2
|
|
4352
|
+
];
|
|
4353
|
+
_state.label = 1;
|
|
4354
|
+
case 1:
|
|
4355
|
+
_state.trys.push([
|
|
4356
|
+
1,
|
|
4357
|
+
4,
|
|
4358
|
+
,
|
|
4359
|
+
5
|
|
4360
|
+
]);
|
|
4361
|
+
return [
|
|
4362
|
+
4,
|
|
4363
|
+
fetch("https://adstorm.co/api-adstorm-dev/adstorm/swirl/projects/".concat(encodeURIComponent(this.config.projectId), "/ad-insertion-point"))
|
|
4364
|
+
];
|
|
4365
|
+
case 2:
|
|
4366
|
+
resp = _state.sent();
|
|
4367
|
+
if (!resp.ok) return [
|
|
4368
|
+
2
|
|
4369
|
+
];
|
|
4370
|
+
return [
|
|
4371
|
+
4,
|
|
4372
|
+
resp.json()
|
|
4373
|
+
];
|
|
4374
|
+
case 3:
|
|
4375
|
+
data = _state.sent();
|
|
4376
|
+
isNew = data.updated_at !== ((_this_lastAdInsertionPoint = this.lastAdInsertionPoint) === null || _this_lastAdInsertionPoint === void 0 ? void 0 : _this_lastAdInsertionPoint.updated_at);
|
|
4377
|
+
this.lastAdInsertionPoint = data;
|
|
4378
|
+
if (isNew) {
|
|
4379
|
+
this.pushAdInsertionDebug("api_response", data.segment_ts_name, {
|
|
4380
|
+
offsetSeconds: data.offset_seconds,
|
|
4381
|
+
updatedAt: data.updated_at,
|
|
4382
|
+
detail: "project=".concat(data.project_id)
|
|
4383
|
+
});
|
|
4384
|
+
}
|
|
4385
|
+
if (this.config.debugAdTiming) {
|
|
4386
|
+
console.log("[StormcloudVideoPlayer] Ad insertion point API response:", data);
|
|
4387
|
+
}
|
|
4388
|
+
return [
|
|
4389
|
+
3,
|
|
4390
|
+
5
|
|
4391
|
+
];
|
|
4392
|
+
case 4:
|
|
4393
|
+
unused = _state.sent();
|
|
4394
|
+
if (this.config.debugAdTiming) {
|
|
4395
|
+
console.warn("[StormcloudVideoPlayer] Ad insertion point API fetch failed");
|
|
4396
|
+
}
|
|
4397
|
+
return [
|
|
4398
|
+
3,
|
|
4399
|
+
5
|
|
4400
|
+
];
|
|
4401
|
+
case 5:
|
|
4402
|
+
return [
|
|
4403
|
+
2
|
|
4404
|
+
];
|
|
4405
|
+
}
|
|
4406
|
+
});
|
|
4407
|
+
}).call(this);
|
|
4408
|
+
}
|
|
4409
|
+
},
|
|
4410
|
+
{
|
|
4411
|
+
key: "checkAdInsertionInManifest",
|
|
4412
|
+
value: function checkAdInsertionInManifest() {
|
|
4413
|
+
var _this_hls;
|
|
4414
|
+
if (!this.lastAdInsertionPoint) return;
|
|
4415
|
+
if (this.inAdBreak || this.pendingAdBreak) return;
|
|
4416
|
+
if (this.lastAdInsertionPoint.updated_at === this.processedAdInsertionUpdatedAt) return;
|
|
4417
|
+
var segmentName = this.lastAdInsertionPoint.segment_ts_name;
|
|
4418
|
+
var levels = (_this_hls = this.hls) === null || _this_hls === void 0 ? void 0 : _this_hls.levels;
|
|
4419
|
+
if (!levels) return;
|
|
4420
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
4421
|
+
try {
|
|
4422
|
+
for(var _iterator = levels[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
4423
|
+
var level = _step.value;
|
|
4424
|
+
var _level_details;
|
|
4425
|
+
var fragments = (_level_details = level.details) === null || _level_details === void 0 ? void 0 : _level_details.fragments;
|
|
4426
|
+
if (!Array.isArray(fragments)) continue;
|
|
4427
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
4428
|
+
try {
|
|
4429
|
+
for(var _iterator1 = fragments[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
4430
|
+
var frag = _step1.value;
|
|
4431
|
+
if (this.fragmentMatchesSegment(frag, segmentName)) {
|
|
4432
|
+
var _ref;
|
|
4433
|
+
this.pushAdInsertionDebug("segment_found", segmentName, {
|
|
4434
|
+
detail: "sn=".concat((_ref = frag === null || frag === void 0 ? void 0 : frag.sn) !== null && _ref !== void 0 ? _ref : "?")
|
|
4435
|
+
});
|
|
4436
|
+
if (this.config.debugAdTiming) {
|
|
4437
|
+
console.log('[StormcloudVideoPlayer] Ad insertion segment "'.concat(segmentName, '" found in manifest — starting pre-fetch'));
|
|
4438
|
+
}
|
|
4439
|
+
var marker = {
|
|
4440
|
+
type: "start",
|
|
4441
|
+
durationSeconds: 60,
|
|
4442
|
+
raw: {
|
|
4443
|
+
apiInsertionPoint: this.lastAdInsertionPoint,
|
|
4444
|
+
earlyDetection: true
|
|
4445
|
+
}
|
|
4446
|
+
};
|
|
4447
|
+
this.startAdPrefetch(marker, frag === null || frag === void 0 ? void 0 : frag.sn);
|
|
4448
|
+
return;
|
|
4449
|
+
}
|
|
4450
|
+
}
|
|
4451
|
+
} catch (err) {
|
|
4452
|
+
_didIteratorError1 = true;
|
|
4453
|
+
_iteratorError1 = err;
|
|
4454
|
+
} finally{
|
|
4455
|
+
try {
|
|
4456
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
4457
|
+
_iterator1.return();
|
|
4458
|
+
}
|
|
4459
|
+
} finally{
|
|
4460
|
+
if (_didIteratorError1) {
|
|
4461
|
+
throw _iteratorError1;
|
|
4462
|
+
}
|
|
4463
|
+
}
|
|
4464
|
+
}
|
|
4465
|
+
}
|
|
4466
|
+
} catch (err) {
|
|
4467
|
+
_didIteratorError = true;
|
|
4468
|
+
_iteratorError = err;
|
|
4469
|
+
} finally{
|
|
4470
|
+
try {
|
|
4471
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
4472
|
+
_iterator.return();
|
|
4473
|
+
}
|
|
4474
|
+
} finally{
|
|
4475
|
+
if (_didIteratorError) {
|
|
4476
|
+
throw _iteratorError;
|
|
4477
|
+
}
|
|
4478
|
+
}
|
|
4479
|
+
}
|
|
4480
|
+
}
|
|
4481
|
+
},
|
|
4482
|
+
{
|
|
4483
|
+
key: "fragmentMatchesSegment",
|
|
4484
|
+
value: function fragmentMatchesSegment(frag, segmentName) {
|
|
4485
|
+
var url = (frag === null || frag === void 0 ? void 0 : frag.url) || (frag === null || frag === void 0 ? void 0 : frag.relurl) || "";
|
|
4486
|
+
return url.endsWith(segmentName) || url.includes("/" + segmentName);
|
|
4487
|
+
}
|
|
4488
|
+
},
|
|
4489
|
+
{
|
|
4490
|
+
key: "clearAdInsertionOffsetTimer",
|
|
4491
|
+
value: function clearAdInsertionOffsetTimer() {
|
|
4492
|
+
if (this.adInsertionOffsetTimerId != null) {
|
|
4493
|
+
clearTimeout(this.adInsertionOffsetTimerId);
|
|
4494
|
+
this.adInsertionOffsetTimerId = void 0;
|
|
4495
|
+
}
|
|
4496
|
+
}
|
|
4497
|
+
},
|
|
4465
4498
|
{
|
|
4466
4499
|
key: "startContinuousFetchLoop",
|
|
4467
4500
|
value: function startContinuousFetchLoop() {
|
|
@@ -5383,6 +5416,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5383
5416
|
}
|
|
5384
5417
|
this.clearAdRequestWatchdog();
|
|
5385
5418
|
this.clearAdFailsafeTimer();
|
|
5419
|
+
this.clearAdInsertionOffsetTimer();
|
|
5386
5420
|
this.activeAdRequestToken = null;
|
|
5387
5421
|
this.isInAdTransition = false;
|
|
5388
5422
|
this.stopContinuousFetching();
|
|
@@ -5713,6 +5747,32 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5713
5747
|
});
|
|
5714
5748
|
}
|
|
5715
5749
|
},
|
|
5750
|
+
{
|
|
5751
|
+
key: "pushAdInsertionDebug",
|
|
5752
|
+
value: function pushAdInsertionDebug(event, segmentName, opts) {
|
|
5753
|
+
if (!this.config.debugAdTiming) return;
|
|
5754
|
+
this.adInsertionDebugHistory.push(_object_spread({
|
|
5755
|
+
timestampMs: Date.now(),
|
|
5756
|
+
event: event,
|
|
5757
|
+
segmentName: segmentName
|
|
5758
|
+
}, (opts === null || opts === void 0 ? void 0 : opts.offsetSeconds) !== void 0 ? {
|
|
5759
|
+
offsetSeconds: opts.offsetSeconds
|
|
5760
|
+
} : {}, (opts === null || opts === void 0 ? void 0 : opts.updatedAt) ? {
|
|
5761
|
+
updatedAt: opts.updatedAt
|
|
5762
|
+
} : {}, (opts === null || opts === void 0 ? void 0 : opts.detail) ? {
|
|
5763
|
+
detail: opts.detail
|
|
5764
|
+
} : {}));
|
|
5765
|
+
if (this.adInsertionDebugHistory.length > DEBUG_HISTORY_LIMIT) {
|
|
5766
|
+
this.adInsertionDebugHistory = this.adInsertionDebugHistory.slice(-DEBUG_HISTORY_LIMIT);
|
|
5767
|
+
}
|
|
5768
|
+
}
|
|
5769
|
+
},
|
|
5770
|
+
{
|
|
5771
|
+
key: "getAdInsertionDebugLog",
|
|
5772
|
+
value: function getAdInsertionDebugLog() {
|
|
5773
|
+
return this.adInsertionDebugHistory.slice();
|
|
5774
|
+
}
|
|
5775
|
+
},
|
|
5716
5776
|
{
|
|
5717
5777
|
key: "getDebugLogs",
|
|
5718
5778
|
value: function getDebugLogs() {
|
|
@@ -5979,6 +6039,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5979
6039
|
key: "destroy",
|
|
5980
6040
|
value: function destroy() {
|
|
5981
6041
|
var _this_hls, _this_adLayer;
|
|
6042
|
+
this.stopAdInsertionPolling();
|
|
6043
|
+
this.clearAdInsertionOffsetTimer();
|
|
5982
6044
|
this.stopContinuousFetching();
|
|
5983
6045
|
this.stopFillerBreakTimer();
|
|
5984
6046
|
this.clearAdStartTimer();
|
|
@@ -6010,6 +6072,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6010
6072
|
this.consecutiveFailures = 0;
|
|
6011
6073
|
this.debugLogEntries = [];
|
|
6012
6074
|
this.scteMarkerHistory = [];
|
|
6075
|
+
this.adInsertionDebugHistory = [];
|
|
6013
6076
|
}
|
|
6014
6077
|
}
|
|
6015
6078
|
]);
|