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
|
@@ -3591,6 +3591,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3591
3591
|
if (this.config.debugAdTiming) {
|
|
3592
3592
|
console.log("[PREFETCH] First VAST request returned no ad, aborting prefetch");
|
|
3593
3593
|
}
|
|
3594
|
+
this.clearPendingAdBreak();
|
|
3594
3595
|
return [
|
|
3595
3596
|
2
|
|
3596
3597
|
];
|
|
@@ -3824,7 +3825,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3824
3825
|
key: "fetchAdInsertionPoint",
|
|
3825
3826
|
value: function fetchAdInsertionPoint() {
|
|
3826
3827
|
return _async_to_generator(function() {
|
|
3827
|
-
var _this_lastAdInsertionPoint, resp, data, isNew, unused;
|
|
3828
|
+
var _this_lastAdInsertionPoint, _this_lastAdInsertionPoint1, resp, data, prevSegment, isNew, segmentChanged, unused;
|
|
3828
3829
|
return _ts_generator(this, function(_state) {
|
|
3829
3830
|
switch(_state.label){
|
|
3830
3831
|
case 0:
|
|
@@ -3854,7 +3855,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3854
3855
|
];
|
|
3855
3856
|
case 3:
|
|
3856
3857
|
data = _state.sent();
|
|
3857
|
-
|
|
3858
|
+
prevSegment = (_this_lastAdInsertionPoint = this.lastAdInsertionPoint) === null || _this_lastAdInsertionPoint === void 0 ? void 0 : _this_lastAdInsertionPoint.segment_ts_name;
|
|
3859
|
+
isNew = data.updated_at !== ((_this_lastAdInsertionPoint1 = this.lastAdInsertionPoint) === null || _this_lastAdInsertionPoint1 === void 0 ? void 0 : _this_lastAdInsertionPoint1.updated_at);
|
|
3860
|
+
segmentChanged = prevSegment !== data.segment_ts_name;
|
|
3858
3861
|
this.lastAdInsertionPoint = data;
|
|
3859
3862
|
if (isNew) {
|
|
3860
3863
|
this.pushAdInsertionDebug("api_response", data.segment_ts_name, {
|
|
@@ -3862,6 +3865,15 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3862
3865
|
updatedAt: data.updated_at,
|
|
3863
3866
|
detail: "project=".concat(data.project_id)
|
|
3864
3867
|
});
|
|
3868
|
+
if (segmentChanged && (this.pendingAdBreak || this.adInsertionOffsetTimerId != null)) {
|
|
3869
|
+
this.clearAdInsertionOffsetTimer();
|
|
3870
|
+
this.clearPendingAdBreak();
|
|
3871
|
+
this.cancelAndClearPreloadedTokens();
|
|
3872
|
+
if (this.config.debugAdTiming) {
|
|
3873
|
+
console.log("[StormcloudVideoPlayer] Insertion segment changed (".concat(prevSegment, " → ").concat(data.segment_ts_name, "), stale pending state cleared"));
|
|
3874
|
+
}
|
|
3875
|
+
}
|
|
3876
|
+
this.checkAdInsertionInManifest();
|
|
3865
3877
|
}
|
|
3866
3878
|
if (this.config.debugAdTiming) {
|
|
3867
3879
|
console.log("[StormcloudVideoPlayer] Ad insertion point API response:", data);
|
|
@@ -3891,6 +3903,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3891
3903
|
{
|
|
3892
3904
|
key: "checkAdInsertionInManifest",
|
|
3893
3905
|
value: function checkAdInsertionInManifest() {
|
|
3906
|
+
var _this = this;
|
|
3894
3907
|
var _this_hls;
|
|
3895
3908
|
if (!this.lastAdInsertionPoint) return;
|
|
3896
3909
|
if (this.inAdBreak || this.pendingAdBreak) return;
|
|
@@ -3910,14 +3923,42 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3910
3923
|
for(var _iterator1 = fragments[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
3911
3924
|
var frag = _step1.value;
|
|
3912
3925
|
if (this.fragmentMatchesSegment(frag, segmentName)) {
|
|
3913
|
-
var _ref;
|
|
3926
|
+
var _frag_start, _frag_duration, _ref;
|
|
3927
|
+
var currentTime = this.video.currentTime;
|
|
3928
|
+
var fragStart = (_frag_start = frag.start) !== null && _frag_start !== void 0 ? _frag_start : 0;
|
|
3929
|
+
var fragDuration = (_frag_duration = frag.duration) !== null && _frag_duration !== void 0 ? _frag_duration : 0;
|
|
3930
|
+
var isCurrentlyPlaying = fragDuration > 0 && currentTime >= fragStart && currentTime < fragStart + fragDuration;
|
|
3914
3931
|
this.pushAdInsertionDebug("segment_found", segmentName, {
|
|
3915
|
-
detail: "sn=".concat((_ref = frag === null || frag === void 0 ? void 0 : frag.sn) !== null && _ref !== void 0 ? _ref : "?")
|
|
3932
|
+
detail: "sn=".concat((_ref = frag === null || frag === void 0 ? void 0 : frag.sn) !== null && _ref !== void 0 ? _ref : "?", " ").concat(isCurrentlyPlaying ? "(playing)" : "(future)")
|
|
3916
3933
|
});
|
|
3917
3934
|
if (this.config.debugAdTiming) {
|
|
3918
|
-
console.log('[StormcloudVideoPlayer] Ad insertion segment "'.concat(segmentName, '" found in manifest — starting pre-fetch
|
|
3935
|
+
console.log('[StormcloudVideoPlayer] Ad insertion segment "'.concat(segmentName, '" found in manifest — ') + (isCurrentlyPlaying ? "currently playing, scheduling directly" : "starting pre-fetch"));
|
|
3919
3936
|
}
|
|
3920
3937
|
this.startAdPrefetch(60, frag === null || frag === void 0 ? void 0 : frag.sn);
|
|
3938
|
+
if (isCurrentlyPlaying && !this.inAdBreak) {
|
|
3939
|
+
var _this_lastAdInsertionPoint_offset_seconds, _ref1;
|
|
3940
|
+
this.processedAdInsertionUpdatedAt = this.lastAdInsertionPoint.updated_at;
|
|
3941
|
+
var rawOffsetMs = ((_this_lastAdInsertionPoint_offset_seconds = this.lastAdInsertionPoint.offset_seconds) !== null && _this_lastAdInsertionPoint_offset_seconds !== void 0 ? _this_lastAdInsertionPoint_offset_seconds : 0) * 1e3;
|
|
3942
|
+
var elapsedInFragMs = (currentTime - fragStart) * 1e3;
|
|
3943
|
+
var remainingOffsetMs = Math.max(0, rawOffsetMs - elapsedInFragMs);
|
|
3944
|
+
this.pushAdInsertionDebug("segment_playing", segmentName, {
|
|
3945
|
+
offsetSeconds: this.lastAdInsertionPoint.offset_seconds,
|
|
3946
|
+
detail: "sn=".concat((_ref1 = frag === null || frag === void 0 ? void 0 : frag.sn) !== null && _ref1 !== void 0 ? _ref1 : "?", " (caught in manifest check)")
|
|
3947
|
+
});
|
|
3948
|
+
this.pushAdInsertionDebug("ad_scheduled", segmentName, {
|
|
3949
|
+
offsetSeconds: this.lastAdInsertionPoint.offset_seconds,
|
|
3950
|
+
detail: "in ".concat(remainingOffsetMs, "ms (adjusted for elapsed ").concat(Math.round(elapsedInFragMs), "ms)")
|
|
3951
|
+
});
|
|
3952
|
+
this.clearAdInsertionOffsetTimer();
|
|
3953
|
+
this.adInsertionOffsetTimerId = window.setTimeout(function() {
|
|
3954
|
+
_this.adInsertionOffsetTimerId = void 0;
|
|
3955
|
+
if (_this.inAdBreak) return;
|
|
3956
|
+
_this.pushAdInsertionDebug("ad_triggered", segmentName, {
|
|
3957
|
+
detail: "ad break started (60s, via manifest-check path)"
|
|
3958
|
+
});
|
|
3959
|
+
void _this.handleAdStart(60);
|
|
3960
|
+
}, remainingOffsetMs);
|
|
3961
|
+
}
|
|
3921
3962
|
return;
|
|
3922
3963
|
}
|
|
3923
3964
|
}
|