stormcloud-video-player 0.7.12 → 0.7.13
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 +46 -5
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +46 -5
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +46 -5
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.cjs +46 -5
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/index.cjs +46 -5
- package/lib/players/index.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +46 -5
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/package.json +1 -1
package/lib/index.cjs
CHANGED
|
@@ -3807,6 +3807,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3807
3807
|
if (this.config.debugAdTiming) {
|
|
3808
3808
|
console.log("[PREFETCH] First VAST request returned no ad, aborting prefetch");
|
|
3809
3809
|
}
|
|
3810
|
+
this.clearPendingAdBreak();
|
|
3810
3811
|
return [
|
|
3811
3812
|
2
|
|
3812
3813
|
];
|
|
@@ -4040,7 +4041,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4040
4041
|
key: "fetchAdInsertionPoint",
|
|
4041
4042
|
value: function fetchAdInsertionPoint() {
|
|
4042
4043
|
return _async_to_generator(function() {
|
|
4043
|
-
var _this_lastAdInsertionPoint, resp, data, isNew, unused;
|
|
4044
|
+
var _this_lastAdInsertionPoint, _this_lastAdInsertionPoint1, resp, data, prevSegment, isNew, segmentChanged, unused;
|
|
4044
4045
|
return _ts_generator(this, function(_state) {
|
|
4045
4046
|
switch(_state.label){
|
|
4046
4047
|
case 0:
|
|
@@ -4070,7 +4071,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4070
4071
|
];
|
|
4071
4072
|
case 3:
|
|
4072
4073
|
data = _state.sent();
|
|
4073
|
-
|
|
4074
|
+
prevSegment = (_this_lastAdInsertionPoint = this.lastAdInsertionPoint) === null || _this_lastAdInsertionPoint === void 0 ? void 0 : _this_lastAdInsertionPoint.segment_ts_name;
|
|
4075
|
+
isNew = data.updated_at !== ((_this_lastAdInsertionPoint1 = this.lastAdInsertionPoint) === null || _this_lastAdInsertionPoint1 === void 0 ? void 0 : _this_lastAdInsertionPoint1.updated_at);
|
|
4076
|
+
segmentChanged = prevSegment !== data.segment_ts_name;
|
|
4074
4077
|
this.lastAdInsertionPoint = data;
|
|
4075
4078
|
if (isNew) {
|
|
4076
4079
|
this.pushAdInsertionDebug("api_response", data.segment_ts_name, {
|
|
@@ -4078,6 +4081,15 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4078
4081
|
updatedAt: data.updated_at,
|
|
4079
4082
|
detail: "project=".concat(data.project_id)
|
|
4080
4083
|
});
|
|
4084
|
+
if (segmentChanged && (this.pendingAdBreak || this.adInsertionOffsetTimerId != null)) {
|
|
4085
|
+
this.clearAdInsertionOffsetTimer();
|
|
4086
|
+
this.clearPendingAdBreak();
|
|
4087
|
+
this.cancelAndClearPreloadedTokens();
|
|
4088
|
+
if (this.config.debugAdTiming) {
|
|
4089
|
+
console.log("[StormcloudVideoPlayer] Insertion segment changed (".concat(prevSegment, " → ").concat(data.segment_ts_name, "), stale pending state cleared"));
|
|
4090
|
+
}
|
|
4091
|
+
}
|
|
4092
|
+
this.checkAdInsertionInManifest();
|
|
4081
4093
|
}
|
|
4082
4094
|
if (this.config.debugAdTiming) {
|
|
4083
4095
|
console.log("[StormcloudVideoPlayer] Ad insertion point API response:", data);
|
|
@@ -4107,6 +4119,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4107
4119
|
{
|
|
4108
4120
|
key: "checkAdInsertionInManifest",
|
|
4109
4121
|
value: function checkAdInsertionInManifest() {
|
|
4122
|
+
var _this = this;
|
|
4110
4123
|
var _this_hls;
|
|
4111
4124
|
if (!this.lastAdInsertionPoint) return;
|
|
4112
4125
|
if (this.inAdBreak || this.pendingAdBreak) return;
|
|
@@ -4126,14 +4139,42 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4126
4139
|
for(var _iterator1 = fragments[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
4127
4140
|
var frag = _step1.value;
|
|
4128
4141
|
if (this.fragmentMatchesSegment(frag, segmentName)) {
|
|
4129
|
-
var _ref;
|
|
4142
|
+
var _frag_start, _frag_duration, _ref;
|
|
4143
|
+
var currentTime = this.video.currentTime;
|
|
4144
|
+
var fragStart = (_frag_start = frag.start) !== null && _frag_start !== void 0 ? _frag_start : 0;
|
|
4145
|
+
var fragDuration = (_frag_duration = frag.duration) !== null && _frag_duration !== void 0 ? _frag_duration : 0;
|
|
4146
|
+
var isCurrentlyPlaying = fragDuration > 0 && currentTime >= fragStart && currentTime < fragStart + fragDuration;
|
|
4130
4147
|
this.pushAdInsertionDebug("segment_found", segmentName, {
|
|
4131
|
-
detail: "sn=".concat((_ref = frag === null || frag === void 0 ? void 0 : frag.sn) !== null && _ref !== void 0 ? _ref : "?")
|
|
4148
|
+
detail: "sn=".concat((_ref = frag === null || frag === void 0 ? void 0 : frag.sn) !== null && _ref !== void 0 ? _ref : "?", " ").concat(isCurrentlyPlaying ? "(playing)" : "(future)")
|
|
4132
4149
|
});
|
|
4133
4150
|
if (this.config.debugAdTiming) {
|
|
4134
|
-
console.log('[StormcloudVideoPlayer] Ad insertion segment "'.concat(segmentName, '" found in manifest — starting pre-fetch
|
|
4151
|
+
console.log('[StormcloudVideoPlayer] Ad insertion segment "'.concat(segmentName, '" found in manifest — ') + (isCurrentlyPlaying ? "currently playing, scheduling directly" : "starting pre-fetch"));
|
|
4135
4152
|
}
|
|
4136
4153
|
this.startAdPrefetch(60, frag === null || frag === void 0 ? void 0 : frag.sn);
|
|
4154
|
+
if (isCurrentlyPlaying && !this.inAdBreak) {
|
|
4155
|
+
var _this_lastAdInsertionPoint_offset_seconds, _ref1;
|
|
4156
|
+
this.processedAdInsertionUpdatedAt = this.lastAdInsertionPoint.updated_at;
|
|
4157
|
+
var rawOffsetMs = ((_this_lastAdInsertionPoint_offset_seconds = this.lastAdInsertionPoint.offset_seconds) !== null && _this_lastAdInsertionPoint_offset_seconds !== void 0 ? _this_lastAdInsertionPoint_offset_seconds : 0) * 1e3;
|
|
4158
|
+
var elapsedInFragMs = (currentTime - fragStart) * 1e3;
|
|
4159
|
+
var remainingOffsetMs = Math.max(0, rawOffsetMs - elapsedInFragMs);
|
|
4160
|
+
this.pushAdInsertionDebug("segment_playing", segmentName, {
|
|
4161
|
+
offsetSeconds: this.lastAdInsertionPoint.offset_seconds,
|
|
4162
|
+
detail: "sn=".concat((_ref1 = frag === null || frag === void 0 ? void 0 : frag.sn) !== null && _ref1 !== void 0 ? _ref1 : "?", " (caught in manifest check)")
|
|
4163
|
+
});
|
|
4164
|
+
this.pushAdInsertionDebug("ad_scheduled", segmentName, {
|
|
4165
|
+
offsetSeconds: this.lastAdInsertionPoint.offset_seconds,
|
|
4166
|
+
detail: "in ".concat(remainingOffsetMs, "ms (adjusted for elapsed ").concat(Math.round(elapsedInFragMs), "ms)")
|
|
4167
|
+
});
|
|
4168
|
+
this.clearAdInsertionOffsetTimer();
|
|
4169
|
+
this.adInsertionOffsetTimerId = window.setTimeout(function() {
|
|
4170
|
+
_this.adInsertionOffsetTimerId = void 0;
|
|
4171
|
+
if (_this.inAdBreak) return;
|
|
4172
|
+
_this.pushAdInsertionDebug("ad_triggered", segmentName, {
|
|
4173
|
+
detail: "ad break started (60s, via manifest-check path)"
|
|
4174
|
+
});
|
|
4175
|
+
void _this.handleAdStart(60);
|
|
4176
|
+
}, remainingOffsetMs);
|
|
4177
|
+
}
|
|
4137
4178
|
return;
|
|
4138
4179
|
}
|
|
4139
4180
|
}
|