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
|
@@ -3643,6 +3643,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3643
3643
|
if (this.config.debugAdTiming) {
|
|
3644
3644
|
console.log("[PREFETCH] First VAST request returned no ad, aborting prefetch");
|
|
3645
3645
|
}
|
|
3646
|
+
this.clearPendingAdBreak();
|
|
3646
3647
|
return [
|
|
3647
3648
|
2
|
|
3648
3649
|
];
|
|
@@ -3876,7 +3877,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3876
3877
|
key: "fetchAdInsertionPoint",
|
|
3877
3878
|
value: function fetchAdInsertionPoint() {
|
|
3878
3879
|
return _async_to_generator(function() {
|
|
3879
|
-
var _this_lastAdInsertionPoint, resp, data, isNew, unused;
|
|
3880
|
+
var _this_lastAdInsertionPoint, _this_lastAdInsertionPoint1, resp, data, prevSegment, isNew, segmentChanged, unused;
|
|
3880
3881
|
return _ts_generator(this, function(_state) {
|
|
3881
3882
|
switch(_state.label){
|
|
3882
3883
|
case 0:
|
|
@@ -3906,7 +3907,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3906
3907
|
];
|
|
3907
3908
|
case 3:
|
|
3908
3909
|
data = _state.sent();
|
|
3909
|
-
|
|
3910
|
+
prevSegment = (_this_lastAdInsertionPoint = this.lastAdInsertionPoint) === null || _this_lastAdInsertionPoint === void 0 ? void 0 : _this_lastAdInsertionPoint.segment_ts_name;
|
|
3911
|
+
isNew = data.updated_at !== ((_this_lastAdInsertionPoint1 = this.lastAdInsertionPoint) === null || _this_lastAdInsertionPoint1 === void 0 ? void 0 : _this_lastAdInsertionPoint1.updated_at);
|
|
3912
|
+
segmentChanged = prevSegment !== data.segment_ts_name;
|
|
3910
3913
|
this.lastAdInsertionPoint = data;
|
|
3911
3914
|
if (isNew) {
|
|
3912
3915
|
this.pushAdInsertionDebug("api_response", data.segment_ts_name, {
|
|
@@ -3914,6 +3917,15 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3914
3917
|
updatedAt: data.updated_at,
|
|
3915
3918
|
detail: "project=".concat(data.project_id)
|
|
3916
3919
|
});
|
|
3920
|
+
if (segmentChanged && (this.pendingAdBreak || this.adInsertionOffsetTimerId != null)) {
|
|
3921
|
+
this.clearAdInsertionOffsetTimer();
|
|
3922
|
+
this.clearPendingAdBreak();
|
|
3923
|
+
this.cancelAndClearPreloadedTokens();
|
|
3924
|
+
if (this.config.debugAdTiming) {
|
|
3925
|
+
console.log("[StormcloudVideoPlayer] Insertion segment changed (".concat(prevSegment, " → ").concat(data.segment_ts_name, "), stale pending state cleared"));
|
|
3926
|
+
}
|
|
3927
|
+
}
|
|
3928
|
+
this.checkAdInsertionInManifest();
|
|
3917
3929
|
}
|
|
3918
3930
|
if (this.config.debugAdTiming) {
|
|
3919
3931
|
console.log("[StormcloudVideoPlayer] Ad insertion point API response:", data);
|
|
@@ -3943,6 +3955,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3943
3955
|
{
|
|
3944
3956
|
key: "checkAdInsertionInManifest",
|
|
3945
3957
|
value: function checkAdInsertionInManifest() {
|
|
3958
|
+
var _this = this;
|
|
3946
3959
|
var _this_hls;
|
|
3947
3960
|
if (!this.lastAdInsertionPoint) return;
|
|
3948
3961
|
if (this.inAdBreak || this.pendingAdBreak) return;
|
|
@@ -3962,14 +3975,42 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3962
3975
|
for(var _iterator1 = fragments[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
3963
3976
|
var frag = _step1.value;
|
|
3964
3977
|
if (this.fragmentMatchesSegment(frag, segmentName)) {
|
|
3965
|
-
var _ref;
|
|
3978
|
+
var _frag_start, _frag_duration, _ref;
|
|
3979
|
+
var currentTime = this.video.currentTime;
|
|
3980
|
+
var fragStart = (_frag_start = frag.start) !== null && _frag_start !== void 0 ? _frag_start : 0;
|
|
3981
|
+
var fragDuration = (_frag_duration = frag.duration) !== null && _frag_duration !== void 0 ? _frag_duration : 0;
|
|
3982
|
+
var isCurrentlyPlaying = fragDuration > 0 && currentTime >= fragStart && currentTime < fragStart + fragDuration;
|
|
3966
3983
|
this.pushAdInsertionDebug("segment_found", segmentName, {
|
|
3967
|
-
detail: "sn=".concat((_ref = frag === null || frag === void 0 ? void 0 : frag.sn) !== null && _ref !== void 0 ? _ref : "?")
|
|
3984
|
+
detail: "sn=".concat((_ref = frag === null || frag === void 0 ? void 0 : frag.sn) !== null && _ref !== void 0 ? _ref : "?", " ").concat(isCurrentlyPlaying ? "(playing)" : "(future)")
|
|
3968
3985
|
});
|
|
3969
3986
|
if (this.config.debugAdTiming) {
|
|
3970
|
-
console.log('[StormcloudVideoPlayer] Ad insertion segment "'.concat(segmentName, '" found in manifest — starting pre-fetch
|
|
3987
|
+
console.log('[StormcloudVideoPlayer] Ad insertion segment "'.concat(segmentName, '" found in manifest — ') + (isCurrentlyPlaying ? "currently playing, scheduling directly" : "starting pre-fetch"));
|
|
3971
3988
|
}
|
|
3972
3989
|
this.startAdPrefetch(60, frag === null || frag === void 0 ? void 0 : frag.sn);
|
|
3990
|
+
if (isCurrentlyPlaying && !this.inAdBreak) {
|
|
3991
|
+
var _this_lastAdInsertionPoint_offset_seconds, _ref1;
|
|
3992
|
+
this.processedAdInsertionUpdatedAt = this.lastAdInsertionPoint.updated_at;
|
|
3993
|
+
var rawOffsetMs = ((_this_lastAdInsertionPoint_offset_seconds = this.lastAdInsertionPoint.offset_seconds) !== null && _this_lastAdInsertionPoint_offset_seconds !== void 0 ? _this_lastAdInsertionPoint_offset_seconds : 0) * 1e3;
|
|
3994
|
+
var elapsedInFragMs = (currentTime - fragStart) * 1e3;
|
|
3995
|
+
var remainingOffsetMs = Math.max(0, rawOffsetMs - elapsedInFragMs);
|
|
3996
|
+
this.pushAdInsertionDebug("segment_playing", segmentName, {
|
|
3997
|
+
offsetSeconds: this.lastAdInsertionPoint.offset_seconds,
|
|
3998
|
+
detail: "sn=".concat((_ref1 = frag === null || frag === void 0 ? void 0 : frag.sn) !== null && _ref1 !== void 0 ? _ref1 : "?", " (caught in manifest check)")
|
|
3999
|
+
});
|
|
4000
|
+
this.pushAdInsertionDebug("ad_scheduled", segmentName, {
|
|
4001
|
+
offsetSeconds: this.lastAdInsertionPoint.offset_seconds,
|
|
4002
|
+
detail: "in ".concat(remainingOffsetMs, "ms (adjusted for elapsed ").concat(Math.round(elapsedInFragMs), "ms)")
|
|
4003
|
+
});
|
|
4004
|
+
this.clearAdInsertionOffsetTimer();
|
|
4005
|
+
this.adInsertionOffsetTimerId = window.setTimeout(function() {
|
|
4006
|
+
_this.adInsertionOffsetTimerId = void 0;
|
|
4007
|
+
if (_this.inAdBreak) return;
|
|
4008
|
+
_this.pushAdInsertionDebug("ad_triggered", segmentName, {
|
|
4009
|
+
detail: "ad break started (60s, via manifest-check path)"
|
|
4010
|
+
});
|
|
4011
|
+
void _this.handleAdStart(60);
|
|
4012
|
+
}, remainingOffsetMs);
|
|
4013
|
+
}
|
|
3973
4014
|
return;
|
|
3974
4015
|
}
|
|
3975
4016
|
}
|