stormcloud-video-player 0.7.10 → 0.7.12
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 +573 -964
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +20 -29
- package/lib/index.d.ts +20 -29
- package/lib/index.js +574 -965
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +411 -887
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/player/StormcloudVideoPlayer.d.cts +20 -24
- package/lib/players/HlsPlayer.cjs +411 -887
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.d.cts +1 -1
- package/lib/players/index.cjs +411 -887
- package/lib/players/index.cjs.map +1 -1
- package/lib/sdk/adstormPlayer.cjs +9 -1
- package/lib/sdk/adstormPlayer.cjs.map +1 -1
- package/lib/sdk/adstormPlayer.d.cts +1 -1
- package/lib/{types-ClqQZM3U.d.cts → types-DrBGHN4q.d.cts} +2 -7
- package/lib/ui/StormcloudVideoPlayer.cjs +573 -964
- 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/players/index.cjs
CHANGED
|
@@ -1479,7 +1479,6 @@ function createAdStormPlayer(contentVideo, options) {
|
|
|
1479
1479
|
contentVideo.muted = originalMutedState;
|
|
1480
1480
|
contentVideo.volume = originalVolume;
|
|
1481
1481
|
currentAd = void 0;
|
|
1482
|
-
tornDown = false;
|
|
1483
1482
|
return [
|
|
1484
1483
|
2,
|
|
1485
1484
|
Promise.resolve()
|
|
@@ -1594,6 +1593,15 @@ function createAdStormPlayer(contentVideo, options) {
|
|
|
1594
1593
|
if (!token) return [
|
|
1595
1594
|
2
|
|
1596
1595
|
];
|
|
1596
|
+
if (currentAd) {
|
|
1597
|
+
preloadSlots.set(token, {
|
|
1598
|
+
ad: currentAd
|
|
1599
|
+
});
|
|
1600
|
+
currentAd = void 0;
|
|
1601
|
+
return [
|
|
1602
|
+
2
|
|
1603
|
+
];
|
|
1604
|
+
}
|
|
1597
1605
|
requestContext = typeof arg1 === "string" ? arg2 : arg1;
|
|
1598
1606
|
return [
|
|
1599
1607
|
4,
|
|
@@ -2087,56 +2095,6 @@ function sendInitialTracking(licenseKey) {
|
|
|
2087
2095
|
});
|
|
2088
2096
|
})();
|
|
2089
2097
|
}
|
|
2090
|
-
function sendAdDetectTracking(licenseKey, adDetectInfo) {
|
|
2091
|
-
return _async_to_generator(function() {
|
|
2092
|
-
var clientInfo, browserId, trackingData, error;
|
|
2093
|
-
return _ts_generator(this, function(_state) {
|
|
2094
|
-
switch(_state.label){
|
|
2095
|
-
case 0:
|
|
2096
|
-
_state.trys.push([
|
|
2097
|
-
0,
|
|
2098
|
-
3,
|
|
2099
|
-
,
|
|
2100
|
-
4
|
|
2101
|
-
]);
|
|
2102
|
-
clientInfo = getClientInfo();
|
|
2103
|
-
return [
|
|
2104
|
-
4,
|
|
2105
|
-
getBrowserID(clientInfo)
|
|
2106
|
-
];
|
|
2107
|
-
case 1:
|
|
2108
|
-
browserId = _state.sent();
|
|
2109
|
-
trackingData = _object_spread({
|
|
2110
|
-
browserId: browserId
|
|
2111
|
-
}, clientInfo);
|
|
2112
|
-
return [
|
|
2113
|
-
4,
|
|
2114
|
-
sendTrackRequest(licenseKey, _object_spread_props(_object_spread({}, trackingData), {
|
|
2115
|
-
licenseKey: licenseKey,
|
|
2116
|
-
adDetectInfo: adDetectInfo
|
|
2117
|
-
}))
|
|
2118
|
-
];
|
|
2119
|
-
case 2:
|
|
2120
|
-
_state.sent();
|
|
2121
|
-
return [
|
|
2122
|
-
3,
|
|
2123
|
-
4
|
|
2124
|
-
];
|
|
2125
|
-
case 3:
|
|
2126
|
-
error = _state.sent();
|
|
2127
|
-
console.error("[StormcloudVideoPlayer] Error sending ad detect tracking:", error);
|
|
2128
|
-
return [
|
|
2129
|
-
3,
|
|
2130
|
-
4
|
|
2131
|
-
];
|
|
2132
|
-
case 4:
|
|
2133
|
-
return [
|
|
2134
|
-
2
|
|
2135
|
-
];
|
|
2136
|
-
}
|
|
2137
|
-
});
|
|
2138
|
-
})();
|
|
2139
|
-
}
|
|
2140
2098
|
function sendAdLoadedTracking(licenseKey, adLoadedInfo) {
|
|
2141
2099
|
return _async_to_generator(function() {
|
|
2142
2100
|
var clientInfo, browserId, trackingData, error;
|
|
@@ -2821,7 +2779,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
2821
2779
|
this.continuousFetchLoopPromise = null;
|
|
2822
2780
|
this.attached = false;
|
|
2823
2781
|
this.inAdBreak = false;
|
|
2824
|
-
this.ptsDriftEmaMs = 0;
|
|
2825
2782
|
this.adPodQueue = [];
|
|
2826
2783
|
this.lastHeartbeatTime = 0;
|
|
2827
2784
|
this.currentAdIndex = 0;
|
|
@@ -2840,10 +2797,12 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
2840
2797
|
this.isInAdTransition = false;
|
|
2841
2798
|
this.maxPlaceholderDurationMs = 5e3;
|
|
2842
2799
|
this.isShowingPlaceholder = false;
|
|
2800
|
+
this.lastAdInsertionPoint = null;
|
|
2801
|
+
this.processedAdInsertionUpdatedAt = null;
|
|
2843
2802
|
this.totalAdRequestsInBreak = 0;
|
|
2844
2803
|
this.maxTotalAdRequestsPerBreak = 20;
|
|
2845
2804
|
this.pendingAdBreak = null;
|
|
2846
|
-
this.
|
|
2805
|
+
this.savedMutedStateBeforeAd = null;
|
|
2847
2806
|
this.consecutiveFailures = 0;
|
|
2848
2807
|
this.maxConsecutiveFailures = 5;
|
|
2849
2808
|
this.lastAdRequestTime = 0;
|
|
@@ -2856,7 +2815,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
2856
2815
|
this.adRequestRetryBackoffMs = 1500;
|
|
2857
2816
|
this.preloadedTokens = [];
|
|
2858
2817
|
this.debugLogEntries = [];
|
|
2859
|
-
this.
|
|
2818
|
+
this.adInsertionDebugHistory = [];
|
|
2860
2819
|
initializePolyfills();
|
|
2861
2820
|
var browserOverrides = getBrowserConfigOverrides();
|
|
2862
2821
|
this.config = _object_spread({}, browserOverrides, config);
|
|
@@ -3041,6 +3000,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3041
3000
|
_state.sent();
|
|
3042
3001
|
_state.label = 2;
|
|
3043
3002
|
case 2:
|
|
3003
|
+
if (!this.config.disableAds && this.config.projectId) {
|
|
3004
|
+
this.startAdInsertionPolling();
|
|
3005
|
+
}
|
|
3044
3006
|
return [
|
|
3045
3007
|
2
|
|
3046
3008
|
];
|
|
@@ -3048,78 +3010,11 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3048
3010
|
});
|
|
3049
3011
|
}).call(_this);
|
|
3050
3012
|
});
|
|
3051
|
-
this.hls.on(import_hls.default.Events.LEVEL_LOADED, function(
|
|
3013
|
+
this.hls.on(import_hls.default.Events.LEVEL_LOADED, function() {
|
|
3052
3014
|
if (_this.inAdBreak || _this.pendingAdBreak) {
|
|
3053
3015
|
return;
|
|
3054
3016
|
}
|
|
3055
|
-
|
|
3056
|
-
if (!details || !details.fragments || details.fragments.length === 0) {
|
|
3057
|
-
return;
|
|
3058
|
-
}
|
|
3059
|
-
var fragmentsToScan = Math.min(5, details.fragments.length);
|
|
3060
|
-
for(var i = 0; i < fragmentsToScan; i++){
|
|
3061
|
-
var frag = details.fragments[i];
|
|
3062
|
-
var tagList = frag === null || frag === void 0 ? void 0 : frag.tagList;
|
|
3063
|
-
if (!Array.isArray(tagList)) continue;
|
|
3064
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
3065
|
-
try {
|
|
3066
|
-
for(var _iterator = tagList[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
3067
|
-
var entry = _step.value;
|
|
3068
|
-
var tag = "";
|
|
3069
|
-
var value = "";
|
|
3070
|
-
if (Array.isArray(entry)) {
|
|
3071
|
-
var _entry_, _entry_1;
|
|
3072
|
-
tag = String((_entry_ = entry[0]) !== null && _entry_ !== void 0 ? _entry_ : "");
|
|
3073
|
-
value = String((_entry_1 = entry[1]) !== null && _entry_1 !== void 0 ? _entry_1 : "");
|
|
3074
|
-
} else if (typeof entry === "string") {
|
|
3075
|
-
var idx = entry.indexOf(":");
|
|
3076
|
-
if (idx >= 0) {
|
|
3077
|
-
tag = entry.substring(0, idx);
|
|
3078
|
-
value = entry.substring(idx + 1);
|
|
3079
|
-
} else {
|
|
3080
|
-
tag = entry;
|
|
3081
|
-
}
|
|
3082
|
-
}
|
|
3083
|
-
if (!tag) continue;
|
|
3084
|
-
if (tag.includes("EXT-X-CUE-OUT") || tag.includes("EXT-X-DATERANGE")) {
|
|
3085
|
-
var attrs = tag.includes("EXT-X-DATERANGE") ? _this.parseAttributeList(value) : {};
|
|
3086
|
-
var hasScteOut = tag.includes("EXT-X-CUE-OUT") || "SCTE35-OUT" in attrs || attrs["SCTE35-OUT"] !== void 0;
|
|
3087
|
-
if (hasScteOut) {
|
|
3088
|
-
var durationSeconds = _this.parseCueOutDuration(value);
|
|
3089
|
-
var marker = _object_spread_props(_object_spread({
|
|
3090
|
-
type: "start"
|
|
3091
|
-
}, durationSeconds !== void 0 ? {
|
|
3092
|
-
durationSeconds: durationSeconds
|
|
3093
|
-
} : {}), {
|
|
3094
|
-
raw: {
|
|
3095
|
-
tag: tag,
|
|
3096
|
-
value: value,
|
|
3097
|
-
earlyDetection: true
|
|
3098
|
-
}
|
|
3099
|
-
});
|
|
3100
|
-
if (_this.config.debugAdTiming) {
|
|
3101
|
-
console.log("[StormcloudVideoPlayer] \uD83C\uDFAF EARLY SCTE-35 DETECTION: Ad break marker found in fragment", i, "- starting pre-fetch (NOT playing yet)");
|
|
3102
|
-
}
|
|
3103
|
-
_this.startAdPrefetch(marker, frag === null || frag === void 0 ? void 0 : frag.sn);
|
|
3104
|
-
return;
|
|
3105
|
-
}
|
|
3106
|
-
}
|
|
3107
|
-
}
|
|
3108
|
-
} catch (err) {
|
|
3109
|
-
_didIteratorError = true;
|
|
3110
|
-
_iteratorError = err;
|
|
3111
|
-
} finally{
|
|
3112
|
-
try {
|
|
3113
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
3114
|
-
_iterator.return();
|
|
3115
|
-
}
|
|
3116
|
-
} finally{
|
|
3117
|
-
if (_didIteratorError) {
|
|
3118
|
-
throw _iteratorError;
|
|
3119
|
-
}
|
|
3120
|
-
}
|
|
3121
|
-
}
|
|
3122
|
-
}
|
|
3017
|
+
_this.checkAdInsertionInManifest();
|
|
3123
3018
|
});
|
|
3124
3019
|
this.hls.on(import_hls.default.Events.FRAG_BUFFERED, function(_evt, data) {
|
|
3125
3020
|
return _async_to_generator(function() {
|
|
@@ -3181,111 +3076,55 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3181
3076
|
});
|
|
3182
3077
|
}).call(_this);
|
|
3183
3078
|
});
|
|
3184
|
-
this.hls.on(import_hls.default.Events.FRAG_PARSING_METADATA, function(_evt, data) {
|
|
3185
|
-
var id3Tags = ((data === null || data === void 0 ? void 0 : data.samples) || []).map(function(s) {
|
|
3186
|
-
return {
|
|
3187
|
-
key: "ID3",
|
|
3188
|
-
value: s === null || s === void 0 ? void 0 : s.data,
|
|
3189
|
-
ptsSeconds: s === null || s === void 0 ? void 0 : s.pts
|
|
3190
|
-
};
|
|
3191
|
-
});
|
|
3192
|
-
id3Tags.forEach(function(tag) {
|
|
3193
|
-
return _this.onId3Tag(tag);
|
|
3194
|
-
});
|
|
3195
|
-
});
|
|
3196
3079
|
this.hls.on(import_hls.default.Events.FRAG_CHANGED, function(_evt, data) {
|
|
3197
3080
|
var frag = data === null || data === void 0 ? void 0 : data.frag;
|
|
3198
|
-
|
|
3199
|
-
if (!
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
var
|
|
3205
|
-
|
|
3206
|
-
|
|
3207
|
-
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
var idx = entry.indexOf(":");
|
|
3212
|
-
if (idx >= 0) {
|
|
3213
|
-
tag = entry.substring(0, idx);
|
|
3214
|
-
value = entry.substring(idx + 1);
|
|
3215
|
-
} else {
|
|
3216
|
-
tag = entry;
|
|
3217
|
-
value = "";
|
|
3218
|
-
}
|
|
3081
|
+
if (!frag) return;
|
|
3082
|
+
if (_this.lastAdInsertionPoint && !_this.inAdBreak && _this.lastAdInsertionPoint.updated_at !== _this.processedAdInsertionUpdatedAt) {
|
|
3083
|
+
var segmentName = _this.lastAdInsertionPoint.segment_ts_name;
|
|
3084
|
+
if (_this.fragmentMatchesSegment(frag, segmentName)) {
|
|
3085
|
+
var _ref;
|
|
3086
|
+
_this.processedAdInsertionUpdatedAt = _this.lastAdInsertionPoint.updated_at;
|
|
3087
|
+
var offsetMs = (_this.lastAdInsertionPoint.offset_seconds || 0) * 1e3;
|
|
3088
|
+
_this.pushAdInsertionDebug("segment_playing", segmentName, {
|
|
3089
|
+
offsetSeconds: _this.lastAdInsertionPoint.offset_seconds,
|
|
3090
|
+
detail: "sn=".concat((_ref = frag === null || frag === void 0 ? void 0 : frag.sn) !== null && _ref !== void 0 ? _ref : "?")
|
|
3091
|
+
});
|
|
3092
|
+
if (_this.config.debugAdTiming) {
|
|
3093
|
+
console.log('[StormcloudVideoPlayer] Ad insertion segment "'.concat(segmentName, '" now playing — scheduling ad start in ').concat(offsetMs, "ms"));
|
|
3219
3094
|
}
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
raw: {
|
|
3231
|
-
tag: tag,
|
|
3232
|
-
value: value
|
|
3233
|
-
}
|
|
3234
|
-
});
|
|
3235
|
-
_this.onScte35Marker(marker);
|
|
3236
|
-
} else if (tag.includes("EXT-X-CUE-OUT")) {
|
|
3237
|
-
var durationSeconds = _this.parseCueOutDuration(value);
|
|
3238
|
-
var marker1 = _object_spread_props(_object_spread({
|
|
3239
|
-
type: "start"
|
|
3240
|
-
}, durationSeconds !== void 0 ? {
|
|
3241
|
-
durationSeconds: durationSeconds
|
|
3242
|
-
} : {}), {
|
|
3243
|
-
raw: {
|
|
3244
|
-
tag: tag,
|
|
3245
|
-
value: value
|
|
3246
|
-
}
|
|
3095
|
+
_this.pushAdInsertionDebug("ad_scheduled", segmentName, {
|
|
3096
|
+
offsetSeconds: _this.lastAdInsertionPoint.offset_seconds,
|
|
3097
|
+
detail: "in ".concat(offsetMs, "ms, dur=60s")
|
|
3098
|
+
});
|
|
3099
|
+
_this.clearAdInsertionOffsetTimer();
|
|
3100
|
+
_this.adInsertionOffsetTimerId = window.setTimeout(function() {
|
|
3101
|
+
_this.adInsertionOffsetTimerId = void 0;
|
|
3102
|
+
if (_this.inAdBreak) return;
|
|
3103
|
+
_this.pushAdInsertionDebug("ad_triggered", segmentName, {
|
|
3104
|
+
detail: "ad break started (60s)"
|
|
3247
3105
|
});
|
|
3248
|
-
_this.
|
|
3249
|
-
}
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
|
|
3260
|
-
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
raw: {
|
|
3271
|
-
tag: tag,
|
|
3272
|
-
value: value,
|
|
3273
|
-
attrs: attrs
|
|
3274
|
-
}
|
|
3275
|
-
});
|
|
3276
|
-
_this.onScte35Marker(marker2);
|
|
3277
|
-
}
|
|
3278
|
-
if (hasScteIn) {
|
|
3279
|
-
_this.onScte35Marker({
|
|
3280
|
-
type: "end",
|
|
3281
|
-
raw: {
|
|
3282
|
-
tag: tag,
|
|
3283
|
-
value: value,
|
|
3284
|
-
attrs: attrs
|
|
3285
|
-
}
|
|
3286
|
-
});
|
|
3287
|
-
}
|
|
3288
|
-
}
|
|
3106
|
+
void _this.handleAdStart(60);
|
|
3107
|
+
}, offsetMs);
|
|
3108
|
+
}
|
|
3109
|
+
}
|
|
3110
|
+
});
|
|
3111
|
+
this.hls.on(import_hls.default.Events.FRAG_PARSING_USERDATA, function(_evt, data) {
|
|
3112
|
+
var _ref;
|
|
3113
|
+
var samples = (_ref = data === null || data === void 0 ? void 0 : data.samples) !== null && _ref !== void 0 ? _ref : [];
|
|
3114
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
3115
|
+
try {
|
|
3116
|
+
for(var _iterator = samples[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
3117
|
+
var sample = _step.value;
|
|
3118
|
+
var _ref1, _ref2;
|
|
3119
|
+
var _data_frag, _data_frag1;
|
|
3120
|
+
var bytes = sample === null || sample === void 0 ? void 0 : sample.data;
|
|
3121
|
+
if (!bytes || bytes.length < 5) continue;
|
|
3122
|
+
var isSCTE35 = bytes[0] === 252;
|
|
3123
|
+
if (!isSCTE35) continue;
|
|
3124
|
+
var segName = (_ref1 = (_ref2 = data === null || data === void 0 ? void 0 : (_data_frag = data.frag) === null || _data_frag === void 0 ? void 0 : _data_frag.relurl) !== null && _ref2 !== void 0 ? _ref2 : data === null || data === void 0 ? void 0 : (_data_frag1 = data.frag) === null || _data_frag1 === void 0 ? void 0 : _data_frag1.url) !== null && _ref1 !== void 0 ? _ref1 : "";
|
|
3125
|
+
_this.pushAdInsertionDebug("scte35_inserted", segName, {
|
|
3126
|
+
detail: "len=".concat(bytes.length, "B")
|
|
3127
|
+
});
|
|
3289
3128
|
}
|
|
3290
3129
|
} catch (err) {
|
|
3291
3130
|
_didIteratorError = true;
|
|
@@ -3376,8 +3215,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3376
3215
|
_this.activeAdRequestToken = null;
|
|
3377
3216
|
_this.showAds = true;
|
|
3378
3217
|
if (_this.config.disableFiller) {
|
|
3379
|
-
if (_this.
|
|
3380
|
-
_this.
|
|
3218
|
+
if (_this.savedMutedStateBeforeAd == null) {
|
|
3219
|
+
_this.savedMutedStateBeforeAd = {
|
|
3381
3220
|
muted: _this.video.muted,
|
|
3382
3221
|
volume: _this.video.volume
|
|
3383
3222
|
};
|
|
@@ -3405,10 +3244,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3405
3244
|
});
|
|
3406
3245
|
this.adLayer.on("content_resume", function() {
|
|
3407
3246
|
var _ref, _ref1;
|
|
3408
|
-
var
|
|
3247
|
+
var _this_savedMutedStateBeforeAd, _this_savedMutedStateBeforeAd1;
|
|
3409
3248
|
var remaining = _this.getRemainingAdMs();
|
|
3410
|
-
var breakMuted = (_ref = (
|
|
3411
|
-
var breakVolume = (_ref1 = (
|
|
3249
|
+
var breakMuted = (_ref = (_this_savedMutedStateBeforeAd = _this.savedMutedStateBeforeAd) === null || _this_savedMutedStateBeforeAd === void 0 ? void 0 : _this_savedMutedStateBeforeAd.muted) !== null && _ref !== void 0 ? _ref : _this.adLayer.getOriginalMutedState();
|
|
3250
|
+
var breakVolume = (_ref1 = (_this_savedMutedStateBeforeAd1 = _this.savedMutedStateBeforeAd) === null || _this_savedMutedStateBeforeAd1 === void 0 ? void 0 : _this_savedMutedStateBeforeAd1.volume) !== null && _ref1 !== void 0 ? _ref1 : _this.adLayer.getOriginalVolume();
|
|
3412
3251
|
if (_this.config.debugAdTiming) {
|
|
3413
3252
|
console.log("[StormcloudVideoPlayer] content_resume received, inAdBreak=%s, remaining=%s, preloadedTokens=%d, pendingNext=%s", _this.inAdBreak, remaining, _this.preloadedTokens.length, !!_this.pendingNextAdBids);
|
|
3414
3253
|
}
|
|
@@ -3485,7 +3324,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3485
3324
|
var remainingFinal = _this.getRemainingAdMs();
|
|
3486
3325
|
if (_this.inAdBreak && remainingFinal > _this.MIN_AD_REMAINING_MS) {
|
|
3487
3326
|
if (_this.config.debugAdTiming) {
|
|
3488
|
-
console.log("[StormcloudVideoPlayer] content_resume:
|
|
3327
|
+
console.log("[StormcloudVideoPlayer] content_resume: ad ended/failed with time remaining, showing filler and continuing fetch for", remainingFinal, "ms");
|
|
3489
3328
|
}
|
|
3490
3329
|
if (!_this.config.disableFiller) {
|
|
3491
3330
|
_this.showPlaceholderLayer();
|
|
@@ -3503,7 +3342,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3503
3342
|
(_this_video_play = _this.video.play()) === null || _this_video_play === void 0 ? void 0 : _this_video_play.catch(function() {});
|
|
3504
3343
|
}
|
|
3505
3344
|
}
|
|
3506
|
-
_this.
|
|
3345
|
+
_this.continuousFetchingActive = true;
|
|
3346
|
+
_this.startContinuousFetchLoop();
|
|
3507
3347
|
return;
|
|
3508
3348
|
}
|
|
3509
3349
|
if (_this.config.debugAdTiming) {
|
|
@@ -3650,547 +3490,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3650
3490
|
return !!(this.config.allowNativeHls && canNative);
|
|
3651
3491
|
}
|
|
3652
3492
|
},
|
|
3653
|
-
{
|
|
3654
|
-
key: "onId3Tag",
|
|
3655
|
-
value: function onId3Tag(tag) {
|
|
3656
|
-
if (typeof tag.ptsSeconds === "number") {
|
|
3657
|
-
this.updatePtsDrift(tag.ptsSeconds);
|
|
3658
|
-
}
|
|
3659
|
-
var marker = this.parseScte35FromId3(tag);
|
|
3660
|
-
if (marker) {
|
|
3661
|
-
this.onScte35Marker(marker);
|
|
3662
|
-
}
|
|
3663
|
-
}
|
|
3664
|
-
},
|
|
3665
|
-
{
|
|
3666
|
-
key: "parseScte35FromId3",
|
|
3667
|
-
value: function parseScte35FromId3(tag) {
|
|
3668
|
-
var text = this.decodeId3ValueToText(tag.value);
|
|
3669
|
-
if (!text) return void 0;
|
|
3670
|
-
var cueOutMatch = text.match(/EXT-X-CUE-OUT(?::([^\r\n]*))?/i) || text.match(/CUE-OUT(?::([^\r\n]*))?/i);
|
|
3671
|
-
if (cueOutMatch) {
|
|
3672
|
-
var _cueOutMatch_;
|
|
3673
|
-
var arg = ((_cueOutMatch_ = cueOutMatch[1]) !== null && _cueOutMatch_ !== void 0 ? _cueOutMatch_ : "").trim();
|
|
3674
|
-
var dur = this.parseCueOutDuration(arg);
|
|
3675
|
-
var marker = _object_spread_props(_object_spread({
|
|
3676
|
-
type: "start"
|
|
3677
|
-
}, tag.ptsSeconds !== void 0 ? {
|
|
3678
|
-
ptsSeconds: tag.ptsSeconds
|
|
3679
|
-
} : {}, dur !== void 0 ? {
|
|
3680
|
-
durationSeconds: dur
|
|
3681
|
-
} : {}), {
|
|
3682
|
-
raw: {
|
|
3683
|
-
id3: text
|
|
3684
|
-
}
|
|
3685
|
-
});
|
|
3686
|
-
return marker;
|
|
3687
|
-
}
|
|
3688
|
-
var cueOutContMatch = text.match(/EXT-X-CUE-OUT-CONT:([^\r\n]*)/i);
|
|
3689
|
-
if (cueOutContMatch) {
|
|
3690
|
-
var _cueOutContMatch_;
|
|
3691
|
-
var arg1 = ((_cueOutContMatch_ = cueOutContMatch[1]) !== null && _cueOutContMatch_ !== void 0 ? _cueOutContMatch_ : "").trim();
|
|
3692
|
-
var cont = this.parseCueOutCont(arg1);
|
|
3693
|
-
var marker1 = _object_spread_props(_object_spread({
|
|
3694
|
-
type: "progress"
|
|
3695
|
-
}, tag.ptsSeconds !== void 0 ? {
|
|
3696
|
-
ptsSeconds: tag.ptsSeconds
|
|
3697
|
-
} : {}, (cont === null || cont === void 0 ? void 0 : cont.duration) !== void 0 ? {
|
|
3698
|
-
durationSeconds: cont.duration
|
|
3699
|
-
} : {}), {
|
|
3700
|
-
raw: {
|
|
3701
|
-
id3: text
|
|
3702
|
-
}
|
|
3703
|
-
});
|
|
3704
|
-
return marker1;
|
|
3705
|
-
}
|
|
3706
|
-
var cueInMatch = text.match(/EXT-X-CUE-IN\b/i) || text.match(/CUE-IN\b/i);
|
|
3707
|
-
if (cueInMatch) {
|
|
3708
|
-
var marker2 = _object_spread_props(_object_spread({
|
|
3709
|
-
type: "end"
|
|
3710
|
-
}, tag.ptsSeconds !== void 0 ? {
|
|
3711
|
-
ptsSeconds: tag.ptsSeconds
|
|
3712
|
-
} : {}), {
|
|
3713
|
-
raw: {
|
|
3714
|
-
id3: text
|
|
3715
|
-
}
|
|
3716
|
-
});
|
|
3717
|
-
return marker2;
|
|
3718
|
-
}
|
|
3719
|
-
var daterangeMatch = text.match(/EXT-X-DATERANGE:([^\r\n]*)/i);
|
|
3720
|
-
if (daterangeMatch) {
|
|
3721
|
-
var _daterangeMatch_, _attrs_CLASS;
|
|
3722
|
-
var attrs = this.parseAttributeList((_daterangeMatch_ = daterangeMatch[1]) !== null && _daterangeMatch_ !== void 0 ? _daterangeMatch_ : "");
|
|
3723
|
-
var hasScteOut = "SCTE35-OUT" in attrs || attrs["SCTE35-OUT"] !== void 0;
|
|
3724
|
-
var hasScteIn = "SCTE35-IN" in attrs || attrs["SCTE35-IN"] !== void 0;
|
|
3725
|
-
var klass = String((_attrs_CLASS = attrs["CLASS"]) !== null && _attrs_CLASS !== void 0 ? _attrs_CLASS : "");
|
|
3726
|
-
var duration = this.toNumber(attrs["DURATION"]);
|
|
3727
|
-
if (hasScteOut || /com\.apple\.hls\.cue/i.test(klass)) {
|
|
3728
|
-
var marker3 = _object_spread_props(_object_spread({
|
|
3729
|
-
type: "start"
|
|
3730
|
-
}, tag.ptsSeconds !== void 0 ? {
|
|
3731
|
-
ptsSeconds: tag.ptsSeconds
|
|
3732
|
-
} : {}, duration !== void 0 ? {
|
|
3733
|
-
durationSeconds: duration
|
|
3734
|
-
} : {}), {
|
|
3735
|
-
raw: {
|
|
3736
|
-
id3: text,
|
|
3737
|
-
attrs: attrs
|
|
3738
|
-
}
|
|
3739
|
-
});
|
|
3740
|
-
return marker3;
|
|
3741
|
-
}
|
|
3742
|
-
if (hasScteIn) {
|
|
3743
|
-
var marker4 = _object_spread_props(_object_spread({
|
|
3744
|
-
type: "end"
|
|
3745
|
-
}, tag.ptsSeconds !== void 0 ? {
|
|
3746
|
-
ptsSeconds: tag.ptsSeconds
|
|
3747
|
-
} : {}), {
|
|
3748
|
-
raw: {
|
|
3749
|
-
id3: text,
|
|
3750
|
-
attrs: attrs
|
|
3751
|
-
}
|
|
3752
|
-
});
|
|
3753
|
-
return marker4;
|
|
3754
|
-
}
|
|
3755
|
-
}
|
|
3756
|
-
if (/SCTE35-OUT/i.test(text)) {
|
|
3757
|
-
var marker5 = _object_spread_props(_object_spread({
|
|
3758
|
-
type: "start"
|
|
3759
|
-
}, tag.ptsSeconds !== void 0 ? {
|
|
3760
|
-
ptsSeconds: tag.ptsSeconds
|
|
3761
|
-
} : {}), {
|
|
3762
|
-
raw: {
|
|
3763
|
-
id3: text
|
|
3764
|
-
}
|
|
3765
|
-
});
|
|
3766
|
-
return marker5;
|
|
3767
|
-
}
|
|
3768
|
-
if (/SCTE35-IN/i.test(text)) {
|
|
3769
|
-
var marker6 = _object_spread_props(_object_spread({
|
|
3770
|
-
type: "end"
|
|
3771
|
-
}, tag.ptsSeconds !== void 0 ? {
|
|
3772
|
-
ptsSeconds: tag.ptsSeconds
|
|
3773
|
-
} : {}), {
|
|
3774
|
-
raw: {
|
|
3775
|
-
id3: text
|
|
3776
|
-
}
|
|
3777
|
-
});
|
|
3778
|
-
return marker6;
|
|
3779
|
-
}
|
|
3780
|
-
if (_instanceof(tag.value, Uint8Array)) {
|
|
3781
|
-
var bin = this.parseScte35Binary(tag.value);
|
|
3782
|
-
if (bin) return bin;
|
|
3783
|
-
}
|
|
3784
|
-
return void 0;
|
|
3785
|
-
}
|
|
3786
|
-
},
|
|
3787
|
-
{
|
|
3788
|
-
key: "decodeId3ValueToText",
|
|
3789
|
-
value: function decodeId3ValueToText(value) {
|
|
3790
|
-
try {
|
|
3791
|
-
if (typeof value === "string") return value;
|
|
3792
|
-
var decoder = new TextDecoder("utf-8", {
|
|
3793
|
-
fatal: false
|
|
3794
|
-
});
|
|
3795
|
-
var text = decoder.decode(value);
|
|
3796
|
-
if (text && /[\x20-\x7E]/.test(text)) return text;
|
|
3797
|
-
var out = "";
|
|
3798
|
-
for(var i = 0; i < value.length; i++)out += String.fromCharCode(value[i]);
|
|
3799
|
-
return out;
|
|
3800
|
-
} catch (unused) {
|
|
3801
|
-
return void 0;
|
|
3802
|
-
}
|
|
3803
|
-
}
|
|
3804
|
-
},
|
|
3805
|
-
{
|
|
3806
|
-
key: "onScte35Marker",
|
|
3807
|
-
value: function onScte35Marker(marker) {
|
|
3808
|
-
var _this = this;
|
|
3809
|
-
if (this.config.disableAds) return;
|
|
3810
|
-
this.pushScteMarker(marker);
|
|
3811
|
-
this.pushDebugLog("info", "scte35", "SCTE-35 marker detected", {
|
|
3812
|
-
type: marker.type,
|
|
3813
|
-
ptsSeconds: marker.ptsSeconds,
|
|
3814
|
-
durationSeconds: marker.durationSeconds,
|
|
3815
|
-
currentTime: this.video.currentTime
|
|
3816
|
-
});
|
|
3817
|
-
if (this.config.debugAdTiming) {
|
|
3818
|
-
console.log("[StormcloudVideoPlayer] SCTE-35 marker detected:", {
|
|
3819
|
-
type: marker.type,
|
|
3820
|
-
ptsSeconds: marker.ptsSeconds,
|
|
3821
|
-
durationSeconds: marker.durationSeconds,
|
|
3822
|
-
currentTime: this.video.currentTime,
|
|
3823
|
-
raw: marker.raw,
|
|
3824
|
-
hasPendingAdBreak: !!this.pendingAdBreak
|
|
3825
|
-
});
|
|
3826
|
-
}
|
|
3827
|
-
if (marker.type === "start") {
|
|
3828
|
-
var _this_config_immediateManifestAds;
|
|
3829
|
-
var _this_pendingAdBreak;
|
|
3830
|
-
if (this.savedMutedStateBeforeScte == null) {
|
|
3831
|
-
this.savedMutedStateBeforeScte = {
|
|
3832
|
-
muted: this.video.muted,
|
|
3833
|
-
volume: this.video.volume
|
|
3834
|
-
};
|
|
3835
|
-
this.adLayer.updateOriginalMutedState(this.video.muted, this.video.volume);
|
|
3836
|
-
}
|
|
3837
|
-
if (!this.config.disableFiller && !this.video.muted && !this.adLayer.isAdPlaying()) {
|
|
3838
|
-
this.video.muted = true;
|
|
3839
|
-
this.video.volume = 0;
|
|
3840
|
-
if (this.config.debugAdTiming) {
|
|
3841
|
-
console.log("[StormcloudVideoPlayer] Muted video on SCTE start marker");
|
|
3842
|
-
}
|
|
3843
|
-
}
|
|
3844
|
-
if (this.inAdBreak) {
|
|
3845
|
-
if (marker.durationSeconds != null) {
|
|
3846
|
-
var newDurationMs = marker.durationSeconds * 1e3;
|
|
3847
|
-
if (this.expectedAdBreakDurationMs == null || newDurationMs > this.expectedAdBreakDurationMs) {
|
|
3848
|
-
this.expectedAdBreakDurationMs = newDurationMs;
|
|
3849
|
-
var elapsedMs = this.currentAdBreakStartWallClockMs != null ? Date.now() - this.currentAdBreakStartWallClockMs : 0;
|
|
3850
|
-
var remainingMs = Math.max(0, newDurationMs - elapsedMs);
|
|
3851
|
-
this.scheduleAdStopCountdown(remainingMs);
|
|
3852
|
-
if (this.config.debugAdTiming) {
|
|
3853
|
-
console.log("[StormcloudVideoPlayer] Updated ad break duration from subsequent marker: ".concat(newDurationMs, "ms, remaining: ").concat(remainingMs, "ms"));
|
|
3854
|
-
}
|
|
3855
|
-
}
|
|
3856
|
-
}
|
|
3857
|
-
return;
|
|
3858
|
-
}
|
|
3859
|
-
this.inAdBreak = true;
|
|
3860
|
-
var durationMs = marker.durationSeconds != null ? marker.durationSeconds * 1e3 : ((_this_pendingAdBreak = this.pendingAdBreak) === null || _this_pendingAdBreak === void 0 ? void 0 : _this_pendingAdBreak.marker.durationSeconds) != null ? this.pendingAdBreak.marker.durationSeconds * 1e3 : void 0;
|
|
3861
|
-
this.expectedAdBreakDurationMs = durationMs;
|
|
3862
|
-
this.currentAdBreakStartWallClockMs = Date.now();
|
|
3863
|
-
if (this.config.licenseKey) {
|
|
3864
|
-
var _this_pendingAdBreak1;
|
|
3865
|
-
var adDetectInfo = _object_spread({
|
|
3866
|
-
source: "scte35",
|
|
3867
|
-
timestamp: /* @__PURE__ */ new Date().toISOString()
|
|
3868
|
-
}, marker.durationSeconds != null && {
|
|
3869
|
-
durationSeconds: marker.durationSeconds
|
|
3870
|
-
}, marker.ptsSeconds != null && {
|
|
3871
|
-
ptsSeconds: marker.ptsSeconds
|
|
3872
|
-
}, ((_this_pendingAdBreak1 = this.pendingAdBreak) === null || _this_pendingAdBreak1 === void 0 ? void 0 : _this_pendingAdBreak1.detectedAtFragmentSn) != null && {
|
|
3873
|
-
detectedAtFragmentSn: this.pendingAdBreak.detectedAtFragmentSn
|
|
3874
|
-
});
|
|
3875
|
-
sendAdDetectTracking(this.config.licenseKey, adDetectInfo);
|
|
3876
|
-
}
|
|
3877
|
-
var isManifestMarker = this.isManifestBasedMarker(marker);
|
|
3878
|
-
var forceImmediate = (_this_config_immediateManifestAds = this.config.immediateManifestAds) !== null && _this_config_immediateManifestAds !== void 0 ? _this_config_immediateManifestAds : true;
|
|
3879
|
-
if (this.config.debugAdTiming) {
|
|
3880
|
-
console.log("[StormcloudVideoPlayer] Ad start decision:", {
|
|
3881
|
-
isManifestMarker: isManifestMarker,
|
|
3882
|
-
forceImmediate: forceImmediate,
|
|
3883
|
-
hasPts: typeof marker.ptsSeconds === "number"
|
|
3884
|
-
});
|
|
3885
|
-
}
|
|
3886
|
-
if (isManifestMarker && forceImmediate) {
|
|
3887
|
-
if (this.config.debugAdTiming) {
|
|
3888
|
-
console.log("[StormcloudVideoPlayer] Starting ad immediately (manifest-based)");
|
|
3889
|
-
}
|
|
3890
|
-
this.clearAdStartTimer();
|
|
3891
|
-
this.handleAdStart(marker);
|
|
3892
|
-
} else if (typeof marker.ptsSeconds === "number") {
|
|
3893
|
-
var _this_config_driftToleranceMs;
|
|
3894
|
-
var tol = (_this_config_driftToleranceMs = this.config.driftToleranceMs) !== null && _this_config_driftToleranceMs !== void 0 ? _this_config_driftToleranceMs : 1e3;
|
|
3895
|
-
var nowMs = this.video.currentTime * 1e3;
|
|
3896
|
-
var estCurrentPtsMs = nowMs - this.ptsDriftEmaMs;
|
|
3897
|
-
var deltaMs = Math.floor(marker.ptsSeconds * 1e3 - estCurrentPtsMs);
|
|
3898
|
-
if (this.config.debugAdTiming) {
|
|
3899
|
-
console.log("[StormcloudVideoPlayer] PTS-based timing calculation:", {
|
|
3900
|
-
nowMs: nowMs,
|
|
3901
|
-
estCurrentPtsMs: estCurrentPtsMs,
|
|
3902
|
-
markerPtsMs: marker.ptsSeconds * 1e3,
|
|
3903
|
-
deltaMs: deltaMs,
|
|
3904
|
-
tolerance: tol
|
|
3905
|
-
});
|
|
3906
|
-
}
|
|
3907
|
-
if (deltaMs > tol) {
|
|
3908
|
-
if (this.config.debugAdTiming) {
|
|
3909
|
-
console.log("[StormcloudVideoPlayer] Scheduling ad start in ".concat(deltaMs, "ms"));
|
|
3910
|
-
}
|
|
3911
|
-
this.scheduleAdStartIn(deltaMs);
|
|
3912
|
-
} else {
|
|
3913
|
-
if (this.config.debugAdTiming) {
|
|
3914
|
-
console.log("[StormcloudVideoPlayer] Starting ad immediately (within tolerance)");
|
|
3915
|
-
}
|
|
3916
|
-
this.clearAdStartTimer();
|
|
3917
|
-
this.handleAdStart(marker);
|
|
3918
|
-
}
|
|
3919
|
-
} else {
|
|
3920
|
-
if (this.config.debugAdTiming) {
|
|
3921
|
-
console.log("[StormcloudVideoPlayer] Starting ad immediately (fallback)");
|
|
3922
|
-
}
|
|
3923
|
-
this.clearAdStartTimer();
|
|
3924
|
-
this.handleAdStart(marker);
|
|
3925
|
-
}
|
|
3926
|
-
if (this.expectedAdBreakDurationMs != null) {
|
|
3927
|
-
this.scheduleAdStopCountdown(this.expectedAdBreakDurationMs);
|
|
3928
|
-
}
|
|
3929
|
-
return;
|
|
3930
|
-
}
|
|
3931
|
-
if (marker.type === "progress" && this.inAdBreak) {
|
|
3932
|
-
if (marker.durationSeconds != null) {
|
|
3933
|
-
this.expectedAdBreakDurationMs = marker.durationSeconds * 1e3;
|
|
3934
|
-
}
|
|
3935
|
-
if (this.expectedAdBreakDurationMs != null && this.currentAdBreakStartWallClockMs != null) {
|
|
3936
|
-
var elapsedMs1 = Date.now() - this.currentAdBreakStartWallClockMs;
|
|
3937
|
-
var remainingMs1 = Math.max(0, this.expectedAdBreakDurationMs - elapsedMs1);
|
|
3938
|
-
this.scheduleAdStopCountdown(remainingMs1);
|
|
3939
|
-
}
|
|
3940
|
-
if (!this.adLayer.isAdPlaying() && this.pendingNextAdBids != null && this.pendingNextAdBids.length > 0) {
|
|
3941
|
-
var bids = this.pendingNextAdBids;
|
|
3942
|
-
this.pendingNextAdBids = null;
|
|
3943
|
-
this.currentAdIndex++;
|
|
3944
|
-
this.adLayer.playAd(bids).catch(function() {
|
|
3945
|
-
return _this.handleAdFailure();
|
|
3946
|
-
});
|
|
3947
|
-
}
|
|
3948
|
-
return;
|
|
3949
|
-
}
|
|
3950
|
-
if (marker.type === "end") {
|
|
3951
|
-
var remaining = this.getRemainingAdMs();
|
|
3952
|
-
var adPlaying = this.adLayer.isAdPlaying();
|
|
3953
|
-
var hasQueuedAds = this.pendingNextAdBids != null && this.pendingNextAdBids.length > 0;
|
|
3954
|
-
if (this.config.debugAdTiming) {
|
|
3955
|
-
console.log("[StormcloudVideoPlayer] SCTE-35 end marker received:", {
|
|
3956
|
-
inAdBreak: this.inAdBreak,
|
|
3957
|
-
remaining: remaining,
|
|
3958
|
-
adPlaying: adPlaying,
|
|
3959
|
-
hasQueuedAds: hasQueuedAds,
|
|
3960
|
-
activeAdRequest: this.activeAdRequestToken !== null
|
|
3961
|
-
});
|
|
3962
|
-
}
|
|
3963
|
-
if (!this.inAdBreak) {
|
|
3964
|
-
if (this.config.debugAdTiming) {
|
|
3965
|
-
console.log("[StormcloudVideoPlayer] Ignoring SCTE-35 end marker - not in ad break");
|
|
3966
|
-
}
|
|
3967
|
-
return;
|
|
3968
|
-
}
|
|
3969
|
-
if (adPlaying || remaining > 500) {
|
|
3970
|
-
if (this.config.debugAdTiming) {
|
|
3971
|
-
console.log("[StormcloudVideoPlayer] Ignoring premature SCTE-35 end marker - ads still active or time remaining");
|
|
3972
|
-
}
|
|
3973
|
-
return;
|
|
3974
|
-
}
|
|
3975
|
-
this.inAdBreak = false;
|
|
3976
|
-
this.expectedAdBreakDurationMs = void 0;
|
|
3977
|
-
this.currentAdBreakStartWallClockMs = void 0;
|
|
3978
|
-
this.clearAdStartTimer();
|
|
3979
|
-
this.clearAdStopTimer();
|
|
3980
|
-
if (adPlaying) {
|
|
3981
|
-
this.adLayer.stop().catch(function() {});
|
|
3982
|
-
}
|
|
3983
|
-
this.handleAdPodComplete();
|
|
3984
|
-
return;
|
|
3985
|
-
}
|
|
3986
|
-
}
|
|
3987
|
-
},
|
|
3988
|
-
{
|
|
3989
|
-
key: "parseCueOutDuration",
|
|
3990
|
-
value: function parseCueOutDuration(value) {
|
|
3991
|
-
var num = parseFloat(value.trim());
|
|
3992
|
-
if (!Number.isNaN(num)) return num;
|
|
3993
|
-
var match = value.match(/(?:^|[,\s])DURATION\s*=\s*([0-9.]+)/i) || value.match(/Duration\s*=\s*([0-9.]+)/i);
|
|
3994
|
-
if (match && match[1] != null) {
|
|
3995
|
-
var dStr = match[1];
|
|
3996
|
-
var d = parseFloat(dStr);
|
|
3997
|
-
return Number.isNaN(d) ? void 0 : d;
|
|
3998
|
-
}
|
|
3999
|
-
return void 0;
|
|
4000
|
-
}
|
|
4001
|
-
},
|
|
4002
|
-
{
|
|
4003
|
-
key: "parseCueOutCont",
|
|
4004
|
-
value: function parseCueOutCont(value) {
|
|
4005
|
-
var res = {};
|
|
4006
|
-
var elapsedMatch = value.match(/Elapsed\s*=\s*([0-9.]+)/i);
|
|
4007
|
-
var durationMatch = value.match(/Duration\s*=\s*([0-9.]+)/i);
|
|
4008
|
-
if (elapsedMatch && elapsedMatch[1] != null) {
|
|
4009
|
-
var e = parseFloat(elapsedMatch[1]);
|
|
4010
|
-
if (!Number.isNaN(e)) res.elapsed = e;
|
|
4011
|
-
}
|
|
4012
|
-
if (durationMatch && durationMatch[1] != null) {
|
|
4013
|
-
var d = parseFloat(durationMatch[1]);
|
|
4014
|
-
if (!Number.isNaN(d)) res.duration = d;
|
|
4015
|
-
}
|
|
4016
|
-
if (!("elapsed" in res) || !("duration" in res)) {
|
|
4017
|
-
var slashMatch = value.match(/([0-9.]+)\s*\/\s*([0-9.]+)/);
|
|
4018
|
-
if (slashMatch && slashMatch[1] && slashMatch[2]) {
|
|
4019
|
-
var elapsed = parseFloat(slashMatch[1]);
|
|
4020
|
-
var duration = parseFloat(slashMatch[2]);
|
|
4021
|
-
if (!Number.isNaN(elapsed) && !("elapsed" in res)) res.elapsed = elapsed;
|
|
4022
|
-
if (!Number.isNaN(duration) && !("duration" in res)) res.duration = duration;
|
|
4023
|
-
}
|
|
4024
|
-
}
|
|
4025
|
-
if ("elapsed" in res || "duration" in res) return res;
|
|
4026
|
-
return void 0;
|
|
4027
|
-
}
|
|
4028
|
-
},
|
|
4029
|
-
{
|
|
4030
|
-
key: "parseAttributeList",
|
|
4031
|
-
value: function parseAttributeList(value) {
|
|
4032
|
-
var attrs = {};
|
|
4033
|
-
var regex = /([A-Z0-9-]+)=(("[^"]*")|([^",]*))(?:,|$)/gi;
|
|
4034
|
-
var match;
|
|
4035
|
-
while((match = regex.exec(value)) !== null){
|
|
4036
|
-
var _match_, _ref, _match_1;
|
|
4037
|
-
var key = (_match_ = match[1]) !== null && _match_ !== void 0 ? _match_ : "";
|
|
4038
|
-
var rawVal = (_ref = (_match_1 = match[3]) !== null && _match_1 !== void 0 ? _match_1 : match[4]) !== null && _ref !== void 0 ? _ref : "";
|
|
4039
|
-
if (rawVal.startsWith('"') && rawVal.endsWith('"')) {
|
|
4040
|
-
rawVal = rawVal.slice(1, -1);
|
|
4041
|
-
}
|
|
4042
|
-
if (key) {
|
|
4043
|
-
attrs[key] = rawVal;
|
|
4044
|
-
}
|
|
4045
|
-
}
|
|
4046
|
-
return attrs;
|
|
4047
|
-
}
|
|
4048
|
-
},
|
|
4049
|
-
{
|
|
4050
|
-
key: "toNumber",
|
|
4051
|
-
value: function toNumber(val) {
|
|
4052
|
-
if (val == null) return void 0;
|
|
4053
|
-
var n = typeof val === "string" ? parseFloat(val) : Number(val);
|
|
4054
|
-
return Number.isNaN(n) ? void 0 : n;
|
|
4055
|
-
}
|
|
4056
|
-
},
|
|
4057
|
-
{
|
|
4058
|
-
key: "isManifestBasedMarker",
|
|
4059
|
-
value: function isManifestBasedMarker(marker) {
|
|
4060
|
-
var raw = marker.raw;
|
|
4061
|
-
if (!raw) return false;
|
|
4062
|
-
if (raw.tag) {
|
|
4063
|
-
var tag = String(raw.tag);
|
|
4064
|
-
return tag.includes("EXT-X-CUE-OUT") || tag.includes("EXT-X-CUE-IN") || tag.includes("EXT-X-DATERANGE");
|
|
4065
|
-
}
|
|
4066
|
-
if (raw.id3) return false;
|
|
4067
|
-
if (raw.splice_command_type) return false;
|
|
4068
|
-
return false;
|
|
4069
|
-
}
|
|
4070
|
-
},
|
|
4071
|
-
{
|
|
4072
|
-
key: "parseScte35Binary",
|
|
4073
|
-
value: function parseScte35Binary(data) {
|
|
4074
|
-
var BitReader = /*#__PURE__*/ function() {
|
|
4075
|
-
function BitReader(buf) {
|
|
4076
|
-
_class_call_check(this, BitReader);
|
|
4077
|
-
this.buf = buf;
|
|
4078
|
-
this.bytePos = 0;
|
|
4079
|
-
this.bitPos = 0;
|
|
4080
|
-
}
|
|
4081
|
-
_create_class(BitReader, [
|
|
4082
|
-
{
|
|
4083
|
-
key: "readBits",
|
|
4084
|
-
value: function readBits(numBits) {
|
|
4085
|
-
var result = 0;
|
|
4086
|
-
while(numBits > 0){
|
|
4087
|
-
if (this.bytePos >= this.buf.length) return result;
|
|
4088
|
-
var remainingInByte = 8 - this.bitPos;
|
|
4089
|
-
var toRead = Math.min(numBits, remainingInByte);
|
|
4090
|
-
var currentByte = this.buf[this.bytePos];
|
|
4091
|
-
var shift = remainingInByte - toRead;
|
|
4092
|
-
var mask = (1 << toRead) - 1 & 255;
|
|
4093
|
-
var bits = currentByte >> shift & mask;
|
|
4094
|
-
result = result << toRead | bits;
|
|
4095
|
-
this.bitPos += toRead;
|
|
4096
|
-
if (this.bitPos >= 8) {
|
|
4097
|
-
this.bitPos = 0;
|
|
4098
|
-
this.bytePos += 1;
|
|
4099
|
-
}
|
|
4100
|
-
numBits -= toRead;
|
|
4101
|
-
}
|
|
4102
|
-
return result >>> 0;
|
|
4103
|
-
}
|
|
4104
|
-
},
|
|
4105
|
-
{
|
|
4106
|
-
key: "skipBits",
|
|
4107
|
-
value: function skipBits(n) {
|
|
4108
|
-
this.readBits(n);
|
|
4109
|
-
}
|
|
4110
|
-
}
|
|
4111
|
-
]);
|
|
4112
|
-
return BitReader;
|
|
4113
|
-
}();
|
|
4114
|
-
var r = new BitReader(data);
|
|
4115
|
-
var tableId = r.readBits(8);
|
|
4116
|
-
if (tableId !== 252) return void 0;
|
|
4117
|
-
r.readBits(1);
|
|
4118
|
-
r.readBits(1);
|
|
4119
|
-
r.readBits(2);
|
|
4120
|
-
var sectionLength = r.readBits(12);
|
|
4121
|
-
r.readBits(8);
|
|
4122
|
-
r.readBits(1);
|
|
4123
|
-
r.readBits(6);
|
|
4124
|
-
var ptsAdjHigh = r.readBits(1);
|
|
4125
|
-
var ptsAdjLow = r.readBits(32);
|
|
4126
|
-
void ptsAdjHigh;
|
|
4127
|
-
void ptsAdjLow;
|
|
4128
|
-
r.readBits(8);
|
|
4129
|
-
r.readBits(12);
|
|
4130
|
-
var spliceCommandLength = r.readBits(12);
|
|
4131
|
-
var spliceCommandType = r.readBits(8);
|
|
4132
|
-
if (spliceCommandType !== 5) {
|
|
4133
|
-
return void 0;
|
|
4134
|
-
}
|
|
4135
|
-
r.readBits(32);
|
|
4136
|
-
var cancel = r.readBits(1) === 1;
|
|
4137
|
-
r.readBits(7);
|
|
4138
|
-
if (cancel) return void 0;
|
|
4139
|
-
var outOfNetwork = r.readBits(1) === 1;
|
|
4140
|
-
var programSpliceFlag = r.readBits(1) === 1;
|
|
4141
|
-
var durationFlag = r.readBits(1) === 1;
|
|
4142
|
-
var spliceImmediateFlag = r.readBits(1) === 1;
|
|
4143
|
-
r.readBits(4);
|
|
4144
|
-
if (programSpliceFlag && !spliceImmediateFlag) {
|
|
4145
|
-
var timeSpecifiedFlag = r.readBits(1) === 1;
|
|
4146
|
-
if (timeSpecifiedFlag) {
|
|
4147
|
-
r.readBits(6);
|
|
4148
|
-
r.readBits(33);
|
|
4149
|
-
} else {
|
|
4150
|
-
r.readBits(7);
|
|
4151
|
-
}
|
|
4152
|
-
} else if (!programSpliceFlag) {
|
|
4153
|
-
var componentCount = r.readBits(8);
|
|
4154
|
-
for(var i = 0; i < componentCount; i++){
|
|
4155
|
-
r.readBits(8);
|
|
4156
|
-
if (!spliceImmediateFlag) {
|
|
4157
|
-
var timeSpecifiedFlag1 = r.readBits(1) === 1;
|
|
4158
|
-
if (timeSpecifiedFlag1) {
|
|
4159
|
-
r.readBits(6);
|
|
4160
|
-
r.readBits(33);
|
|
4161
|
-
} else {
|
|
4162
|
-
r.readBits(7);
|
|
4163
|
-
}
|
|
4164
|
-
}
|
|
4165
|
-
}
|
|
4166
|
-
}
|
|
4167
|
-
var durationSeconds = void 0;
|
|
4168
|
-
if (durationFlag) {
|
|
4169
|
-
r.readBits(6);
|
|
4170
|
-
r.readBits(1);
|
|
4171
|
-
var high = r.readBits(1);
|
|
4172
|
-
var low = r.readBits(32);
|
|
4173
|
-
var durationTicks = high * 4294967296 + low;
|
|
4174
|
-
durationSeconds = durationTicks / 9e4;
|
|
4175
|
-
}
|
|
4176
|
-
r.readBits(16);
|
|
4177
|
-
r.readBits(8);
|
|
4178
|
-
r.readBits(8);
|
|
4179
|
-
if (outOfNetwork) {
|
|
4180
|
-
var marker = _object_spread_props(_object_spread({
|
|
4181
|
-
type: "start"
|
|
4182
|
-
}, durationSeconds !== void 0 ? {
|
|
4183
|
-
durationSeconds: durationSeconds
|
|
4184
|
-
} : {}), {
|
|
4185
|
-
raw: {
|
|
4186
|
-
splice_command_type: 5
|
|
4187
|
-
}
|
|
4188
|
-
});
|
|
4189
|
-
return marker;
|
|
4190
|
-
}
|
|
4191
|
-
return void 0;
|
|
4192
|
-
}
|
|
4193
|
-
},
|
|
4194
3493
|
{
|
|
4195
3494
|
key: "initializeTracking",
|
|
4196
3495
|
value: function initializeTracking() {
|
|
@@ -4312,35 +3611,35 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4312
3611
|
},
|
|
4313
3612
|
{
|
|
4314
3613
|
key: "startAdPrefetch",
|
|
4315
|
-
value: function startAdPrefetch(
|
|
3614
|
+
value: function startAdPrefetch(durationSeconds, fragmentSn) {
|
|
4316
3615
|
if (this.config.disableAds) return;
|
|
4317
3616
|
if (this.pendingAdBreak || this.inAdBreak) {
|
|
4318
3617
|
return;
|
|
4319
3618
|
}
|
|
4320
|
-
this.pendingAdBreak = _object_spread_props(_object_spread({
|
|
4321
|
-
|
|
4322
|
-
}, fragmentSn !== void 0 ? {
|
|
3619
|
+
this.pendingAdBreak = _object_spread_props(_object_spread({}, durationSeconds !== void 0 ? {
|
|
3620
|
+
durationSeconds: durationSeconds
|
|
3621
|
+
} : {}, fragmentSn !== void 0 ? {
|
|
4323
3622
|
detectedAtFragmentSn: fragmentSn
|
|
4324
3623
|
} : {}), {
|
|
4325
3624
|
isFetching: false,
|
|
4326
3625
|
fetchStartTime: Date.now()
|
|
4327
3626
|
});
|
|
4328
|
-
void this.runAdPrefetch(
|
|
3627
|
+
void this.runAdPrefetch(durationSeconds);
|
|
4329
3628
|
if (this.config.debugAdTiming) {
|
|
4330
|
-
console.log("[PREFETCH] Ad break
|
|
3629
|
+
console.log("[PREFETCH] Ad break registered, multi-ad prefetch started");
|
|
4331
3630
|
}
|
|
4332
3631
|
}
|
|
4333
3632
|
},
|
|
4334
3633
|
{
|
|
4335
3634
|
key: "runAdPrefetch",
|
|
4336
|
-
value: function runAdPrefetch(
|
|
3635
|
+
value: function runAdPrefetch(durationSeconds) {
|
|
4337
3636
|
return _async_to_generator(function() {
|
|
4338
|
-
var _this,
|
|
3637
|
+
var _this, _ref, _firstBids_, durSec, context, firstBids, unused, adDurationSec, estimatedCount, firstToken, unused1, remaining, results, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, result, token, unused2, err;
|
|
4339
3638
|
return _ts_generator(this, function(_state) {
|
|
4340
3639
|
switch(_state.label){
|
|
4341
3640
|
case 0:
|
|
4342
3641
|
_this = this;
|
|
4343
|
-
durSec =
|
|
3642
|
+
durSec = durationSeconds !== null && durationSeconds !== void 0 ? durationSeconds : 60;
|
|
4344
3643
|
context = {
|
|
4345
3644
|
breakDurationSec: durSec,
|
|
4346
3645
|
remainingBreakSec: durSec
|
|
@@ -4390,14 +3689,43 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4390
3689
|
console.log("[PREFETCH] Ad duration=".concat(adDurationSec, "s, break=").concat(durSec, "s → ").concat(estimatedCount, " ad(s) needed"));
|
|
4391
3690
|
}
|
|
4392
3691
|
firstToken = "preload_".concat(Date.now(), "_").concat(Math.random().toString(36).slice(2, 7));
|
|
4393
|
-
|
|
4394
|
-
|
|
3692
|
+
_state.label = 5;
|
|
3693
|
+
case 5:
|
|
3694
|
+
_state.trys.push([
|
|
3695
|
+
5,
|
|
3696
|
+
7,
|
|
3697
|
+
,
|
|
3698
|
+
8
|
|
3699
|
+
]);
|
|
3700
|
+
return [
|
|
3701
|
+
4,
|
|
3702
|
+
this.adLayer.preloadAd(firstBids, firstToken)
|
|
3703
|
+
];
|
|
3704
|
+
case 6:
|
|
3705
|
+
_state.sent();
|
|
3706
|
+
if (!this.inAdBreak) {
|
|
3707
|
+
this.preloadedTokens.push(firstToken);
|
|
3708
|
+
if (this.config.debugAdTiming) {
|
|
3709
|
+
console.log("[PREFETCH] First ad preloaded and queued, token=".concat(firstToken));
|
|
3710
|
+
}
|
|
3711
|
+
}
|
|
3712
|
+
return [
|
|
3713
|
+
3,
|
|
3714
|
+
8
|
|
3715
|
+
];
|
|
3716
|
+
case 7:
|
|
3717
|
+
unused1 = _state.sent();
|
|
4395
3718
|
if (this.config.debugAdTiming) {
|
|
4396
|
-
console.
|
|
3719
|
+
console.warn("[PREFETCH] First ad preload failed, token=".concat(firstToken));
|
|
4397
3720
|
}
|
|
3721
|
+
return [
|
|
3722
|
+
3,
|
|
3723
|
+
8
|
|
3724
|
+
];
|
|
3725
|
+
case 8:
|
|
4398
3726
|
if (!(estimatedCount > 1)) return [
|
|
4399
3727
|
3,
|
|
4400
|
-
|
|
3728
|
+
19
|
|
4401
3729
|
];
|
|
4402
3730
|
remaining = Array.from({
|
|
4403
3731
|
length: estimatedCount - 1
|
|
@@ -4419,38 +3747,100 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4419
3747
|
4,
|
|
4420
3748
|
Promise.all(remaining)
|
|
4421
3749
|
];
|
|
4422
|
-
case
|
|
3750
|
+
case 9:
|
|
4423
3751
|
results = _state.sent();
|
|
4424
3752
|
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
3753
|
+
_state.label = 10;
|
|
3754
|
+
case 10:
|
|
3755
|
+
_state.trys.push([
|
|
3756
|
+
10,
|
|
3757
|
+
17,
|
|
3758
|
+
18,
|
|
3759
|
+
19
|
|
3760
|
+
]);
|
|
3761
|
+
_iterator = results[Symbol.iterator]();
|
|
3762
|
+
_state.label = 11;
|
|
3763
|
+
case 11:
|
|
3764
|
+
if (!!(_iteratorNormalCompletion = (_step = _iterator.next()).done)) return [
|
|
3765
|
+
3,
|
|
3766
|
+
16
|
|
3767
|
+
];
|
|
3768
|
+
result = _step.value;
|
|
3769
|
+
if (this.inAdBreak) return [
|
|
3770
|
+
3,
|
|
3771
|
+
16
|
|
3772
|
+
];
|
|
3773
|
+
if (!(result.ok && result.value.length > 0)) return [
|
|
3774
|
+
3,
|
|
3775
|
+
15
|
|
3776
|
+
];
|
|
3777
|
+
token = "preload_".concat(Date.now(), "_").concat(Math.random().toString(36).slice(2, 7));
|
|
3778
|
+
_state.label = 12;
|
|
3779
|
+
case 12:
|
|
3780
|
+
_state.trys.push([
|
|
3781
|
+
12,
|
|
3782
|
+
14,
|
|
3783
|
+
,
|
|
3784
|
+
15
|
|
3785
|
+
]);
|
|
3786
|
+
return [
|
|
3787
|
+
4,
|
|
3788
|
+
this.adLayer.preloadAd(result.value, token)
|
|
3789
|
+
];
|
|
3790
|
+
case 13:
|
|
3791
|
+
_state.sent();
|
|
3792
|
+
if (!this.inAdBreak) {
|
|
3793
|
+
this.preloadedTokens.push(token);
|
|
3794
|
+
if (this.config.debugAdTiming) {
|
|
3795
|
+
console.log("[PREFETCH] Additional ad preloaded and queued, token=".concat(token));
|
|
3796
|
+
}
|
|
3797
|
+
}
|
|
3798
|
+
return [
|
|
3799
|
+
3,
|
|
3800
|
+
15
|
|
3801
|
+
];
|
|
3802
|
+
case 14:
|
|
3803
|
+
unused2 = _state.sent();
|
|
3804
|
+
if (this.config.debugAdTiming) {
|
|
3805
|
+
console.warn("[PREFETCH] Additional ad preload failed, token=".concat(token));
|
|
3806
|
+
}
|
|
3807
|
+
return [
|
|
3808
|
+
3,
|
|
3809
|
+
15
|
|
3810
|
+
];
|
|
3811
|
+
case 15:
|
|
3812
|
+
_iteratorNormalCompletion = true;
|
|
3813
|
+
return [
|
|
3814
|
+
3,
|
|
3815
|
+
11
|
|
3816
|
+
];
|
|
3817
|
+
case 16:
|
|
3818
|
+
return [
|
|
3819
|
+
3,
|
|
3820
|
+
19
|
|
3821
|
+
];
|
|
3822
|
+
case 17:
|
|
3823
|
+
err = _state.sent();
|
|
3824
|
+
_didIteratorError = true;
|
|
3825
|
+
_iteratorError = err;
|
|
3826
|
+
return [
|
|
3827
|
+
3,
|
|
3828
|
+
19
|
|
3829
|
+
];
|
|
3830
|
+
case 18:
|
|
4425
3831
|
try {
|
|
4426
|
-
|
|
4427
|
-
|
|
4428
|
-
if (this.inAdBreak) break;
|
|
4429
|
-
if (result.ok && result.value.length > 0) {
|
|
4430
|
-
token = "preload_".concat(Date.now(), "_").concat(Math.random().toString(36).slice(2, 7));
|
|
4431
|
-
this.preloadedTokens.push(token);
|
|
4432
|
-
void this.adLayer.preloadAd(result.value, token);
|
|
4433
|
-
if (this.config.debugAdTiming) {
|
|
4434
|
-
console.log("[PREFETCH] Additional ad preloading, token=".concat(token));
|
|
4435
|
-
}
|
|
4436
|
-
}
|
|
3832
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
3833
|
+
_iterator.return();
|
|
4437
3834
|
}
|
|
4438
|
-
} catch (err) {
|
|
4439
|
-
_didIteratorError = true;
|
|
4440
|
-
_iteratorError = err;
|
|
4441
3835
|
} finally{
|
|
4442
|
-
|
|
4443
|
-
|
|
4444
|
-
_iterator.return();
|
|
4445
|
-
}
|
|
4446
|
-
} finally{
|
|
4447
|
-
if (_didIteratorError) {
|
|
4448
|
-
throw _iteratorError;
|
|
4449
|
-
}
|
|
3836
|
+
if (_didIteratorError) {
|
|
3837
|
+
throw _iteratorError;
|
|
4450
3838
|
}
|
|
4451
3839
|
}
|
|
4452
|
-
|
|
4453
|
-
|
|
3840
|
+
return [
|
|
3841
|
+
7
|
|
3842
|
+
];
|
|
3843
|
+
case 19:
|
|
4454
3844
|
if (this.config.debugAdTiming) {
|
|
4455
3845
|
console.log("[PREFETCH] Pre-fetch complete: ".concat(this.preloadedTokens.length, " ad(s) queued"));
|
|
4456
3846
|
}
|
|
@@ -4498,6 +3888,177 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4498
3888
|
this.preloadedTokens = [];
|
|
4499
3889
|
}
|
|
4500
3890
|
},
|
|
3891
|
+
{
|
|
3892
|
+
key: "startAdInsertionPolling",
|
|
3893
|
+
value: function startAdInsertionPolling() {
|
|
3894
|
+
var _this = this;
|
|
3895
|
+
if (this.adInsertionPollingId != null) return;
|
|
3896
|
+
this.fetchAdInsertionPoint();
|
|
3897
|
+
this.adInsertionPollingId = window.setInterval(function() {
|
|
3898
|
+
_this.fetchAdInsertionPoint();
|
|
3899
|
+
}, 1e3);
|
|
3900
|
+
}
|
|
3901
|
+
},
|
|
3902
|
+
{
|
|
3903
|
+
key: "stopAdInsertionPolling",
|
|
3904
|
+
value: function stopAdInsertionPolling() {
|
|
3905
|
+
if (this.adInsertionPollingId != null) {
|
|
3906
|
+
clearInterval(this.adInsertionPollingId);
|
|
3907
|
+
this.adInsertionPollingId = void 0;
|
|
3908
|
+
}
|
|
3909
|
+
}
|
|
3910
|
+
},
|
|
3911
|
+
{
|
|
3912
|
+
key: "fetchAdInsertionPoint",
|
|
3913
|
+
value: function fetchAdInsertionPoint() {
|
|
3914
|
+
return _async_to_generator(function() {
|
|
3915
|
+
var _this_lastAdInsertionPoint, resp, data, isNew, unused;
|
|
3916
|
+
return _ts_generator(this, function(_state) {
|
|
3917
|
+
switch(_state.label){
|
|
3918
|
+
case 0:
|
|
3919
|
+
if (!this.config.projectId) return [
|
|
3920
|
+
2
|
|
3921
|
+
];
|
|
3922
|
+
_state.label = 1;
|
|
3923
|
+
case 1:
|
|
3924
|
+
_state.trys.push([
|
|
3925
|
+
1,
|
|
3926
|
+
4,
|
|
3927
|
+
,
|
|
3928
|
+
5
|
|
3929
|
+
]);
|
|
3930
|
+
return [
|
|
3931
|
+
4,
|
|
3932
|
+
fetch("https://adstorm.co/api-adstorm-dev/adstorm/swirl/projects/".concat(encodeURIComponent(this.config.projectId), "/ad-insertion-point"))
|
|
3933
|
+
];
|
|
3934
|
+
case 2:
|
|
3935
|
+
resp = _state.sent();
|
|
3936
|
+
if (!resp.ok) return [
|
|
3937
|
+
2
|
|
3938
|
+
];
|
|
3939
|
+
return [
|
|
3940
|
+
4,
|
|
3941
|
+
resp.json()
|
|
3942
|
+
];
|
|
3943
|
+
case 3:
|
|
3944
|
+
data = _state.sent();
|
|
3945
|
+
isNew = data.updated_at !== ((_this_lastAdInsertionPoint = this.lastAdInsertionPoint) === null || _this_lastAdInsertionPoint === void 0 ? void 0 : _this_lastAdInsertionPoint.updated_at);
|
|
3946
|
+
this.lastAdInsertionPoint = data;
|
|
3947
|
+
if (isNew) {
|
|
3948
|
+
this.pushAdInsertionDebug("api_response", data.segment_ts_name, {
|
|
3949
|
+
offsetSeconds: data.offset_seconds,
|
|
3950
|
+
updatedAt: data.updated_at,
|
|
3951
|
+
detail: "project=".concat(data.project_id)
|
|
3952
|
+
});
|
|
3953
|
+
}
|
|
3954
|
+
if (this.config.debugAdTiming) {
|
|
3955
|
+
console.log("[StormcloudVideoPlayer] Ad insertion point API response:", data);
|
|
3956
|
+
}
|
|
3957
|
+
return [
|
|
3958
|
+
3,
|
|
3959
|
+
5
|
|
3960
|
+
];
|
|
3961
|
+
case 4:
|
|
3962
|
+
unused = _state.sent();
|
|
3963
|
+
if (this.config.debugAdTiming) {
|
|
3964
|
+
console.warn("[StormcloudVideoPlayer] Ad insertion point API fetch failed");
|
|
3965
|
+
}
|
|
3966
|
+
return [
|
|
3967
|
+
3,
|
|
3968
|
+
5
|
|
3969
|
+
];
|
|
3970
|
+
case 5:
|
|
3971
|
+
return [
|
|
3972
|
+
2
|
|
3973
|
+
];
|
|
3974
|
+
}
|
|
3975
|
+
});
|
|
3976
|
+
}).call(this);
|
|
3977
|
+
}
|
|
3978
|
+
},
|
|
3979
|
+
{
|
|
3980
|
+
key: "checkAdInsertionInManifest",
|
|
3981
|
+
value: function checkAdInsertionInManifest() {
|
|
3982
|
+
var _this_hls;
|
|
3983
|
+
if (!this.lastAdInsertionPoint) return;
|
|
3984
|
+
if (this.inAdBreak || this.pendingAdBreak) return;
|
|
3985
|
+
if (this.lastAdInsertionPoint.updated_at === this.processedAdInsertionUpdatedAt) return;
|
|
3986
|
+
var segmentName = this.lastAdInsertionPoint.segment_ts_name;
|
|
3987
|
+
var levels = (_this_hls = this.hls) === null || _this_hls === void 0 ? void 0 : _this_hls.levels;
|
|
3988
|
+
if (!levels) return;
|
|
3989
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
3990
|
+
try {
|
|
3991
|
+
for(var _iterator = levels[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
3992
|
+
var level = _step.value;
|
|
3993
|
+
var _level_details;
|
|
3994
|
+
var fragments = (_level_details = level.details) === null || _level_details === void 0 ? void 0 : _level_details.fragments;
|
|
3995
|
+
if (!Array.isArray(fragments)) continue;
|
|
3996
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
3997
|
+
try {
|
|
3998
|
+
for(var _iterator1 = fragments[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
3999
|
+
var frag = _step1.value;
|
|
4000
|
+
if (this.fragmentMatchesSegment(frag, segmentName)) {
|
|
4001
|
+
var _ref;
|
|
4002
|
+
this.pushAdInsertionDebug("segment_found", segmentName, {
|
|
4003
|
+
detail: "sn=".concat((_ref = frag === null || frag === void 0 ? void 0 : frag.sn) !== null && _ref !== void 0 ? _ref : "?")
|
|
4004
|
+
});
|
|
4005
|
+
if (this.config.debugAdTiming) {
|
|
4006
|
+
console.log('[StormcloudVideoPlayer] Ad insertion segment "'.concat(segmentName, '" found in manifest — starting pre-fetch'));
|
|
4007
|
+
}
|
|
4008
|
+
this.startAdPrefetch(60, frag === null || frag === void 0 ? void 0 : frag.sn);
|
|
4009
|
+
return;
|
|
4010
|
+
}
|
|
4011
|
+
}
|
|
4012
|
+
} catch (err) {
|
|
4013
|
+
_didIteratorError1 = true;
|
|
4014
|
+
_iteratorError1 = err;
|
|
4015
|
+
} finally{
|
|
4016
|
+
try {
|
|
4017
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
4018
|
+
_iterator1.return();
|
|
4019
|
+
}
|
|
4020
|
+
} finally{
|
|
4021
|
+
if (_didIteratorError1) {
|
|
4022
|
+
throw _iteratorError1;
|
|
4023
|
+
}
|
|
4024
|
+
}
|
|
4025
|
+
}
|
|
4026
|
+
}
|
|
4027
|
+
} catch (err) {
|
|
4028
|
+
_didIteratorError = true;
|
|
4029
|
+
_iteratorError = err;
|
|
4030
|
+
} finally{
|
|
4031
|
+
try {
|
|
4032
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
4033
|
+
_iterator.return();
|
|
4034
|
+
}
|
|
4035
|
+
} finally{
|
|
4036
|
+
if (_didIteratorError) {
|
|
4037
|
+
throw _iteratorError;
|
|
4038
|
+
}
|
|
4039
|
+
}
|
|
4040
|
+
}
|
|
4041
|
+
}
|
|
4042
|
+
},
|
|
4043
|
+
{
|
|
4044
|
+
key: "fragmentMatchesSegment",
|
|
4045
|
+
value: function fragmentMatchesSegment(frag, segmentName) {
|
|
4046
|
+
var _rawUrl_split_;
|
|
4047
|
+
var rawUrl = (frag === null || frag === void 0 ? void 0 : frag.url) || (frag === null || frag === void 0 ? void 0 : frag.relurl) || "";
|
|
4048
|
+
var url = (_rawUrl_split_ = rawUrl.split("?")[0]) !== null && _rawUrl_split_ !== void 0 ? _rawUrl_split_ : "";
|
|
4049
|
+
var name = segmentName.startsWith("/") ? segmentName : "/" + segmentName;
|
|
4050
|
+
return url.endsWith(name) || url.includes(name);
|
|
4051
|
+
}
|
|
4052
|
+
},
|
|
4053
|
+
{
|
|
4054
|
+
key: "clearAdInsertionOffsetTimer",
|
|
4055
|
+
value: function clearAdInsertionOffsetTimer() {
|
|
4056
|
+
if (this.adInsertionOffsetTimerId != null) {
|
|
4057
|
+
clearTimeout(this.adInsertionOffsetTimerId);
|
|
4058
|
+
this.adInsertionOffsetTimerId = void 0;
|
|
4059
|
+
}
|
|
4060
|
+
}
|
|
4061
|
+
},
|
|
4501
4062
|
{
|
|
4502
4063
|
key: "startContinuousFetchLoop",
|
|
4503
4064
|
value: function startContinuousFetchLoop() {
|
|
@@ -4823,13 +4384,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4823
4384
|
},
|
|
4824
4385
|
{
|
|
4825
4386
|
key: "handleAdStart",
|
|
4826
|
-
value: function handleAdStart(
|
|
4387
|
+
value: function handleAdStart(durationSeconds) {
|
|
4827
4388
|
return _async_to_generator(function() {
|
|
4828
|
-
var
|
|
4389
|
+
var _this_savedMutedStateBeforeAd, adBreakDurationMs, mode, state, adBreakToken, adVolume, token, remaining, err;
|
|
4829
4390
|
return _ts_generator(this, function(_state) {
|
|
4830
4391
|
switch(_state.label){
|
|
4831
4392
|
case 0:
|
|
4832
|
-
adBreakDurationMs =
|
|
4393
|
+
adBreakDurationMs = durationSeconds != null ? durationSeconds * 1e3 : void 0;
|
|
4833
4394
|
if (this.config.debugAdTiming) {
|
|
4834
4395
|
mode = this.isLiveStream ? "LIVE" : "VOD";
|
|
4835
4396
|
console.log("[CONTINUOUS-FETCH] \uD83D\uDCFA ".concat(mode, " MODE: Target duration=").concat(adBreakDurationMs, "ms"));
|
|
@@ -4840,13 +4401,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4840
4401
|
this.pendingNextAdBids = null;
|
|
4841
4402
|
this.isShowingPlaceholder = false;
|
|
4842
4403
|
this.totalAdRequestsInBreak = 0;
|
|
4843
|
-
if (this.
|
|
4844
|
-
this.
|
|
4404
|
+
if (this.savedMutedStateBeforeAd == null && !this.video.muted) {
|
|
4405
|
+
this.savedMutedStateBeforeAd = {
|
|
4845
4406
|
muted: false,
|
|
4846
4407
|
volume: this.video.volume
|
|
4847
4408
|
};
|
|
4848
4409
|
}
|
|
4849
|
-
state = (
|
|
4410
|
+
state = (_this_savedMutedStateBeforeAd = this.savedMutedStateBeforeAd) !== null && _this_savedMutedStateBeforeAd !== void 0 ? _this_savedMutedStateBeforeAd : {
|
|
4850
4411
|
muted: this.video.muted,
|
|
4851
4412
|
volume: this.video.volume
|
|
4852
4413
|
};
|
|
@@ -4873,6 +4434,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4873
4434
|
if (this.expectedAdBreakDurationMs == null && adBreakDurationMs != null) {
|
|
4874
4435
|
this.expectedAdBreakDurationMs = adBreakDurationMs;
|
|
4875
4436
|
}
|
|
4437
|
+
if (this.expectedAdBreakDurationMs != null) {
|
|
4438
|
+
this.scheduleAdStopCountdown(this.expectedAdBreakDurationMs);
|
|
4439
|
+
}
|
|
4876
4440
|
this.clearPendingAdBreak();
|
|
4877
4441
|
adBreakToken = Date.now();
|
|
4878
4442
|
this.activeAdRequestToken = adBreakToken;
|
|
@@ -5371,54 +4935,18 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5371
4935
|
this.handleAdPodComplete();
|
|
5372
4936
|
}
|
|
5373
4937
|
},
|
|
5374
|
-
{
|
|
5375
|
-
key: "scheduleAdStartIn",
|
|
5376
|
-
value: function scheduleAdStartIn(delayMs) {
|
|
5377
|
-
var _this = this;
|
|
5378
|
-
this.clearAdStartTimer();
|
|
5379
|
-
var ms = Math.max(0, Math.floor(delayMs));
|
|
5380
|
-
if (ms === 0) {
|
|
5381
|
-
this.handleAdStart({
|
|
5382
|
-
type: "start"
|
|
5383
|
-
}).catch(function() {});
|
|
5384
|
-
return;
|
|
5385
|
-
}
|
|
5386
|
-
this.adStartTimerId = window.setTimeout(function() {
|
|
5387
|
-
_this.handleAdStart({
|
|
5388
|
-
type: "start"
|
|
5389
|
-
}).catch(function() {});
|
|
5390
|
-
}, ms);
|
|
5391
|
-
}
|
|
5392
|
-
},
|
|
5393
|
-
{
|
|
5394
|
-
key: "clearAdStartTimer",
|
|
5395
|
-
value: function clearAdStartTimer() {
|
|
5396
|
-
if (this.adStartTimerId != null) {
|
|
5397
|
-
clearTimeout(this.adStartTimerId);
|
|
5398
|
-
this.adStartTimerId = void 0;
|
|
5399
|
-
}
|
|
5400
|
-
}
|
|
5401
|
-
},
|
|
5402
|
-
{
|
|
5403
|
-
key: "updatePtsDrift",
|
|
5404
|
-
value: function updatePtsDrift(ptsSecondsSample) {
|
|
5405
|
-
var sampleMs = (this.video.currentTime - ptsSecondsSample) * 1e3;
|
|
5406
|
-
if (!Number.isFinite(sampleMs) || Math.abs(sampleMs) > 6e4) return;
|
|
5407
|
-
var alpha = 0.1;
|
|
5408
|
-
this.ptsDriftEmaMs = this.ptsDriftEmaMs * (1 - alpha) + sampleMs * alpha;
|
|
5409
|
-
}
|
|
5410
|
-
},
|
|
5411
4938
|
{
|
|
5412
4939
|
key: "handleAdPodComplete",
|
|
5413
4940
|
value: function handleAdPodComplete() {
|
|
5414
4941
|
var _this = this;
|
|
5415
4942
|
var _ref, _ref1;
|
|
5416
|
-
var
|
|
4943
|
+
var _this_savedMutedStateBeforeAd, _this_savedMutedStateBeforeAd1;
|
|
5417
4944
|
if (this.config.debugAdTiming) {
|
|
5418
4945
|
console.log("[StormcloudVideoPlayer] \uD83C\uDFC1 Ad pod complete - cleaning up");
|
|
5419
4946
|
}
|
|
5420
4947
|
this.clearAdRequestWatchdog();
|
|
5421
4948
|
this.clearAdFailsafeTimer();
|
|
4949
|
+
this.clearAdInsertionOffsetTimer();
|
|
5422
4950
|
this.activeAdRequestToken = null;
|
|
5423
4951
|
this.isInAdTransition = false;
|
|
5424
4952
|
this.stopContinuousFetching();
|
|
@@ -5434,7 +4962,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5434
4962
|
this.inAdBreak = false;
|
|
5435
4963
|
this.expectedAdBreakDurationMs = void 0;
|
|
5436
4964
|
this.currentAdBreakStartWallClockMs = void 0;
|
|
5437
|
-
this.clearAdStartTimer();
|
|
5438
4965
|
this.clearAdStopTimer();
|
|
5439
4966
|
this.adPodQueue = [];
|
|
5440
4967
|
this.showAds = false;
|
|
@@ -5442,8 +4969,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5442
4969
|
this.totalAdsInBreak = 0;
|
|
5443
4970
|
this.totalAdRequestsInBreak = 0;
|
|
5444
4971
|
this.consecutiveFailures = 0;
|
|
5445
|
-
var restoredMuted = (_ref = (
|
|
5446
|
-
var restoredVolume = (_ref1 = (
|
|
4972
|
+
var restoredMuted = (_ref = (_this_savedMutedStateBeforeAd = this.savedMutedStateBeforeAd) === null || _this_savedMutedStateBeforeAd === void 0 ? void 0 : _this_savedMutedStateBeforeAd.muted) !== null && _ref !== void 0 ? _ref : this.adLayer.getOriginalMutedState();
|
|
4973
|
+
var restoredVolume = (_ref1 = (_this_savedMutedStateBeforeAd1 = this.savedMutedStateBeforeAd) === null || _this_savedMutedStateBeforeAd1 === void 0 ? void 0 : _this_savedMutedStateBeforeAd1.volume) !== null && _ref1 !== void 0 ? _ref1 : this.adLayer.getOriginalVolume();
|
|
5447
4974
|
this.adLayer.updateOriginalMutedState(restoredMuted, restoredVolume);
|
|
5448
4975
|
this.adLayer.stop().catch(function() {});
|
|
5449
4976
|
if (this.video.muted !== restoredMuted) {
|
|
@@ -5552,7 +5079,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5552
5079
|
}, delay);
|
|
5553
5080
|
});
|
|
5554
5081
|
}
|
|
5555
|
-
this.
|
|
5082
|
+
this.savedMutedStateBeforeAd = null;
|
|
5556
5083
|
}
|
|
5557
5084
|
},
|
|
5558
5085
|
{
|
|
@@ -5702,19 +5229,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5702
5229
|
return Math.max(0, this.expectedAdBreakDurationMs - elapsed);
|
|
5703
5230
|
}
|
|
5704
5231
|
},
|
|
5705
|
-
{
|
|
5706
|
-
key: "pushScteMarker",
|
|
5707
|
-
value: function pushScteMarker(marker) {
|
|
5708
|
-
if (!this.config.debugAdTiming) return;
|
|
5709
|
-
this.scteMarkerHistory.push({
|
|
5710
|
-
timestampMs: Date.now(),
|
|
5711
|
-
marker: marker
|
|
5712
|
-
});
|
|
5713
|
-
if (this.scteMarkerHistory.length > DEBUG_HISTORY_LIMIT) {
|
|
5714
|
-
this.scteMarkerHistory = this.scteMarkerHistory.slice(-DEBUG_HISTORY_LIMIT);
|
|
5715
|
-
}
|
|
5716
|
-
}
|
|
5717
|
-
},
|
|
5718
5232
|
{
|
|
5719
5233
|
key: "pushDebugLog",
|
|
5720
5234
|
value: function pushDebugLog(level, category, message, details) {
|
|
@@ -5733,20 +5247,29 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5733
5247
|
}
|
|
5734
5248
|
},
|
|
5735
5249
|
{
|
|
5736
|
-
key: "
|
|
5737
|
-
value: function
|
|
5738
|
-
|
|
5739
|
-
|
|
5740
|
-
|
|
5741
|
-
|
|
5742
|
-
|
|
5743
|
-
|
|
5744
|
-
|
|
5745
|
-
|
|
5746
|
-
|
|
5747
|
-
|
|
5748
|
-
|
|
5749
|
-
});
|
|
5250
|
+
key: "pushAdInsertionDebug",
|
|
5251
|
+
value: function pushAdInsertionDebug(event, segmentName, opts) {
|
|
5252
|
+
if (!this.config.debugAdTiming) return;
|
|
5253
|
+
this.adInsertionDebugHistory.push(_object_spread({
|
|
5254
|
+
timestampMs: Date.now(),
|
|
5255
|
+
event: event,
|
|
5256
|
+
segmentName: segmentName
|
|
5257
|
+
}, (opts === null || opts === void 0 ? void 0 : opts.offsetSeconds) !== void 0 ? {
|
|
5258
|
+
offsetSeconds: opts.offsetSeconds
|
|
5259
|
+
} : {}, (opts === null || opts === void 0 ? void 0 : opts.updatedAt) ? {
|
|
5260
|
+
updatedAt: opts.updatedAt
|
|
5261
|
+
} : {}, (opts === null || opts === void 0 ? void 0 : opts.detail) ? {
|
|
5262
|
+
detail: opts.detail
|
|
5263
|
+
} : {}));
|
|
5264
|
+
if (this.adInsertionDebugHistory.length > DEBUG_HISTORY_LIMIT) {
|
|
5265
|
+
this.adInsertionDebugHistory = this.adInsertionDebugHistory.slice(-DEBUG_HISTORY_LIMIT);
|
|
5266
|
+
}
|
|
5267
|
+
}
|
|
5268
|
+
},
|
|
5269
|
+
{
|
|
5270
|
+
key: "getAdInsertionDebugLog",
|
|
5271
|
+
value: function getAdInsertionDebugLog() {
|
|
5272
|
+
return this.adInsertionDebugHistory.slice();
|
|
5750
5273
|
}
|
|
5751
5274
|
},
|
|
5752
5275
|
{
|
|
@@ -6015,9 +5538,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6015
5538
|
key: "destroy",
|
|
6016
5539
|
value: function destroy() {
|
|
6017
5540
|
var _this_hls, _this_adLayer;
|
|
5541
|
+
this.stopAdInsertionPolling();
|
|
5542
|
+
this.clearAdInsertionOffsetTimer();
|
|
6018
5543
|
this.stopContinuousFetching();
|
|
6019
5544
|
this.stopFillerBreakTimer();
|
|
6020
|
-
this.clearAdStartTimer();
|
|
6021
5545
|
this.clearAdStopTimer();
|
|
6022
5546
|
this.clearAdFailsafeTimer();
|
|
6023
5547
|
this.clearAdRequestWatchdog();
|
|
@@ -6045,7 +5569,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6045
5569
|
(_this_adLayer = this.adLayer) === null || _this_adLayer === void 0 ? void 0 : _this_adLayer.destroy();
|
|
6046
5570
|
this.consecutiveFailures = 0;
|
|
6047
5571
|
this.debugLogEntries = [];
|
|
6048
|
-
this.
|
|
5572
|
+
this.adInsertionDebugHistory = [];
|
|
6049
5573
|
}
|
|
6050
5574
|
}
|
|
6051
5575
|
]);
|