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
|
@@ -1391,7 +1391,6 @@ function createAdStormPlayer(contentVideo, options) {
|
|
|
1391
1391
|
contentVideo.muted = originalMutedState;
|
|
1392
1392
|
contentVideo.volume = originalVolume;
|
|
1393
1393
|
currentAd = void 0;
|
|
1394
|
-
tornDown = false;
|
|
1395
1394
|
return [
|
|
1396
1395
|
2,
|
|
1397
1396
|
Promise.resolve()
|
|
@@ -1506,6 +1505,15 @@ function createAdStormPlayer(contentVideo, options) {
|
|
|
1506
1505
|
if (!token) return [
|
|
1507
1506
|
2
|
|
1508
1507
|
];
|
|
1508
|
+
if (currentAd) {
|
|
1509
|
+
preloadSlots.set(token, {
|
|
1510
|
+
ad: currentAd
|
|
1511
|
+
});
|
|
1512
|
+
currentAd = void 0;
|
|
1513
|
+
return [
|
|
1514
|
+
2
|
|
1515
|
+
];
|
|
1516
|
+
}
|
|
1509
1517
|
requestContext = typeof arg1 === "string" ? arg2 : arg1;
|
|
1510
1518
|
return [
|
|
1511
1519
|
4,
|
|
@@ -1999,56 +2007,6 @@ function sendInitialTracking(licenseKey) {
|
|
|
1999
2007
|
});
|
|
2000
2008
|
})();
|
|
2001
2009
|
}
|
|
2002
|
-
function sendAdDetectTracking(licenseKey, adDetectInfo) {
|
|
2003
|
-
return _async_to_generator(function() {
|
|
2004
|
-
var clientInfo, browserId, trackingData, error;
|
|
2005
|
-
return _ts_generator(this, function(_state) {
|
|
2006
|
-
switch(_state.label){
|
|
2007
|
-
case 0:
|
|
2008
|
-
_state.trys.push([
|
|
2009
|
-
0,
|
|
2010
|
-
3,
|
|
2011
|
-
,
|
|
2012
|
-
4
|
|
2013
|
-
]);
|
|
2014
|
-
clientInfo = getClientInfo();
|
|
2015
|
-
return [
|
|
2016
|
-
4,
|
|
2017
|
-
getBrowserID(clientInfo)
|
|
2018
|
-
];
|
|
2019
|
-
case 1:
|
|
2020
|
-
browserId = _state.sent();
|
|
2021
|
-
trackingData = _object_spread({
|
|
2022
|
-
browserId: browserId
|
|
2023
|
-
}, clientInfo);
|
|
2024
|
-
return [
|
|
2025
|
-
4,
|
|
2026
|
-
sendTrackRequest(licenseKey, _object_spread_props(_object_spread({}, trackingData), {
|
|
2027
|
-
licenseKey: licenseKey,
|
|
2028
|
-
adDetectInfo: adDetectInfo
|
|
2029
|
-
}))
|
|
2030
|
-
];
|
|
2031
|
-
case 2:
|
|
2032
|
-
_state.sent();
|
|
2033
|
-
return [
|
|
2034
|
-
3,
|
|
2035
|
-
4
|
|
2036
|
-
];
|
|
2037
|
-
case 3:
|
|
2038
|
-
error = _state.sent();
|
|
2039
|
-
console.error("[StormcloudVideoPlayer] Error sending ad detect tracking:", error);
|
|
2040
|
-
return [
|
|
2041
|
-
3,
|
|
2042
|
-
4
|
|
2043
|
-
];
|
|
2044
|
-
case 4:
|
|
2045
|
-
return [
|
|
2046
|
-
2
|
|
2047
|
-
];
|
|
2048
|
-
}
|
|
2049
|
-
});
|
|
2050
|
-
})();
|
|
2051
|
-
}
|
|
2052
2010
|
function sendAdLoadedTracking(licenseKey, adLoadedInfo) {
|
|
2053
2011
|
return _async_to_generator(function() {
|
|
2054
2012
|
var clientInfo, browserId, trackingData, error;
|
|
@@ -2733,7 +2691,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
2733
2691
|
this.continuousFetchLoopPromise = null;
|
|
2734
2692
|
this.attached = false;
|
|
2735
2693
|
this.inAdBreak = false;
|
|
2736
|
-
this.ptsDriftEmaMs = 0;
|
|
2737
2694
|
this.adPodQueue = [];
|
|
2738
2695
|
this.lastHeartbeatTime = 0;
|
|
2739
2696
|
this.currentAdIndex = 0;
|
|
@@ -2752,10 +2709,12 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
2752
2709
|
this.isInAdTransition = false;
|
|
2753
2710
|
this.maxPlaceholderDurationMs = 5e3;
|
|
2754
2711
|
this.isShowingPlaceholder = false;
|
|
2712
|
+
this.lastAdInsertionPoint = null;
|
|
2713
|
+
this.processedAdInsertionUpdatedAt = null;
|
|
2755
2714
|
this.totalAdRequestsInBreak = 0;
|
|
2756
2715
|
this.maxTotalAdRequestsPerBreak = 20;
|
|
2757
2716
|
this.pendingAdBreak = null;
|
|
2758
|
-
this.
|
|
2717
|
+
this.savedMutedStateBeforeAd = null;
|
|
2759
2718
|
this.consecutiveFailures = 0;
|
|
2760
2719
|
this.maxConsecutiveFailures = 5;
|
|
2761
2720
|
this.lastAdRequestTime = 0;
|
|
@@ -2768,7 +2727,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
2768
2727
|
this.adRequestRetryBackoffMs = 1500;
|
|
2769
2728
|
this.preloadedTokens = [];
|
|
2770
2729
|
this.debugLogEntries = [];
|
|
2771
|
-
this.
|
|
2730
|
+
this.adInsertionDebugHistory = [];
|
|
2772
2731
|
initializePolyfills();
|
|
2773
2732
|
var browserOverrides = getBrowserConfigOverrides();
|
|
2774
2733
|
this.config = _object_spread({}, browserOverrides, config);
|
|
@@ -2953,6 +2912,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
2953
2912
|
_state.sent();
|
|
2954
2913
|
_state.label = 2;
|
|
2955
2914
|
case 2:
|
|
2915
|
+
if (!this.config.disableAds && this.config.projectId) {
|
|
2916
|
+
this.startAdInsertionPolling();
|
|
2917
|
+
}
|
|
2956
2918
|
return [
|
|
2957
2919
|
2
|
|
2958
2920
|
];
|
|
@@ -2960,78 +2922,11 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
2960
2922
|
});
|
|
2961
2923
|
}).call(_this);
|
|
2962
2924
|
});
|
|
2963
|
-
this.hls.on(import_hls.default.Events.LEVEL_LOADED, function(
|
|
2925
|
+
this.hls.on(import_hls.default.Events.LEVEL_LOADED, function() {
|
|
2964
2926
|
if (_this.inAdBreak || _this.pendingAdBreak) {
|
|
2965
2927
|
return;
|
|
2966
2928
|
}
|
|
2967
|
-
|
|
2968
|
-
if (!details || !details.fragments || details.fragments.length === 0) {
|
|
2969
|
-
return;
|
|
2970
|
-
}
|
|
2971
|
-
var fragmentsToScan = Math.min(5, details.fragments.length);
|
|
2972
|
-
for(var i = 0; i < fragmentsToScan; i++){
|
|
2973
|
-
var frag = details.fragments[i];
|
|
2974
|
-
var tagList = frag === null || frag === void 0 ? void 0 : frag.tagList;
|
|
2975
|
-
if (!Array.isArray(tagList)) continue;
|
|
2976
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
2977
|
-
try {
|
|
2978
|
-
for(var _iterator = tagList[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
2979
|
-
var entry = _step.value;
|
|
2980
|
-
var tag = "";
|
|
2981
|
-
var value = "";
|
|
2982
|
-
if (Array.isArray(entry)) {
|
|
2983
|
-
var _entry_, _entry_1;
|
|
2984
|
-
tag = String((_entry_ = entry[0]) !== null && _entry_ !== void 0 ? _entry_ : "");
|
|
2985
|
-
value = String((_entry_1 = entry[1]) !== null && _entry_1 !== void 0 ? _entry_1 : "");
|
|
2986
|
-
} else if (typeof entry === "string") {
|
|
2987
|
-
var idx = entry.indexOf(":");
|
|
2988
|
-
if (idx >= 0) {
|
|
2989
|
-
tag = entry.substring(0, idx);
|
|
2990
|
-
value = entry.substring(idx + 1);
|
|
2991
|
-
} else {
|
|
2992
|
-
tag = entry;
|
|
2993
|
-
}
|
|
2994
|
-
}
|
|
2995
|
-
if (!tag) continue;
|
|
2996
|
-
if (tag.includes("EXT-X-CUE-OUT") || tag.includes("EXT-X-DATERANGE")) {
|
|
2997
|
-
var attrs = tag.includes("EXT-X-DATERANGE") ? _this.parseAttributeList(value) : {};
|
|
2998
|
-
var hasScteOut = tag.includes("EXT-X-CUE-OUT") || "SCTE35-OUT" in attrs || attrs["SCTE35-OUT"] !== void 0;
|
|
2999
|
-
if (hasScteOut) {
|
|
3000
|
-
var durationSeconds = _this.parseCueOutDuration(value);
|
|
3001
|
-
var marker = _object_spread_props(_object_spread({
|
|
3002
|
-
type: "start"
|
|
3003
|
-
}, durationSeconds !== void 0 ? {
|
|
3004
|
-
durationSeconds: durationSeconds
|
|
3005
|
-
} : {}), {
|
|
3006
|
-
raw: {
|
|
3007
|
-
tag: tag,
|
|
3008
|
-
value: value,
|
|
3009
|
-
earlyDetection: true
|
|
3010
|
-
}
|
|
3011
|
-
});
|
|
3012
|
-
if (_this.config.debugAdTiming) {
|
|
3013
|
-
console.log("[StormcloudVideoPlayer] \uD83C\uDFAF EARLY SCTE-35 DETECTION: Ad break marker found in fragment", i, "- starting pre-fetch (NOT playing yet)");
|
|
3014
|
-
}
|
|
3015
|
-
_this.startAdPrefetch(marker, frag === null || frag === void 0 ? void 0 : frag.sn);
|
|
3016
|
-
return;
|
|
3017
|
-
}
|
|
3018
|
-
}
|
|
3019
|
-
}
|
|
3020
|
-
} catch (err) {
|
|
3021
|
-
_didIteratorError = true;
|
|
3022
|
-
_iteratorError = err;
|
|
3023
|
-
} finally{
|
|
3024
|
-
try {
|
|
3025
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
3026
|
-
_iterator.return();
|
|
3027
|
-
}
|
|
3028
|
-
} finally{
|
|
3029
|
-
if (_didIteratorError) {
|
|
3030
|
-
throw _iteratorError;
|
|
3031
|
-
}
|
|
3032
|
-
}
|
|
3033
|
-
}
|
|
3034
|
-
}
|
|
2929
|
+
_this.checkAdInsertionInManifest();
|
|
3035
2930
|
});
|
|
3036
2931
|
this.hls.on(import_hls.default.Events.FRAG_BUFFERED, function(_evt, data) {
|
|
3037
2932
|
return _async_to_generator(function() {
|
|
@@ -3093,111 +2988,55 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3093
2988
|
});
|
|
3094
2989
|
}).call(_this);
|
|
3095
2990
|
});
|
|
3096
|
-
this.hls.on(import_hls.default.Events.FRAG_PARSING_METADATA, function(_evt, data) {
|
|
3097
|
-
var id3Tags = ((data === null || data === void 0 ? void 0 : data.samples) || []).map(function(s) {
|
|
3098
|
-
return {
|
|
3099
|
-
key: "ID3",
|
|
3100
|
-
value: s === null || s === void 0 ? void 0 : s.data,
|
|
3101
|
-
ptsSeconds: s === null || s === void 0 ? void 0 : s.pts
|
|
3102
|
-
};
|
|
3103
|
-
});
|
|
3104
|
-
id3Tags.forEach(function(tag) {
|
|
3105
|
-
return _this.onId3Tag(tag);
|
|
3106
|
-
});
|
|
3107
|
-
});
|
|
3108
2991
|
this.hls.on(import_hls.default.Events.FRAG_CHANGED, function(_evt, data) {
|
|
3109
2992
|
var frag = data === null || data === void 0 ? void 0 : data.frag;
|
|
3110
|
-
|
|
3111
|
-
if (!
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
var
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
var idx = entry.indexOf(":");
|
|
3124
|
-
if (idx >= 0) {
|
|
3125
|
-
tag = entry.substring(0, idx);
|
|
3126
|
-
value = entry.substring(idx + 1);
|
|
3127
|
-
} else {
|
|
3128
|
-
tag = entry;
|
|
3129
|
-
value = "";
|
|
3130
|
-
}
|
|
2993
|
+
if (!frag) return;
|
|
2994
|
+
if (_this.lastAdInsertionPoint && !_this.inAdBreak && _this.lastAdInsertionPoint.updated_at !== _this.processedAdInsertionUpdatedAt) {
|
|
2995
|
+
var segmentName = _this.lastAdInsertionPoint.segment_ts_name;
|
|
2996
|
+
if (_this.fragmentMatchesSegment(frag, segmentName)) {
|
|
2997
|
+
var _ref;
|
|
2998
|
+
_this.processedAdInsertionUpdatedAt = _this.lastAdInsertionPoint.updated_at;
|
|
2999
|
+
var offsetMs = (_this.lastAdInsertionPoint.offset_seconds || 0) * 1e3;
|
|
3000
|
+
_this.pushAdInsertionDebug("segment_playing", segmentName, {
|
|
3001
|
+
offsetSeconds: _this.lastAdInsertionPoint.offset_seconds,
|
|
3002
|
+
detail: "sn=".concat((_ref = frag === null || frag === void 0 ? void 0 : frag.sn) !== null && _ref !== void 0 ? _ref : "?")
|
|
3003
|
+
});
|
|
3004
|
+
if (_this.config.debugAdTiming) {
|
|
3005
|
+
console.log('[StormcloudVideoPlayer] Ad insertion segment "'.concat(segmentName, '" now playing — scheduling ad start in ').concat(offsetMs, "ms"));
|
|
3131
3006
|
}
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
raw: {
|
|
3143
|
-
tag: tag,
|
|
3144
|
-
value: value
|
|
3145
|
-
}
|
|
3146
|
-
});
|
|
3147
|
-
_this.onScte35Marker(marker);
|
|
3148
|
-
} else if (tag.includes("EXT-X-CUE-OUT")) {
|
|
3149
|
-
var durationSeconds = _this.parseCueOutDuration(value);
|
|
3150
|
-
var marker1 = _object_spread_props(_object_spread({
|
|
3151
|
-
type: "start"
|
|
3152
|
-
}, durationSeconds !== void 0 ? {
|
|
3153
|
-
durationSeconds: durationSeconds
|
|
3154
|
-
} : {}), {
|
|
3155
|
-
raw: {
|
|
3156
|
-
tag: tag,
|
|
3157
|
-
value: value
|
|
3158
|
-
}
|
|
3007
|
+
_this.pushAdInsertionDebug("ad_scheduled", segmentName, {
|
|
3008
|
+
offsetSeconds: _this.lastAdInsertionPoint.offset_seconds,
|
|
3009
|
+
detail: "in ".concat(offsetMs, "ms, dur=60s")
|
|
3010
|
+
});
|
|
3011
|
+
_this.clearAdInsertionOffsetTimer();
|
|
3012
|
+
_this.adInsertionOffsetTimerId = window.setTimeout(function() {
|
|
3013
|
+
_this.adInsertionOffsetTimerId = void 0;
|
|
3014
|
+
if (_this.inAdBreak) return;
|
|
3015
|
+
_this.pushAdInsertionDebug("ad_triggered", segmentName, {
|
|
3016
|
+
detail: "ad break started (60s)"
|
|
3159
3017
|
});
|
|
3160
|
-
_this.
|
|
3161
|
-
}
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
raw: {
|
|
3183
|
-
tag: tag,
|
|
3184
|
-
value: value,
|
|
3185
|
-
attrs: attrs
|
|
3186
|
-
}
|
|
3187
|
-
});
|
|
3188
|
-
_this.onScte35Marker(marker2);
|
|
3189
|
-
}
|
|
3190
|
-
if (hasScteIn) {
|
|
3191
|
-
_this.onScte35Marker({
|
|
3192
|
-
type: "end",
|
|
3193
|
-
raw: {
|
|
3194
|
-
tag: tag,
|
|
3195
|
-
value: value,
|
|
3196
|
-
attrs: attrs
|
|
3197
|
-
}
|
|
3198
|
-
});
|
|
3199
|
-
}
|
|
3200
|
-
}
|
|
3018
|
+
void _this.handleAdStart(60);
|
|
3019
|
+
}, offsetMs);
|
|
3020
|
+
}
|
|
3021
|
+
}
|
|
3022
|
+
});
|
|
3023
|
+
this.hls.on(import_hls.default.Events.FRAG_PARSING_USERDATA, function(_evt, data) {
|
|
3024
|
+
var _ref;
|
|
3025
|
+
var samples = (_ref = data === null || data === void 0 ? void 0 : data.samples) !== null && _ref !== void 0 ? _ref : [];
|
|
3026
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
3027
|
+
try {
|
|
3028
|
+
for(var _iterator = samples[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
3029
|
+
var sample = _step.value;
|
|
3030
|
+
var _ref1, _ref2;
|
|
3031
|
+
var _data_frag, _data_frag1;
|
|
3032
|
+
var bytes = sample === null || sample === void 0 ? void 0 : sample.data;
|
|
3033
|
+
if (!bytes || bytes.length < 5) continue;
|
|
3034
|
+
var isSCTE35 = bytes[0] === 252;
|
|
3035
|
+
if (!isSCTE35) continue;
|
|
3036
|
+
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 : "";
|
|
3037
|
+
_this.pushAdInsertionDebug("scte35_inserted", segName, {
|
|
3038
|
+
detail: "len=".concat(bytes.length, "B")
|
|
3039
|
+
});
|
|
3201
3040
|
}
|
|
3202
3041
|
} catch (err) {
|
|
3203
3042
|
_didIteratorError = true;
|
|
@@ -3288,8 +3127,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3288
3127
|
_this.activeAdRequestToken = null;
|
|
3289
3128
|
_this.showAds = true;
|
|
3290
3129
|
if (_this.config.disableFiller) {
|
|
3291
|
-
if (_this.
|
|
3292
|
-
_this.
|
|
3130
|
+
if (_this.savedMutedStateBeforeAd == null) {
|
|
3131
|
+
_this.savedMutedStateBeforeAd = {
|
|
3293
3132
|
muted: _this.video.muted,
|
|
3294
3133
|
volume: _this.video.volume
|
|
3295
3134
|
};
|
|
@@ -3317,10 +3156,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3317
3156
|
});
|
|
3318
3157
|
this.adLayer.on("content_resume", function() {
|
|
3319
3158
|
var _ref, _ref1;
|
|
3320
|
-
var
|
|
3159
|
+
var _this_savedMutedStateBeforeAd, _this_savedMutedStateBeforeAd1;
|
|
3321
3160
|
var remaining = _this.getRemainingAdMs();
|
|
3322
|
-
var breakMuted = (_ref = (
|
|
3323
|
-
var breakVolume = (_ref1 = (
|
|
3161
|
+
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();
|
|
3162
|
+
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();
|
|
3324
3163
|
if (_this.config.debugAdTiming) {
|
|
3325
3164
|
console.log("[StormcloudVideoPlayer] content_resume received, inAdBreak=%s, remaining=%s, preloadedTokens=%d, pendingNext=%s", _this.inAdBreak, remaining, _this.preloadedTokens.length, !!_this.pendingNextAdBids);
|
|
3326
3165
|
}
|
|
@@ -3397,7 +3236,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3397
3236
|
var remainingFinal = _this.getRemainingAdMs();
|
|
3398
3237
|
if (_this.inAdBreak && remainingFinal > _this.MIN_AD_REMAINING_MS) {
|
|
3399
3238
|
if (_this.config.debugAdTiming) {
|
|
3400
|
-
console.log("[StormcloudVideoPlayer] content_resume:
|
|
3239
|
+
console.log("[StormcloudVideoPlayer] content_resume: ad ended/failed with time remaining, showing filler and continuing fetch for", remainingFinal, "ms");
|
|
3401
3240
|
}
|
|
3402
3241
|
if (!_this.config.disableFiller) {
|
|
3403
3242
|
_this.showPlaceholderLayer();
|
|
@@ -3415,7 +3254,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3415
3254
|
(_this_video_play = _this.video.play()) === null || _this_video_play === void 0 ? void 0 : _this_video_play.catch(function() {});
|
|
3416
3255
|
}
|
|
3417
3256
|
}
|
|
3418
|
-
_this.
|
|
3257
|
+
_this.continuousFetchingActive = true;
|
|
3258
|
+
_this.startContinuousFetchLoop();
|
|
3419
3259
|
return;
|
|
3420
3260
|
}
|
|
3421
3261
|
if (_this.config.debugAdTiming) {
|
|
@@ -3562,547 +3402,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3562
3402
|
return !!(this.config.allowNativeHls && canNative);
|
|
3563
3403
|
}
|
|
3564
3404
|
},
|
|
3565
|
-
{
|
|
3566
|
-
key: "onId3Tag",
|
|
3567
|
-
value: function onId3Tag(tag) {
|
|
3568
|
-
if (typeof tag.ptsSeconds === "number") {
|
|
3569
|
-
this.updatePtsDrift(tag.ptsSeconds);
|
|
3570
|
-
}
|
|
3571
|
-
var marker = this.parseScte35FromId3(tag);
|
|
3572
|
-
if (marker) {
|
|
3573
|
-
this.onScte35Marker(marker);
|
|
3574
|
-
}
|
|
3575
|
-
}
|
|
3576
|
-
},
|
|
3577
|
-
{
|
|
3578
|
-
key: "parseScte35FromId3",
|
|
3579
|
-
value: function parseScte35FromId3(tag) {
|
|
3580
|
-
var text = this.decodeId3ValueToText(tag.value);
|
|
3581
|
-
if (!text) return void 0;
|
|
3582
|
-
var cueOutMatch = text.match(/EXT-X-CUE-OUT(?::([^\r\n]*))?/i) || text.match(/CUE-OUT(?::([^\r\n]*))?/i);
|
|
3583
|
-
if (cueOutMatch) {
|
|
3584
|
-
var _cueOutMatch_;
|
|
3585
|
-
var arg = ((_cueOutMatch_ = cueOutMatch[1]) !== null && _cueOutMatch_ !== void 0 ? _cueOutMatch_ : "").trim();
|
|
3586
|
-
var dur = this.parseCueOutDuration(arg);
|
|
3587
|
-
var marker = _object_spread_props(_object_spread({
|
|
3588
|
-
type: "start"
|
|
3589
|
-
}, tag.ptsSeconds !== void 0 ? {
|
|
3590
|
-
ptsSeconds: tag.ptsSeconds
|
|
3591
|
-
} : {}, dur !== void 0 ? {
|
|
3592
|
-
durationSeconds: dur
|
|
3593
|
-
} : {}), {
|
|
3594
|
-
raw: {
|
|
3595
|
-
id3: text
|
|
3596
|
-
}
|
|
3597
|
-
});
|
|
3598
|
-
return marker;
|
|
3599
|
-
}
|
|
3600
|
-
var cueOutContMatch = text.match(/EXT-X-CUE-OUT-CONT:([^\r\n]*)/i);
|
|
3601
|
-
if (cueOutContMatch) {
|
|
3602
|
-
var _cueOutContMatch_;
|
|
3603
|
-
var arg1 = ((_cueOutContMatch_ = cueOutContMatch[1]) !== null && _cueOutContMatch_ !== void 0 ? _cueOutContMatch_ : "").trim();
|
|
3604
|
-
var cont = this.parseCueOutCont(arg1);
|
|
3605
|
-
var marker1 = _object_spread_props(_object_spread({
|
|
3606
|
-
type: "progress"
|
|
3607
|
-
}, tag.ptsSeconds !== void 0 ? {
|
|
3608
|
-
ptsSeconds: tag.ptsSeconds
|
|
3609
|
-
} : {}, (cont === null || cont === void 0 ? void 0 : cont.duration) !== void 0 ? {
|
|
3610
|
-
durationSeconds: cont.duration
|
|
3611
|
-
} : {}), {
|
|
3612
|
-
raw: {
|
|
3613
|
-
id3: text
|
|
3614
|
-
}
|
|
3615
|
-
});
|
|
3616
|
-
return marker1;
|
|
3617
|
-
}
|
|
3618
|
-
var cueInMatch = text.match(/EXT-X-CUE-IN\b/i) || text.match(/CUE-IN\b/i);
|
|
3619
|
-
if (cueInMatch) {
|
|
3620
|
-
var marker2 = _object_spread_props(_object_spread({
|
|
3621
|
-
type: "end"
|
|
3622
|
-
}, tag.ptsSeconds !== void 0 ? {
|
|
3623
|
-
ptsSeconds: tag.ptsSeconds
|
|
3624
|
-
} : {}), {
|
|
3625
|
-
raw: {
|
|
3626
|
-
id3: text
|
|
3627
|
-
}
|
|
3628
|
-
});
|
|
3629
|
-
return marker2;
|
|
3630
|
-
}
|
|
3631
|
-
var daterangeMatch = text.match(/EXT-X-DATERANGE:([^\r\n]*)/i);
|
|
3632
|
-
if (daterangeMatch) {
|
|
3633
|
-
var _daterangeMatch_, _attrs_CLASS;
|
|
3634
|
-
var attrs = this.parseAttributeList((_daterangeMatch_ = daterangeMatch[1]) !== null && _daterangeMatch_ !== void 0 ? _daterangeMatch_ : "");
|
|
3635
|
-
var hasScteOut = "SCTE35-OUT" in attrs || attrs["SCTE35-OUT"] !== void 0;
|
|
3636
|
-
var hasScteIn = "SCTE35-IN" in attrs || attrs["SCTE35-IN"] !== void 0;
|
|
3637
|
-
var klass = String((_attrs_CLASS = attrs["CLASS"]) !== null && _attrs_CLASS !== void 0 ? _attrs_CLASS : "");
|
|
3638
|
-
var duration = this.toNumber(attrs["DURATION"]);
|
|
3639
|
-
if (hasScteOut || /com\.apple\.hls\.cue/i.test(klass)) {
|
|
3640
|
-
var marker3 = _object_spread_props(_object_spread({
|
|
3641
|
-
type: "start"
|
|
3642
|
-
}, tag.ptsSeconds !== void 0 ? {
|
|
3643
|
-
ptsSeconds: tag.ptsSeconds
|
|
3644
|
-
} : {}, duration !== void 0 ? {
|
|
3645
|
-
durationSeconds: duration
|
|
3646
|
-
} : {}), {
|
|
3647
|
-
raw: {
|
|
3648
|
-
id3: text,
|
|
3649
|
-
attrs: attrs
|
|
3650
|
-
}
|
|
3651
|
-
});
|
|
3652
|
-
return marker3;
|
|
3653
|
-
}
|
|
3654
|
-
if (hasScteIn) {
|
|
3655
|
-
var marker4 = _object_spread_props(_object_spread({
|
|
3656
|
-
type: "end"
|
|
3657
|
-
}, tag.ptsSeconds !== void 0 ? {
|
|
3658
|
-
ptsSeconds: tag.ptsSeconds
|
|
3659
|
-
} : {}), {
|
|
3660
|
-
raw: {
|
|
3661
|
-
id3: text,
|
|
3662
|
-
attrs: attrs
|
|
3663
|
-
}
|
|
3664
|
-
});
|
|
3665
|
-
return marker4;
|
|
3666
|
-
}
|
|
3667
|
-
}
|
|
3668
|
-
if (/SCTE35-OUT/i.test(text)) {
|
|
3669
|
-
var marker5 = _object_spread_props(_object_spread({
|
|
3670
|
-
type: "start"
|
|
3671
|
-
}, tag.ptsSeconds !== void 0 ? {
|
|
3672
|
-
ptsSeconds: tag.ptsSeconds
|
|
3673
|
-
} : {}), {
|
|
3674
|
-
raw: {
|
|
3675
|
-
id3: text
|
|
3676
|
-
}
|
|
3677
|
-
});
|
|
3678
|
-
return marker5;
|
|
3679
|
-
}
|
|
3680
|
-
if (/SCTE35-IN/i.test(text)) {
|
|
3681
|
-
var marker6 = _object_spread_props(_object_spread({
|
|
3682
|
-
type: "end"
|
|
3683
|
-
}, tag.ptsSeconds !== void 0 ? {
|
|
3684
|
-
ptsSeconds: tag.ptsSeconds
|
|
3685
|
-
} : {}), {
|
|
3686
|
-
raw: {
|
|
3687
|
-
id3: text
|
|
3688
|
-
}
|
|
3689
|
-
});
|
|
3690
|
-
return marker6;
|
|
3691
|
-
}
|
|
3692
|
-
if (_instanceof(tag.value, Uint8Array)) {
|
|
3693
|
-
var bin = this.parseScte35Binary(tag.value);
|
|
3694
|
-
if (bin) return bin;
|
|
3695
|
-
}
|
|
3696
|
-
return void 0;
|
|
3697
|
-
}
|
|
3698
|
-
},
|
|
3699
|
-
{
|
|
3700
|
-
key: "decodeId3ValueToText",
|
|
3701
|
-
value: function decodeId3ValueToText(value) {
|
|
3702
|
-
try {
|
|
3703
|
-
if (typeof value === "string") return value;
|
|
3704
|
-
var decoder = new TextDecoder("utf-8", {
|
|
3705
|
-
fatal: false
|
|
3706
|
-
});
|
|
3707
|
-
var text = decoder.decode(value);
|
|
3708
|
-
if (text && /[\x20-\x7E]/.test(text)) return text;
|
|
3709
|
-
var out = "";
|
|
3710
|
-
for(var i = 0; i < value.length; i++)out += String.fromCharCode(value[i]);
|
|
3711
|
-
return out;
|
|
3712
|
-
} catch (unused) {
|
|
3713
|
-
return void 0;
|
|
3714
|
-
}
|
|
3715
|
-
}
|
|
3716
|
-
},
|
|
3717
|
-
{
|
|
3718
|
-
key: "onScte35Marker",
|
|
3719
|
-
value: function onScte35Marker(marker) {
|
|
3720
|
-
var _this = this;
|
|
3721
|
-
if (this.config.disableAds) return;
|
|
3722
|
-
this.pushScteMarker(marker);
|
|
3723
|
-
this.pushDebugLog("info", "scte35", "SCTE-35 marker detected", {
|
|
3724
|
-
type: marker.type,
|
|
3725
|
-
ptsSeconds: marker.ptsSeconds,
|
|
3726
|
-
durationSeconds: marker.durationSeconds,
|
|
3727
|
-
currentTime: this.video.currentTime
|
|
3728
|
-
});
|
|
3729
|
-
if (this.config.debugAdTiming) {
|
|
3730
|
-
console.log("[StormcloudVideoPlayer] SCTE-35 marker detected:", {
|
|
3731
|
-
type: marker.type,
|
|
3732
|
-
ptsSeconds: marker.ptsSeconds,
|
|
3733
|
-
durationSeconds: marker.durationSeconds,
|
|
3734
|
-
currentTime: this.video.currentTime,
|
|
3735
|
-
raw: marker.raw,
|
|
3736
|
-
hasPendingAdBreak: !!this.pendingAdBreak
|
|
3737
|
-
});
|
|
3738
|
-
}
|
|
3739
|
-
if (marker.type === "start") {
|
|
3740
|
-
var _this_config_immediateManifestAds;
|
|
3741
|
-
var _this_pendingAdBreak;
|
|
3742
|
-
if (this.savedMutedStateBeforeScte == null) {
|
|
3743
|
-
this.savedMutedStateBeforeScte = {
|
|
3744
|
-
muted: this.video.muted,
|
|
3745
|
-
volume: this.video.volume
|
|
3746
|
-
};
|
|
3747
|
-
this.adLayer.updateOriginalMutedState(this.video.muted, this.video.volume);
|
|
3748
|
-
}
|
|
3749
|
-
if (!this.config.disableFiller && !this.video.muted && !this.adLayer.isAdPlaying()) {
|
|
3750
|
-
this.video.muted = true;
|
|
3751
|
-
this.video.volume = 0;
|
|
3752
|
-
if (this.config.debugAdTiming) {
|
|
3753
|
-
console.log("[StormcloudVideoPlayer] Muted video on SCTE start marker");
|
|
3754
|
-
}
|
|
3755
|
-
}
|
|
3756
|
-
if (this.inAdBreak) {
|
|
3757
|
-
if (marker.durationSeconds != null) {
|
|
3758
|
-
var newDurationMs = marker.durationSeconds * 1e3;
|
|
3759
|
-
if (this.expectedAdBreakDurationMs == null || newDurationMs > this.expectedAdBreakDurationMs) {
|
|
3760
|
-
this.expectedAdBreakDurationMs = newDurationMs;
|
|
3761
|
-
var elapsedMs = this.currentAdBreakStartWallClockMs != null ? Date.now() - this.currentAdBreakStartWallClockMs : 0;
|
|
3762
|
-
var remainingMs = Math.max(0, newDurationMs - elapsedMs);
|
|
3763
|
-
this.scheduleAdStopCountdown(remainingMs);
|
|
3764
|
-
if (this.config.debugAdTiming) {
|
|
3765
|
-
console.log("[StormcloudVideoPlayer] Updated ad break duration from subsequent marker: ".concat(newDurationMs, "ms, remaining: ").concat(remainingMs, "ms"));
|
|
3766
|
-
}
|
|
3767
|
-
}
|
|
3768
|
-
}
|
|
3769
|
-
return;
|
|
3770
|
-
}
|
|
3771
|
-
this.inAdBreak = true;
|
|
3772
|
-
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;
|
|
3773
|
-
this.expectedAdBreakDurationMs = durationMs;
|
|
3774
|
-
this.currentAdBreakStartWallClockMs = Date.now();
|
|
3775
|
-
if (this.config.licenseKey) {
|
|
3776
|
-
var _this_pendingAdBreak1;
|
|
3777
|
-
var adDetectInfo = _object_spread({
|
|
3778
|
-
source: "scte35",
|
|
3779
|
-
timestamp: /* @__PURE__ */ new Date().toISOString()
|
|
3780
|
-
}, marker.durationSeconds != null && {
|
|
3781
|
-
durationSeconds: marker.durationSeconds
|
|
3782
|
-
}, marker.ptsSeconds != null && {
|
|
3783
|
-
ptsSeconds: marker.ptsSeconds
|
|
3784
|
-
}, ((_this_pendingAdBreak1 = this.pendingAdBreak) === null || _this_pendingAdBreak1 === void 0 ? void 0 : _this_pendingAdBreak1.detectedAtFragmentSn) != null && {
|
|
3785
|
-
detectedAtFragmentSn: this.pendingAdBreak.detectedAtFragmentSn
|
|
3786
|
-
});
|
|
3787
|
-
sendAdDetectTracking(this.config.licenseKey, adDetectInfo);
|
|
3788
|
-
}
|
|
3789
|
-
var isManifestMarker = this.isManifestBasedMarker(marker);
|
|
3790
|
-
var forceImmediate = (_this_config_immediateManifestAds = this.config.immediateManifestAds) !== null && _this_config_immediateManifestAds !== void 0 ? _this_config_immediateManifestAds : true;
|
|
3791
|
-
if (this.config.debugAdTiming) {
|
|
3792
|
-
console.log("[StormcloudVideoPlayer] Ad start decision:", {
|
|
3793
|
-
isManifestMarker: isManifestMarker,
|
|
3794
|
-
forceImmediate: forceImmediate,
|
|
3795
|
-
hasPts: typeof marker.ptsSeconds === "number"
|
|
3796
|
-
});
|
|
3797
|
-
}
|
|
3798
|
-
if (isManifestMarker && forceImmediate) {
|
|
3799
|
-
if (this.config.debugAdTiming) {
|
|
3800
|
-
console.log("[StormcloudVideoPlayer] Starting ad immediately (manifest-based)");
|
|
3801
|
-
}
|
|
3802
|
-
this.clearAdStartTimer();
|
|
3803
|
-
this.handleAdStart(marker);
|
|
3804
|
-
} else if (typeof marker.ptsSeconds === "number") {
|
|
3805
|
-
var _this_config_driftToleranceMs;
|
|
3806
|
-
var tol = (_this_config_driftToleranceMs = this.config.driftToleranceMs) !== null && _this_config_driftToleranceMs !== void 0 ? _this_config_driftToleranceMs : 1e3;
|
|
3807
|
-
var nowMs = this.video.currentTime * 1e3;
|
|
3808
|
-
var estCurrentPtsMs = nowMs - this.ptsDriftEmaMs;
|
|
3809
|
-
var deltaMs = Math.floor(marker.ptsSeconds * 1e3 - estCurrentPtsMs);
|
|
3810
|
-
if (this.config.debugAdTiming) {
|
|
3811
|
-
console.log("[StormcloudVideoPlayer] PTS-based timing calculation:", {
|
|
3812
|
-
nowMs: nowMs,
|
|
3813
|
-
estCurrentPtsMs: estCurrentPtsMs,
|
|
3814
|
-
markerPtsMs: marker.ptsSeconds * 1e3,
|
|
3815
|
-
deltaMs: deltaMs,
|
|
3816
|
-
tolerance: tol
|
|
3817
|
-
});
|
|
3818
|
-
}
|
|
3819
|
-
if (deltaMs > tol) {
|
|
3820
|
-
if (this.config.debugAdTiming) {
|
|
3821
|
-
console.log("[StormcloudVideoPlayer] Scheduling ad start in ".concat(deltaMs, "ms"));
|
|
3822
|
-
}
|
|
3823
|
-
this.scheduleAdStartIn(deltaMs);
|
|
3824
|
-
} else {
|
|
3825
|
-
if (this.config.debugAdTiming) {
|
|
3826
|
-
console.log("[StormcloudVideoPlayer] Starting ad immediately (within tolerance)");
|
|
3827
|
-
}
|
|
3828
|
-
this.clearAdStartTimer();
|
|
3829
|
-
this.handleAdStart(marker);
|
|
3830
|
-
}
|
|
3831
|
-
} else {
|
|
3832
|
-
if (this.config.debugAdTiming) {
|
|
3833
|
-
console.log("[StormcloudVideoPlayer] Starting ad immediately (fallback)");
|
|
3834
|
-
}
|
|
3835
|
-
this.clearAdStartTimer();
|
|
3836
|
-
this.handleAdStart(marker);
|
|
3837
|
-
}
|
|
3838
|
-
if (this.expectedAdBreakDurationMs != null) {
|
|
3839
|
-
this.scheduleAdStopCountdown(this.expectedAdBreakDurationMs);
|
|
3840
|
-
}
|
|
3841
|
-
return;
|
|
3842
|
-
}
|
|
3843
|
-
if (marker.type === "progress" && this.inAdBreak) {
|
|
3844
|
-
if (marker.durationSeconds != null) {
|
|
3845
|
-
this.expectedAdBreakDurationMs = marker.durationSeconds * 1e3;
|
|
3846
|
-
}
|
|
3847
|
-
if (this.expectedAdBreakDurationMs != null && this.currentAdBreakStartWallClockMs != null) {
|
|
3848
|
-
var elapsedMs1 = Date.now() - this.currentAdBreakStartWallClockMs;
|
|
3849
|
-
var remainingMs1 = Math.max(0, this.expectedAdBreakDurationMs - elapsedMs1);
|
|
3850
|
-
this.scheduleAdStopCountdown(remainingMs1);
|
|
3851
|
-
}
|
|
3852
|
-
if (!this.adLayer.isAdPlaying() && this.pendingNextAdBids != null && this.pendingNextAdBids.length > 0) {
|
|
3853
|
-
var bids = this.pendingNextAdBids;
|
|
3854
|
-
this.pendingNextAdBids = null;
|
|
3855
|
-
this.currentAdIndex++;
|
|
3856
|
-
this.adLayer.playAd(bids).catch(function() {
|
|
3857
|
-
return _this.handleAdFailure();
|
|
3858
|
-
});
|
|
3859
|
-
}
|
|
3860
|
-
return;
|
|
3861
|
-
}
|
|
3862
|
-
if (marker.type === "end") {
|
|
3863
|
-
var remaining = this.getRemainingAdMs();
|
|
3864
|
-
var adPlaying = this.adLayer.isAdPlaying();
|
|
3865
|
-
var hasQueuedAds = this.pendingNextAdBids != null && this.pendingNextAdBids.length > 0;
|
|
3866
|
-
if (this.config.debugAdTiming) {
|
|
3867
|
-
console.log("[StormcloudVideoPlayer] SCTE-35 end marker received:", {
|
|
3868
|
-
inAdBreak: this.inAdBreak,
|
|
3869
|
-
remaining: remaining,
|
|
3870
|
-
adPlaying: adPlaying,
|
|
3871
|
-
hasQueuedAds: hasQueuedAds,
|
|
3872
|
-
activeAdRequest: this.activeAdRequestToken !== null
|
|
3873
|
-
});
|
|
3874
|
-
}
|
|
3875
|
-
if (!this.inAdBreak) {
|
|
3876
|
-
if (this.config.debugAdTiming) {
|
|
3877
|
-
console.log("[StormcloudVideoPlayer] Ignoring SCTE-35 end marker - not in ad break");
|
|
3878
|
-
}
|
|
3879
|
-
return;
|
|
3880
|
-
}
|
|
3881
|
-
if (adPlaying || remaining > 500) {
|
|
3882
|
-
if (this.config.debugAdTiming) {
|
|
3883
|
-
console.log("[StormcloudVideoPlayer] Ignoring premature SCTE-35 end marker - ads still active or time remaining");
|
|
3884
|
-
}
|
|
3885
|
-
return;
|
|
3886
|
-
}
|
|
3887
|
-
this.inAdBreak = false;
|
|
3888
|
-
this.expectedAdBreakDurationMs = void 0;
|
|
3889
|
-
this.currentAdBreakStartWallClockMs = void 0;
|
|
3890
|
-
this.clearAdStartTimer();
|
|
3891
|
-
this.clearAdStopTimer();
|
|
3892
|
-
if (adPlaying) {
|
|
3893
|
-
this.adLayer.stop().catch(function() {});
|
|
3894
|
-
}
|
|
3895
|
-
this.handleAdPodComplete();
|
|
3896
|
-
return;
|
|
3897
|
-
}
|
|
3898
|
-
}
|
|
3899
|
-
},
|
|
3900
|
-
{
|
|
3901
|
-
key: "parseCueOutDuration",
|
|
3902
|
-
value: function parseCueOutDuration(value) {
|
|
3903
|
-
var num = parseFloat(value.trim());
|
|
3904
|
-
if (!Number.isNaN(num)) return num;
|
|
3905
|
-
var match = value.match(/(?:^|[,\s])DURATION\s*=\s*([0-9.]+)/i) || value.match(/Duration\s*=\s*([0-9.]+)/i);
|
|
3906
|
-
if (match && match[1] != null) {
|
|
3907
|
-
var dStr = match[1];
|
|
3908
|
-
var d = parseFloat(dStr);
|
|
3909
|
-
return Number.isNaN(d) ? void 0 : d;
|
|
3910
|
-
}
|
|
3911
|
-
return void 0;
|
|
3912
|
-
}
|
|
3913
|
-
},
|
|
3914
|
-
{
|
|
3915
|
-
key: "parseCueOutCont",
|
|
3916
|
-
value: function parseCueOutCont(value) {
|
|
3917
|
-
var res = {};
|
|
3918
|
-
var elapsedMatch = value.match(/Elapsed\s*=\s*([0-9.]+)/i);
|
|
3919
|
-
var durationMatch = value.match(/Duration\s*=\s*([0-9.]+)/i);
|
|
3920
|
-
if (elapsedMatch && elapsedMatch[1] != null) {
|
|
3921
|
-
var e = parseFloat(elapsedMatch[1]);
|
|
3922
|
-
if (!Number.isNaN(e)) res.elapsed = e;
|
|
3923
|
-
}
|
|
3924
|
-
if (durationMatch && durationMatch[1] != null) {
|
|
3925
|
-
var d = parseFloat(durationMatch[1]);
|
|
3926
|
-
if (!Number.isNaN(d)) res.duration = d;
|
|
3927
|
-
}
|
|
3928
|
-
if (!("elapsed" in res) || !("duration" in res)) {
|
|
3929
|
-
var slashMatch = value.match(/([0-9.]+)\s*\/\s*([0-9.]+)/);
|
|
3930
|
-
if (slashMatch && slashMatch[1] && slashMatch[2]) {
|
|
3931
|
-
var elapsed = parseFloat(slashMatch[1]);
|
|
3932
|
-
var duration = parseFloat(slashMatch[2]);
|
|
3933
|
-
if (!Number.isNaN(elapsed) && !("elapsed" in res)) res.elapsed = elapsed;
|
|
3934
|
-
if (!Number.isNaN(duration) && !("duration" in res)) res.duration = duration;
|
|
3935
|
-
}
|
|
3936
|
-
}
|
|
3937
|
-
if ("elapsed" in res || "duration" in res) return res;
|
|
3938
|
-
return void 0;
|
|
3939
|
-
}
|
|
3940
|
-
},
|
|
3941
|
-
{
|
|
3942
|
-
key: "parseAttributeList",
|
|
3943
|
-
value: function parseAttributeList(value) {
|
|
3944
|
-
var attrs = {};
|
|
3945
|
-
var regex = /([A-Z0-9-]+)=(("[^"]*")|([^",]*))(?:,|$)/gi;
|
|
3946
|
-
var match;
|
|
3947
|
-
while((match = regex.exec(value)) !== null){
|
|
3948
|
-
var _match_, _ref, _match_1;
|
|
3949
|
-
var key = (_match_ = match[1]) !== null && _match_ !== void 0 ? _match_ : "";
|
|
3950
|
-
var rawVal = (_ref = (_match_1 = match[3]) !== null && _match_1 !== void 0 ? _match_1 : match[4]) !== null && _ref !== void 0 ? _ref : "";
|
|
3951
|
-
if (rawVal.startsWith('"') && rawVal.endsWith('"')) {
|
|
3952
|
-
rawVal = rawVal.slice(1, -1);
|
|
3953
|
-
}
|
|
3954
|
-
if (key) {
|
|
3955
|
-
attrs[key] = rawVal;
|
|
3956
|
-
}
|
|
3957
|
-
}
|
|
3958
|
-
return attrs;
|
|
3959
|
-
}
|
|
3960
|
-
},
|
|
3961
|
-
{
|
|
3962
|
-
key: "toNumber",
|
|
3963
|
-
value: function toNumber(val) {
|
|
3964
|
-
if (val == null) return void 0;
|
|
3965
|
-
var n = typeof val === "string" ? parseFloat(val) : Number(val);
|
|
3966
|
-
return Number.isNaN(n) ? void 0 : n;
|
|
3967
|
-
}
|
|
3968
|
-
},
|
|
3969
|
-
{
|
|
3970
|
-
key: "isManifestBasedMarker",
|
|
3971
|
-
value: function isManifestBasedMarker(marker) {
|
|
3972
|
-
var raw = marker.raw;
|
|
3973
|
-
if (!raw) return false;
|
|
3974
|
-
if (raw.tag) {
|
|
3975
|
-
var tag = String(raw.tag);
|
|
3976
|
-
return tag.includes("EXT-X-CUE-OUT") || tag.includes("EXT-X-CUE-IN") || tag.includes("EXT-X-DATERANGE");
|
|
3977
|
-
}
|
|
3978
|
-
if (raw.id3) return false;
|
|
3979
|
-
if (raw.splice_command_type) return false;
|
|
3980
|
-
return false;
|
|
3981
|
-
}
|
|
3982
|
-
},
|
|
3983
|
-
{
|
|
3984
|
-
key: "parseScte35Binary",
|
|
3985
|
-
value: function parseScte35Binary(data) {
|
|
3986
|
-
var BitReader = /*#__PURE__*/ function() {
|
|
3987
|
-
function BitReader(buf) {
|
|
3988
|
-
_class_call_check(this, BitReader);
|
|
3989
|
-
this.buf = buf;
|
|
3990
|
-
this.bytePos = 0;
|
|
3991
|
-
this.bitPos = 0;
|
|
3992
|
-
}
|
|
3993
|
-
_create_class(BitReader, [
|
|
3994
|
-
{
|
|
3995
|
-
key: "readBits",
|
|
3996
|
-
value: function readBits(numBits) {
|
|
3997
|
-
var result = 0;
|
|
3998
|
-
while(numBits > 0){
|
|
3999
|
-
if (this.bytePos >= this.buf.length) return result;
|
|
4000
|
-
var remainingInByte = 8 - this.bitPos;
|
|
4001
|
-
var toRead = Math.min(numBits, remainingInByte);
|
|
4002
|
-
var currentByte = this.buf[this.bytePos];
|
|
4003
|
-
var shift = remainingInByte - toRead;
|
|
4004
|
-
var mask = (1 << toRead) - 1 & 255;
|
|
4005
|
-
var bits = currentByte >> shift & mask;
|
|
4006
|
-
result = result << toRead | bits;
|
|
4007
|
-
this.bitPos += toRead;
|
|
4008
|
-
if (this.bitPos >= 8) {
|
|
4009
|
-
this.bitPos = 0;
|
|
4010
|
-
this.bytePos += 1;
|
|
4011
|
-
}
|
|
4012
|
-
numBits -= toRead;
|
|
4013
|
-
}
|
|
4014
|
-
return result >>> 0;
|
|
4015
|
-
}
|
|
4016
|
-
},
|
|
4017
|
-
{
|
|
4018
|
-
key: "skipBits",
|
|
4019
|
-
value: function skipBits(n) {
|
|
4020
|
-
this.readBits(n);
|
|
4021
|
-
}
|
|
4022
|
-
}
|
|
4023
|
-
]);
|
|
4024
|
-
return BitReader;
|
|
4025
|
-
}();
|
|
4026
|
-
var r = new BitReader(data);
|
|
4027
|
-
var tableId = r.readBits(8);
|
|
4028
|
-
if (tableId !== 252) return void 0;
|
|
4029
|
-
r.readBits(1);
|
|
4030
|
-
r.readBits(1);
|
|
4031
|
-
r.readBits(2);
|
|
4032
|
-
var sectionLength = r.readBits(12);
|
|
4033
|
-
r.readBits(8);
|
|
4034
|
-
r.readBits(1);
|
|
4035
|
-
r.readBits(6);
|
|
4036
|
-
var ptsAdjHigh = r.readBits(1);
|
|
4037
|
-
var ptsAdjLow = r.readBits(32);
|
|
4038
|
-
void ptsAdjHigh;
|
|
4039
|
-
void ptsAdjLow;
|
|
4040
|
-
r.readBits(8);
|
|
4041
|
-
r.readBits(12);
|
|
4042
|
-
var spliceCommandLength = r.readBits(12);
|
|
4043
|
-
var spliceCommandType = r.readBits(8);
|
|
4044
|
-
if (spliceCommandType !== 5) {
|
|
4045
|
-
return void 0;
|
|
4046
|
-
}
|
|
4047
|
-
r.readBits(32);
|
|
4048
|
-
var cancel = r.readBits(1) === 1;
|
|
4049
|
-
r.readBits(7);
|
|
4050
|
-
if (cancel) return void 0;
|
|
4051
|
-
var outOfNetwork = r.readBits(1) === 1;
|
|
4052
|
-
var programSpliceFlag = r.readBits(1) === 1;
|
|
4053
|
-
var durationFlag = r.readBits(1) === 1;
|
|
4054
|
-
var spliceImmediateFlag = r.readBits(1) === 1;
|
|
4055
|
-
r.readBits(4);
|
|
4056
|
-
if (programSpliceFlag && !spliceImmediateFlag) {
|
|
4057
|
-
var timeSpecifiedFlag = r.readBits(1) === 1;
|
|
4058
|
-
if (timeSpecifiedFlag) {
|
|
4059
|
-
r.readBits(6);
|
|
4060
|
-
r.readBits(33);
|
|
4061
|
-
} else {
|
|
4062
|
-
r.readBits(7);
|
|
4063
|
-
}
|
|
4064
|
-
} else if (!programSpliceFlag) {
|
|
4065
|
-
var componentCount = r.readBits(8);
|
|
4066
|
-
for(var i = 0; i < componentCount; i++){
|
|
4067
|
-
r.readBits(8);
|
|
4068
|
-
if (!spliceImmediateFlag) {
|
|
4069
|
-
var timeSpecifiedFlag1 = r.readBits(1) === 1;
|
|
4070
|
-
if (timeSpecifiedFlag1) {
|
|
4071
|
-
r.readBits(6);
|
|
4072
|
-
r.readBits(33);
|
|
4073
|
-
} else {
|
|
4074
|
-
r.readBits(7);
|
|
4075
|
-
}
|
|
4076
|
-
}
|
|
4077
|
-
}
|
|
4078
|
-
}
|
|
4079
|
-
var durationSeconds = void 0;
|
|
4080
|
-
if (durationFlag) {
|
|
4081
|
-
r.readBits(6);
|
|
4082
|
-
r.readBits(1);
|
|
4083
|
-
var high = r.readBits(1);
|
|
4084
|
-
var low = r.readBits(32);
|
|
4085
|
-
var durationTicks = high * 4294967296 + low;
|
|
4086
|
-
durationSeconds = durationTicks / 9e4;
|
|
4087
|
-
}
|
|
4088
|
-
r.readBits(16);
|
|
4089
|
-
r.readBits(8);
|
|
4090
|
-
r.readBits(8);
|
|
4091
|
-
if (outOfNetwork) {
|
|
4092
|
-
var marker = _object_spread_props(_object_spread({
|
|
4093
|
-
type: "start"
|
|
4094
|
-
}, durationSeconds !== void 0 ? {
|
|
4095
|
-
durationSeconds: durationSeconds
|
|
4096
|
-
} : {}), {
|
|
4097
|
-
raw: {
|
|
4098
|
-
splice_command_type: 5
|
|
4099
|
-
}
|
|
4100
|
-
});
|
|
4101
|
-
return marker;
|
|
4102
|
-
}
|
|
4103
|
-
return void 0;
|
|
4104
|
-
}
|
|
4105
|
-
},
|
|
4106
3405
|
{
|
|
4107
3406
|
key: "initializeTracking",
|
|
4108
3407
|
value: function initializeTracking() {
|
|
@@ -4224,35 +3523,35 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4224
3523
|
},
|
|
4225
3524
|
{
|
|
4226
3525
|
key: "startAdPrefetch",
|
|
4227
|
-
value: function startAdPrefetch(
|
|
3526
|
+
value: function startAdPrefetch(durationSeconds, fragmentSn) {
|
|
4228
3527
|
if (this.config.disableAds) return;
|
|
4229
3528
|
if (this.pendingAdBreak || this.inAdBreak) {
|
|
4230
3529
|
return;
|
|
4231
3530
|
}
|
|
4232
|
-
this.pendingAdBreak = _object_spread_props(_object_spread({
|
|
4233
|
-
|
|
4234
|
-
}, fragmentSn !== void 0 ? {
|
|
3531
|
+
this.pendingAdBreak = _object_spread_props(_object_spread({}, durationSeconds !== void 0 ? {
|
|
3532
|
+
durationSeconds: durationSeconds
|
|
3533
|
+
} : {}, fragmentSn !== void 0 ? {
|
|
4235
3534
|
detectedAtFragmentSn: fragmentSn
|
|
4236
3535
|
} : {}), {
|
|
4237
3536
|
isFetching: false,
|
|
4238
3537
|
fetchStartTime: Date.now()
|
|
4239
3538
|
});
|
|
4240
|
-
void this.runAdPrefetch(
|
|
3539
|
+
void this.runAdPrefetch(durationSeconds);
|
|
4241
3540
|
if (this.config.debugAdTiming) {
|
|
4242
|
-
console.log("[PREFETCH] Ad break
|
|
3541
|
+
console.log("[PREFETCH] Ad break registered, multi-ad prefetch started");
|
|
4243
3542
|
}
|
|
4244
3543
|
}
|
|
4245
3544
|
},
|
|
4246
3545
|
{
|
|
4247
3546
|
key: "runAdPrefetch",
|
|
4248
|
-
value: function runAdPrefetch(
|
|
3547
|
+
value: function runAdPrefetch(durationSeconds) {
|
|
4249
3548
|
return _async_to_generator(function() {
|
|
4250
|
-
var _this,
|
|
3549
|
+
var _this, _ref, _firstBids_, durSec, context, firstBids, unused, adDurationSec, estimatedCount, firstToken, unused1, remaining, results, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, result, token, unused2, err;
|
|
4251
3550
|
return _ts_generator(this, function(_state) {
|
|
4252
3551
|
switch(_state.label){
|
|
4253
3552
|
case 0:
|
|
4254
3553
|
_this = this;
|
|
4255
|
-
durSec =
|
|
3554
|
+
durSec = durationSeconds !== null && durationSeconds !== void 0 ? durationSeconds : 60;
|
|
4256
3555
|
context = {
|
|
4257
3556
|
breakDurationSec: durSec,
|
|
4258
3557
|
remainingBreakSec: durSec
|
|
@@ -4302,14 +3601,43 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4302
3601
|
console.log("[PREFETCH] Ad duration=".concat(adDurationSec, "s, break=").concat(durSec, "s → ").concat(estimatedCount, " ad(s) needed"));
|
|
4303
3602
|
}
|
|
4304
3603
|
firstToken = "preload_".concat(Date.now(), "_").concat(Math.random().toString(36).slice(2, 7));
|
|
4305
|
-
|
|
4306
|
-
|
|
3604
|
+
_state.label = 5;
|
|
3605
|
+
case 5:
|
|
3606
|
+
_state.trys.push([
|
|
3607
|
+
5,
|
|
3608
|
+
7,
|
|
3609
|
+
,
|
|
3610
|
+
8
|
|
3611
|
+
]);
|
|
3612
|
+
return [
|
|
3613
|
+
4,
|
|
3614
|
+
this.adLayer.preloadAd(firstBids, firstToken)
|
|
3615
|
+
];
|
|
3616
|
+
case 6:
|
|
3617
|
+
_state.sent();
|
|
3618
|
+
if (!this.inAdBreak) {
|
|
3619
|
+
this.preloadedTokens.push(firstToken);
|
|
3620
|
+
if (this.config.debugAdTiming) {
|
|
3621
|
+
console.log("[PREFETCH] First ad preloaded and queued, token=".concat(firstToken));
|
|
3622
|
+
}
|
|
3623
|
+
}
|
|
3624
|
+
return [
|
|
3625
|
+
3,
|
|
3626
|
+
8
|
|
3627
|
+
];
|
|
3628
|
+
case 7:
|
|
3629
|
+
unused1 = _state.sent();
|
|
4307
3630
|
if (this.config.debugAdTiming) {
|
|
4308
|
-
console.
|
|
3631
|
+
console.warn("[PREFETCH] First ad preload failed, token=".concat(firstToken));
|
|
4309
3632
|
}
|
|
3633
|
+
return [
|
|
3634
|
+
3,
|
|
3635
|
+
8
|
|
3636
|
+
];
|
|
3637
|
+
case 8:
|
|
4310
3638
|
if (!(estimatedCount > 1)) return [
|
|
4311
3639
|
3,
|
|
4312
|
-
|
|
3640
|
+
19
|
|
4313
3641
|
];
|
|
4314
3642
|
remaining = Array.from({
|
|
4315
3643
|
length: estimatedCount - 1
|
|
@@ -4331,38 +3659,100 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4331
3659
|
4,
|
|
4332
3660
|
Promise.all(remaining)
|
|
4333
3661
|
];
|
|
4334
|
-
case
|
|
3662
|
+
case 9:
|
|
4335
3663
|
results = _state.sent();
|
|
4336
3664
|
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
3665
|
+
_state.label = 10;
|
|
3666
|
+
case 10:
|
|
3667
|
+
_state.trys.push([
|
|
3668
|
+
10,
|
|
3669
|
+
17,
|
|
3670
|
+
18,
|
|
3671
|
+
19
|
|
3672
|
+
]);
|
|
3673
|
+
_iterator = results[Symbol.iterator]();
|
|
3674
|
+
_state.label = 11;
|
|
3675
|
+
case 11:
|
|
3676
|
+
if (!!(_iteratorNormalCompletion = (_step = _iterator.next()).done)) return [
|
|
3677
|
+
3,
|
|
3678
|
+
16
|
|
3679
|
+
];
|
|
3680
|
+
result = _step.value;
|
|
3681
|
+
if (this.inAdBreak) return [
|
|
3682
|
+
3,
|
|
3683
|
+
16
|
|
3684
|
+
];
|
|
3685
|
+
if (!(result.ok && result.value.length > 0)) return [
|
|
3686
|
+
3,
|
|
3687
|
+
15
|
|
3688
|
+
];
|
|
3689
|
+
token = "preload_".concat(Date.now(), "_").concat(Math.random().toString(36).slice(2, 7));
|
|
3690
|
+
_state.label = 12;
|
|
3691
|
+
case 12:
|
|
3692
|
+
_state.trys.push([
|
|
3693
|
+
12,
|
|
3694
|
+
14,
|
|
3695
|
+
,
|
|
3696
|
+
15
|
|
3697
|
+
]);
|
|
3698
|
+
return [
|
|
3699
|
+
4,
|
|
3700
|
+
this.adLayer.preloadAd(result.value, token)
|
|
3701
|
+
];
|
|
3702
|
+
case 13:
|
|
3703
|
+
_state.sent();
|
|
3704
|
+
if (!this.inAdBreak) {
|
|
3705
|
+
this.preloadedTokens.push(token);
|
|
3706
|
+
if (this.config.debugAdTiming) {
|
|
3707
|
+
console.log("[PREFETCH] Additional ad preloaded and queued, token=".concat(token));
|
|
3708
|
+
}
|
|
3709
|
+
}
|
|
3710
|
+
return [
|
|
3711
|
+
3,
|
|
3712
|
+
15
|
|
3713
|
+
];
|
|
3714
|
+
case 14:
|
|
3715
|
+
unused2 = _state.sent();
|
|
3716
|
+
if (this.config.debugAdTiming) {
|
|
3717
|
+
console.warn("[PREFETCH] Additional ad preload failed, token=".concat(token));
|
|
3718
|
+
}
|
|
3719
|
+
return [
|
|
3720
|
+
3,
|
|
3721
|
+
15
|
|
3722
|
+
];
|
|
3723
|
+
case 15:
|
|
3724
|
+
_iteratorNormalCompletion = true;
|
|
3725
|
+
return [
|
|
3726
|
+
3,
|
|
3727
|
+
11
|
|
3728
|
+
];
|
|
3729
|
+
case 16:
|
|
3730
|
+
return [
|
|
3731
|
+
3,
|
|
3732
|
+
19
|
|
3733
|
+
];
|
|
3734
|
+
case 17:
|
|
3735
|
+
err = _state.sent();
|
|
3736
|
+
_didIteratorError = true;
|
|
3737
|
+
_iteratorError = err;
|
|
3738
|
+
return [
|
|
3739
|
+
3,
|
|
3740
|
+
19
|
|
3741
|
+
];
|
|
3742
|
+
case 18:
|
|
4337
3743
|
try {
|
|
4338
|
-
|
|
4339
|
-
|
|
4340
|
-
if (this.inAdBreak) break;
|
|
4341
|
-
if (result.ok && result.value.length > 0) {
|
|
4342
|
-
token = "preload_".concat(Date.now(), "_").concat(Math.random().toString(36).slice(2, 7));
|
|
4343
|
-
this.preloadedTokens.push(token);
|
|
4344
|
-
void this.adLayer.preloadAd(result.value, token);
|
|
4345
|
-
if (this.config.debugAdTiming) {
|
|
4346
|
-
console.log("[PREFETCH] Additional ad preloading, token=".concat(token));
|
|
4347
|
-
}
|
|
4348
|
-
}
|
|
3744
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
3745
|
+
_iterator.return();
|
|
4349
3746
|
}
|
|
4350
|
-
} catch (err) {
|
|
4351
|
-
_didIteratorError = true;
|
|
4352
|
-
_iteratorError = err;
|
|
4353
3747
|
} finally{
|
|
4354
|
-
|
|
4355
|
-
|
|
4356
|
-
_iterator.return();
|
|
4357
|
-
}
|
|
4358
|
-
} finally{
|
|
4359
|
-
if (_didIteratorError) {
|
|
4360
|
-
throw _iteratorError;
|
|
4361
|
-
}
|
|
3748
|
+
if (_didIteratorError) {
|
|
3749
|
+
throw _iteratorError;
|
|
4362
3750
|
}
|
|
4363
3751
|
}
|
|
4364
|
-
|
|
4365
|
-
|
|
3752
|
+
return [
|
|
3753
|
+
7
|
|
3754
|
+
];
|
|
3755
|
+
case 19:
|
|
4366
3756
|
if (this.config.debugAdTiming) {
|
|
4367
3757
|
console.log("[PREFETCH] Pre-fetch complete: ".concat(this.preloadedTokens.length, " ad(s) queued"));
|
|
4368
3758
|
}
|
|
@@ -4410,6 +3800,177 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4410
3800
|
this.preloadedTokens = [];
|
|
4411
3801
|
}
|
|
4412
3802
|
},
|
|
3803
|
+
{
|
|
3804
|
+
key: "startAdInsertionPolling",
|
|
3805
|
+
value: function startAdInsertionPolling() {
|
|
3806
|
+
var _this = this;
|
|
3807
|
+
if (this.adInsertionPollingId != null) return;
|
|
3808
|
+
this.fetchAdInsertionPoint();
|
|
3809
|
+
this.adInsertionPollingId = window.setInterval(function() {
|
|
3810
|
+
_this.fetchAdInsertionPoint();
|
|
3811
|
+
}, 1e3);
|
|
3812
|
+
}
|
|
3813
|
+
},
|
|
3814
|
+
{
|
|
3815
|
+
key: "stopAdInsertionPolling",
|
|
3816
|
+
value: function stopAdInsertionPolling() {
|
|
3817
|
+
if (this.adInsertionPollingId != null) {
|
|
3818
|
+
clearInterval(this.adInsertionPollingId);
|
|
3819
|
+
this.adInsertionPollingId = void 0;
|
|
3820
|
+
}
|
|
3821
|
+
}
|
|
3822
|
+
},
|
|
3823
|
+
{
|
|
3824
|
+
key: "fetchAdInsertionPoint",
|
|
3825
|
+
value: function fetchAdInsertionPoint() {
|
|
3826
|
+
return _async_to_generator(function() {
|
|
3827
|
+
var _this_lastAdInsertionPoint, resp, data, isNew, unused;
|
|
3828
|
+
return _ts_generator(this, function(_state) {
|
|
3829
|
+
switch(_state.label){
|
|
3830
|
+
case 0:
|
|
3831
|
+
if (!this.config.projectId) return [
|
|
3832
|
+
2
|
|
3833
|
+
];
|
|
3834
|
+
_state.label = 1;
|
|
3835
|
+
case 1:
|
|
3836
|
+
_state.trys.push([
|
|
3837
|
+
1,
|
|
3838
|
+
4,
|
|
3839
|
+
,
|
|
3840
|
+
5
|
|
3841
|
+
]);
|
|
3842
|
+
return [
|
|
3843
|
+
4,
|
|
3844
|
+
fetch("https://adstorm.co/api-adstorm-dev/adstorm/swirl/projects/".concat(encodeURIComponent(this.config.projectId), "/ad-insertion-point"))
|
|
3845
|
+
];
|
|
3846
|
+
case 2:
|
|
3847
|
+
resp = _state.sent();
|
|
3848
|
+
if (!resp.ok) return [
|
|
3849
|
+
2
|
|
3850
|
+
];
|
|
3851
|
+
return [
|
|
3852
|
+
4,
|
|
3853
|
+
resp.json()
|
|
3854
|
+
];
|
|
3855
|
+
case 3:
|
|
3856
|
+
data = _state.sent();
|
|
3857
|
+
isNew = data.updated_at !== ((_this_lastAdInsertionPoint = this.lastAdInsertionPoint) === null || _this_lastAdInsertionPoint === void 0 ? void 0 : _this_lastAdInsertionPoint.updated_at);
|
|
3858
|
+
this.lastAdInsertionPoint = data;
|
|
3859
|
+
if (isNew) {
|
|
3860
|
+
this.pushAdInsertionDebug("api_response", data.segment_ts_name, {
|
|
3861
|
+
offsetSeconds: data.offset_seconds,
|
|
3862
|
+
updatedAt: data.updated_at,
|
|
3863
|
+
detail: "project=".concat(data.project_id)
|
|
3864
|
+
});
|
|
3865
|
+
}
|
|
3866
|
+
if (this.config.debugAdTiming) {
|
|
3867
|
+
console.log("[StormcloudVideoPlayer] Ad insertion point API response:", data);
|
|
3868
|
+
}
|
|
3869
|
+
return [
|
|
3870
|
+
3,
|
|
3871
|
+
5
|
|
3872
|
+
];
|
|
3873
|
+
case 4:
|
|
3874
|
+
unused = _state.sent();
|
|
3875
|
+
if (this.config.debugAdTiming) {
|
|
3876
|
+
console.warn("[StormcloudVideoPlayer] Ad insertion point API fetch failed");
|
|
3877
|
+
}
|
|
3878
|
+
return [
|
|
3879
|
+
3,
|
|
3880
|
+
5
|
|
3881
|
+
];
|
|
3882
|
+
case 5:
|
|
3883
|
+
return [
|
|
3884
|
+
2
|
|
3885
|
+
];
|
|
3886
|
+
}
|
|
3887
|
+
});
|
|
3888
|
+
}).call(this);
|
|
3889
|
+
}
|
|
3890
|
+
},
|
|
3891
|
+
{
|
|
3892
|
+
key: "checkAdInsertionInManifest",
|
|
3893
|
+
value: function checkAdInsertionInManifest() {
|
|
3894
|
+
var _this_hls;
|
|
3895
|
+
if (!this.lastAdInsertionPoint) return;
|
|
3896
|
+
if (this.inAdBreak || this.pendingAdBreak) return;
|
|
3897
|
+
if (this.lastAdInsertionPoint.updated_at === this.processedAdInsertionUpdatedAt) return;
|
|
3898
|
+
var segmentName = this.lastAdInsertionPoint.segment_ts_name;
|
|
3899
|
+
var levels = (_this_hls = this.hls) === null || _this_hls === void 0 ? void 0 : _this_hls.levels;
|
|
3900
|
+
if (!levels) return;
|
|
3901
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
3902
|
+
try {
|
|
3903
|
+
for(var _iterator = levels[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
3904
|
+
var level = _step.value;
|
|
3905
|
+
var _level_details;
|
|
3906
|
+
var fragments = (_level_details = level.details) === null || _level_details === void 0 ? void 0 : _level_details.fragments;
|
|
3907
|
+
if (!Array.isArray(fragments)) continue;
|
|
3908
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
3909
|
+
try {
|
|
3910
|
+
for(var _iterator1 = fragments[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
3911
|
+
var frag = _step1.value;
|
|
3912
|
+
if (this.fragmentMatchesSegment(frag, segmentName)) {
|
|
3913
|
+
var _ref;
|
|
3914
|
+
this.pushAdInsertionDebug("segment_found", segmentName, {
|
|
3915
|
+
detail: "sn=".concat((_ref = frag === null || frag === void 0 ? void 0 : frag.sn) !== null && _ref !== void 0 ? _ref : "?")
|
|
3916
|
+
});
|
|
3917
|
+
if (this.config.debugAdTiming) {
|
|
3918
|
+
console.log('[StormcloudVideoPlayer] Ad insertion segment "'.concat(segmentName, '" found in manifest — starting pre-fetch'));
|
|
3919
|
+
}
|
|
3920
|
+
this.startAdPrefetch(60, frag === null || frag === void 0 ? void 0 : frag.sn);
|
|
3921
|
+
return;
|
|
3922
|
+
}
|
|
3923
|
+
}
|
|
3924
|
+
} catch (err) {
|
|
3925
|
+
_didIteratorError1 = true;
|
|
3926
|
+
_iteratorError1 = err;
|
|
3927
|
+
} finally{
|
|
3928
|
+
try {
|
|
3929
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
3930
|
+
_iterator1.return();
|
|
3931
|
+
}
|
|
3932
|
+
} finally{
|
|
3933
|
+
if (_didIteratorError1) {
|
|
3934
|
+
throw _iteratorError1;
|
|
3935
|
+
}
|
|
3936
|
+
}
|
|
3937
|
+
}
|
|
3938
|
+
}
|
|
3939
|
+
} catch (err) {
|
|
3940
|
+
_didIteratorError = true;
|
|
3941
|
+
_iteratorError = err;
|
|
3942
|
+
} finally{
|
|
3943
|
+
try {
|
|
3944
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
3945
|
+
_iterator.return();
|
|
3946
|
+
}
|
|
3947
|
+
} finally{
|
|
3948
|
+
if (_didIteratorError) {
|
|
3949
|
+
throw _iteratorError;
|
|
3950
|
+
}
|
|
3951
|
+
}
|
|
3952
|
+
}
|
|
3953
|
+
}
|
|
3954
|
+
},
|
|
3955
|
+
{
|
|
3956
|
+
key: "fragmentMatchesSegment",
|
|
3957
|
+
value: function fragmentMatchesSegment(frag, segmentName) {
|
|
3958
|
+
var _rawUrl_split_;
|
|
3959
|
+
var rawUrl = (frag === null || frag === void 0 ? void 0 : frag.url) || (frag === null || frag === void 0 ? void 0 : frag.relurl) || "";
|
|
3960
|
+
var url = (_rawUrl_split_ = rawUrl.split("?")[0]) !== null && _rawUrl_split_ !== void 0 ? _rawUrl_split_ : "";
|
|
3961
|
+
var name = segmentName.startsWith("/") ? segmentName : "/" + segmentName;
|
|
3962
|
+
return url.endsWith(name) || url.includes(name);
|
|
3963
|
+
}
|
|
3964
|
+
},
|
|
3965
|
+
{
|
|
3966
|
+
key: "clearAdInsertionOffsetTimer",
|
|
3967
|
+
value: function clearAdInsertionOffsetTimer() {
|
|
3968
|
+
if (this.adInsertionOffsetTimerId != null) {
|
|
3969
|
+
clearTimeout(this.adInsertionOffsetTimerId);
|
|
3970
|
+
this.adInsertionOffsetTimerId = void 0;
|
|
3971
|
+
}
|
|
3972
|
+
}
|
|
3973
|
+
},
|
|
4413
3974
|
{
|
|
4414
3975
|
key: "startContinuousFetchLoop",
|
|
4415
3976
|
value: function startContinuousFetchLoop() {
|
|
@@ -4735,13 +4296,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4735
4296
|
},
|
|
4736
4297
|
{
|
|
4737
4298
|
key: "handleAdStart",
|
|
4738
|
-
value: function handleAdStart(
|
|
4299
|
+
value: function handleAdStart(durationSeconds) {
|
|
4739
4300
|
return _async_to_generator(function() {
|
|
4740
|
-
var
|
|
4301
|
+
var _this_savedMutedStateBeforeAd, adBreakDurationMs, mode, state, adBreakToken, adVolume, token, remaining, err;
|
|
4741
4302
|
return _ts_generator(this, function(_state) {
|
|
4742
4303
|
switch(_state.label){
|
|
4743
4304
|
case 0:
|
|
4744
|
-
adBreakDurationMs =
|
|
4305
|
+
adBreakDurationMs = durationSeconds != null ? durationSeconds * 1e3 : void 0;
|
|
4745
4306
|
if (this.config.debugAdTiming) {
|
|
4746
4307
|
mode = this.isLiveStream ? "LIVE" : "VOD";
|
|
4747
4308
|
console.log("[CONTINUOUS-FETCH] \uD83D\uDCFA ".concat(mode, " MODE: Target duration=").concat(adBreakDurationMs, "ms"));
|
|
@@ -4752,13 +4313,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4752
4313
|
this.pendingNextAdBids = null;
|
|
4753
4314
|
this.isShowingPlaceholder = false;
|
|
4754
4315
|
this.totalAdRequestsInBreak = 0;
|
|
4755
|
-
if (this.
|
|
4756
|
-
this.
|
|
4316
|
+
if (this.savedMutedStateBeforeAd == null && !this.video.muted) {
|
|
4317
|
+
this.savedMutedStateBeforeAd = {
|
|
4757
4318
|
muted: false,
|
|
4758
4319
|
volume: this.video.volume
|
|
4759
4320
|
};
|
|
4760
4321
|
}
|
|
4761
|
-
state = (
|
|
4322
|
+
state = (_this_savedMutedStateBeforeAd = this.savedMutedStateBeforeAd) !== null && _this_savedMutedStateBeforeAd !== void 0 ? _this_savedMutedStateBeforeAd : {
|
|
4762
4323
|
muted: this.video.muted,
|
|
4763
4324
|
volume: this.video.volume
|
|
4764
4325
|
};
|
|
@@ -4785,6 +4346,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4785
4346
|
if (this.expectedAdBreakDurationMs == null && adBreakDurationMs != null) {
|
|
4786
4347
|
this.expectedAdBreakDurationMs = adBreakDurationMs;
|
|
4787
4348
|
}
|
|
4349
|
+
if (this.expectedAdBreakDurationMs != null) {
|
|
4350
|
+
this.scheduleAdStopCountdown(this.expectedAdBreakDurationMs);
|
|
4351
|
+
}
|
|
4788
4352
|
this.clearPendingAdBreak();
|
|
4789
4353
|
adBreakToken = Date.now();
|
|
4790
4354
|
this.activeAdRequestToken = adBreakToken;
|
|
@@ -5283,54 +4847,18 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5283
4847
|
this.handleAdPodComplete();
|
|
5284
4848
|
}
|
|
5285
4849
|
},
|
|
5286
|
-
{
|
|
5287
|
-
key: "scheduleAdStartIn",
|
|
5288
|
-
value: function scheduleAdStartIn(delayMs) {
|
|
5289
|
-
var _this = this;
|
|
5290
|
-
this.clearAdStartTimer();
|
|
5291
|
-
var ms = Math.max(0, Math.floor(delayMs));
|
|
5292
|
-
if (ms === 0) {
|
|
5293
|
-
this.handleAdStart({
|
|
5294
|
-
type: "start"
|
|
5295
|
-
}).catch(function() {});
|
|
5296
|
-
return;
|
|
5297
|
-
}
|
|
5298
|
-
this.adStartTimerId = window.setTimeout(function() {
|
|
5299
|
-
_this.handleAdStart({
|
|
5300
|
-
type: "start"
|
|
5301
|
-
}).catch(function() {});
|
|
5302
|
-
}, ms);
|
|
5303
|
-
}
|
|
5304
|
-
},
|
|
5305
|
-
{
|
|
5306
|
-
key: "clearAdStartTimer",
|
|
5307
|
-
value: function clearAdStartTimer() {
|
|
5308
|
-
if (this.adStartTimerId != null) {
|
|
5309
|
-
clearTimeout(this.adStartTimerId);
|
|
5310
|
-
this.adStartTimerId = void 0;
|
|
5311
|
-
}
|
|
5312
|
-
}
|
|
5313
|
-
},
|
|
5314
|
-
{
|
|
5315
|
-
key: "updatePtsDrift",
|
|
5316
|
-
value: function updatePtsDrift(ptsSecondsSample) {
|
|
5317
|
-
var sampleMs = (this.video.currentTime - ptsSecondsSample) * 1e3;
|
|
5318
|
-
if (!Number.isFinite(sampleMs) || Math.abs(sampleMs) > 6e4) return;
|
|
5319
|
-
var alpha = 0.1;
|
|
5320
|
-
this.ptsDriftEmaMs = this.ptsDriftEmaMs * (1 - alpha) + sampleMs * alpha;
|
|
5321
|
-
}
|
|
5322
|
-
},
|
|
5323
4850
|
{
|
|
5324
4851
|
key: "handleAdPodComplete",
|
|
5325
4852
|
value: function handleAdPodComplete() {
|
|
5326
4853
|
var _this = this;
|
|
5327
4854
|
var _ref, _ref1;
|
|
5328
|
-
var
|
|
4855
|
+
var _this_savedMutedStateBeforeAd, _this_savedMutedStateBeforeAd1;
|
|
5329
4856
|
if (this.config.debugAdTiming) {
|
|
5330
4857
|
console.log("[StormcloudVideoPlayer] \uD83C\uDFC1 Ad pod complete - cleaning up");
|
|
5331
4858
|
}
|
|
5332
4859
|
this.clearAdRequestWatchdog();
|
|
5333
4860
|
this.clearAdFailsafeTimer();
|
|
4861
|
+
this.clearAdInsertionOffsetTimer();
|
|
5334
4862
|
this.activeAdRequestToken = null;
|
|
5335
4863
|
this.isInAdTransition = false;
|
|
5336
4864
|
this.stopContinuousFetching();
|
|
@@ -5346,7 +4874,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5346
4874
|
this.inAdBreak = false;
|
|
5347
4875
|
this.expectedAdBreakDurationMs = void 0;
|
|
5348
4876
|
this.currentAdBreakStartWallClockMs = void 0;
|
|
5349
|
-
this.clearAdStartTimer();
|
|
5350
4877
|
this.clearAdStopTimer();
|
|
5351
4878
|
this.adPodQueue = [];
|
|
5352
4879
|
this.showAds = false;
|
|
@@ -5354,8 +4881,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5354
4881
|
this.totalAdsInBreak = 0;
|
|
5355
4882
|
this.totalAdRequestsInBreak = 0;
|
|
5356
4883
|
this.consecutiveFailures = 0;
|
|
5357
|
-
var restoredMuted = (_ref = (
|
|
5358
|
-
var restoredVolume = (_ref1 = (
|
|
4884
|
+
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();
|
|
4885
|
+
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();
|
|
5359
4886
|
this.adLayer.updateOriginalMutedState(restoredMuted, restoredVolume);
|
|
5360
4887
|
this.adLayer.stop().catch(function() {});
|
|
5361
4888
|
if (this.video.muted !== restoredMuted) {
|
|
@@ -5464,7 +4991,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5464
4991
|
}, delay);
|
|
5465
4992
|
});
|
|
5466
4993
|
}
|
|
5467
|
-
this.
|
|
4994
|
+
this.savedMutedStateBeforeAd = null;
|
|
5468
4995
|
}
|
|
5469
4996
|
},
|
|
5470
4997
|
{
|
|
@@ -5614,19 +5141,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5614
5141
|
return Math.max(0, this.expectedAdBreakDurationMs - elapsed);
|
|
5615
5142
|
}
|
|
5616
5143
|
},
|
|
5617
|
-
{
|
|
5618
|
-
key: "pushScteMarker",
|
|
5619
|
-
value: function pushScteMarker(marker) {
|
|
5620
|
-
if (!this.config.debugAdTiming) return;
|
|
5621
|
-
this.scteMarkerHistory.push({
|
|
5622
|
-
timestampMs: Date.now(),
|
|
5623
|
-
marker: marker
|
|
5624
|
-
});
|
|
5625
|
-
if (this.scteMarkerHistory.length > DEBUG_HISTORY_LIMIT) {
|
|
5626
|
-
this.scteMarkerHistory = this.scteMarkerHistory.slice(-DEBUG_HISTORY_LIMIT);
|
|
5627
|
-
}
|
|
5628
|
-
}
|
|
5629
|
-
},
|
|
5630
5144
|
{
|
|
5631
5145
|
key: "pushDebugLog",
|
|
5632
5146
|
value: function pushDebugLog(level, category, message, details) {
|
|
@@ -5645,20 +5159,29 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5645
5159
|
}
|
|
5646
5160
|
},
|
|
5647
5161
|
{
|
|
5648
|
-
key: "
|
|
5649
|
-
value: function
|
|
5650
|
-
|
|
5651
|
-
|
|
5652
|
-
|
|
5653
|
-
|
|
5654
|
-
|
|
5655
|
-
|
|
5656
|
-
|
|
5657
|
-
|
|
5658
|
-
|
|
5659
|
-
|
|
5660
|
-
|
|
5661
|
-
});
|
|
5162
|
+
key: "pushAdInsertionDebug",
|
|
5163
|
+
value: function pushAdInsertionDebug(event, segmentName, opts) {
|
|
5164
|
+
if (!this.config.debugAdTiming) return;
|
|
5165
|
+
this.adInsertionDebugHistory.push(_object_spread({
|
|
5166
|
+
timestampMs: Date.now(),
|
|
5167
|
+
event: event,
|
|
5168
|
+
segmentName: segmentName
|
|
5169
|
+
}, (opts === null || opts === void 0 ? void 0 : opts.offsetSeconds) !== void 0 ? {
|
|
5170
|
+
offsetSeconds: opts.offsetSeconds
|
|
5171
|
+
} : {}, (opts === null || opts === void 0 ? void 0 : opts.updatedAt) ? {
|
|
5172
|
+
updatedAt: opts.updatedAt
|
|
5173
|
+
} : {}, (opts === null || opts === void 0 ? void 0 : opts.detail) ? {
|
|
5174
|
+
detail: opts.detail
|
|
5175
|
+
} : {}));
|
|
5176
|
+
if (this.adInsertionDebugHistory.length > DEBUG_HISTORY_LIMIT) {
|
|
5177
|
+
this.adInsertionDebugHistory = this.adInsertionDebugHistory.slice(-DEBUG_HISTORY_LIMIT);
|
|
5178
|
+
}
|
|
5179
|
+
}
|
|
5180
|
+
},
|
|
5181
|
+
{
|
|
5182
|
+
key: "getAdInsertionDebugLog",
|
|
5183
|
+
value: function getAdInsertionDebugLog() {
|
|
5184
|
+
return this.adInsertionDebugHistory.slice();
|
|
5662
5185
|
}
|
|
5663
5186
|
},
|
|
5664
5187
|
{
|
|
@@ -5927,9 +5450,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5927
5450
|
key: "destroy",
|
|
5928
5451
|
value: function destroy() {
|
|
5929
5452
|
var _this_hls, _this_adLayer;
|
|
5453
|
+
this.stopAdInsertionPolling();
|
|
5454
|
+
this.clearAdInsertionOffsetTimer();
|
|
5930
5455
|
this.stopContinuousFetching();
|
|
5931
5456
|
this.stopFillerBreakTimer();
|
|
5932
|
-
this.clearAdStartTimer();
|
|
5933
5457
|
this.clearAdStopTimer();
|
|
5934
5458
|
this.clearAdFailsafeTimer();
|
|
5935
5459
|
this.clearAdRequestWatchdog();
|
|
@@ -5957,7 +5481,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5957
5481
|
(_this_adLayer = this.adLayer) === null || _this_adLayer === void 0 ? void 0 : _this_adLayer.destroy();
|
|
5958
5482
|
this.consecutiveFailures = 0;
|
|
5959
5483
|
this.debugLogEntries = [];
|
|
5960
|
-
this.
|
|
5484
|
+
this.adInsertionDebugHistory = [];
|
|
5961
5485
|
}
|
|
5962
5486
|
}
|
|
5963
5487
|
]);
|