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
|
@@ -3629,6 +3629,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3629
3629
|
if (this.config.debugAdTiming) {
|
|
3630
3630
|
console.log("[PREFETCH] First VAST request returned no ad, aborting prefetch");
|
|
3631
3631
|
}
|
|
3632
|
+
this.clearPendingAdBreak();
|
|
3632
3633
|
return [
|
|
3633
3634
|
2
|
|
3634
3635
|
];
|
|
@@ -3862,7 +3863,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3862
3863
|
key: "fetchAdInsertionPoint",
|
|
3863
3864
|
value: function fetchAdInsertionPoint() {
|
|
3864
3865
|
return _async_to_generator(function() {
|
|
3865
|
-
var _this_lastAdInsertionPoint, resp, data, isNew, unused;
|
|
3866
|
+
var _this_lastAdInsertionPoint, _this_lastAdInsertionPoint1, resp, data, prevSegment, isNew, segmentChanged, unused;
|
|
3866
3867
|
return _ts_generator(this, function(_state) {
|
|
3867
3868
|
switch(_state.label){
|
|
3868
3869
|
case 0:
|
|
@@ -3892,7 +3893,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3892
3893
|
];
|
|
3893
3894
|
case 3:
|
|
3894
3895
|
data = _state.sent();
|
|
3895
|
-
|
|
3896
|
+
prevSegment = (_this_lastAdInsertionPoint = this.lastAdInsertionPoint) === null || _this_lastAdInsertionPoint === void 0 ? void 0 : _this_lastAdInsertionPoint.segment_ts_name;
|
|
3897
|
+
isNew = data.updated_at !== ((_this_lastAdInsertionPoint1 = this.lastAdInsertionPoint) === null || _this_lastAdInsertionPoint1 === void 0 ? void 0 : _this_lastAdInsertionPoint1.updated_at);
|
|
3898
|
+
segmentChanged = prevSegment !== data.segment_ts_name;
|
|
3896
3899
|
this.lastAdInsertionPoint = data;
|
|
3897
3900
|
if (isNew) {
|
|
3898
3901
|
this.pushAdInsertionDebug("api_response", data.segment_ts_name, {
|
|
@@ -3900,6 +3903,15 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3900
3903
|
updatedAt: data.updated_at,
|
|
3901
3904
|
detail: "project=".concat(data.project_id)
|
|
3902
3905
|
});
|
|
3906
|
+
if (segmentChanged && (this.pendingAdBreak || this.adInsertionOffsetTimerId != null)) {
|
|
3907
|
+
this.clearAdInsertionOffsetTimer();
|
|
3908
|
+
this.clearPendingAdBreak();
|
|
3909
|
+
this.cancelAndClearPreloadedTokens();
|
|
3910
|
+
if (this.config.debugAdTiming) {
|
|
3911
|
+
console.log("[StormcloudVideoPlayer] Insertion segment changed (".concat(prevSegment, " → ").concat(data.segment_ts_name, "), stale pending state cleared"));
|
|
3912
|
+
}
|
|
3913
|
+
}
|
|
3914
|
+
this.checkAdInsertionInManifest();
|
|
3903
3915
|
}
|
|
3904
3916
|
if (this.config.debugAdTiming) {
|
|
3905
3917
|
console.log("[StormcloudVideoPlayer] Ad insertion point API response:", data);
|
|
@@ -3929,6 +3941,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3929
3941
|
{
|
|
3930
3942
|
key: "checkAdInsertionInManifest",
|
|
3931
3943
|
value: function checkAdInsertionInManifest() {
|
|
3944
|
+
var _this = this;
|
|
3932
3945
|
var _this_hls;
|
|
3933
3946
|
if (!this.lastAdInsertionPoint) return;
|
|
3934
3947
|
if (this.inAdBreak || this.pendingAdBreak) return;
|
|
@@ -3948,14 +3961,42 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3948
3961
|
for(var _iterator1 = fragments[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
3949
3962
|
var frag = _step1.value;
|
|
3950
3963
|
if (this.fragmentMatchesSegment(frag, segmentName)) {
|
|
3951
|
-
var _ref;
|
|
3964
|
+
var _frag_start, _frag_duration, _ref;
|
|
3965
|
+
var currentTime = this.video.currentTime;
|
|
3966
|
+
var fragStart = (_frag_start = frag.start) !== null && _frag_start !== void 0 ? _frag_start : 0;
|
|
3967
|
+
var fragDuration = (_frag_duration = frag.duration) !== null && _frag_duration !== void 0 ? _frag_duration : 0;
|
|
3968
|
+
var isCurrentlyPlaying = fragDuration > 0 && currentTime >= fragStart && currentTime < fragStart + fragDuration;
|
|
3952
3969
|
this.pushAdInsertionDebug("segment_found", segmentName, {
|
|
3953
|
-
detail: "sn=".concat((_ref = frag === null || frag === void 0 ? void 0 : frag.sn) !== null && _ref !== void 0 ? _ref : "?")
|
|
3970
|
+
detail: "sn=".concat((_ref = frag === null || frag === void 0 ? void 0 : frag.sn) !== null && _ref !== void 0 ? _ref : "?", " ").concat(isCurrentlyPlaying ? "(playing)" : "(future)")
|
|
3954
3971
|
});
|
|
3955
3972
|
if (this.config.debugAdTiming) {
|
|
3956
|
-
console.log('[StormcloudVideoPlayer] Ad insertion segment "'.concat(segmentName, '" found in manifest — starting pre-fetch
|
|
3973
|
+
console.log('[StormcloudVideoPlayer] Ad insertion segment "'.concat(segmentName, '" found in manifest — ') + (isCurrentlyPlaying ? "currently playing, scheduling directly" : "starting pre-fetch"));
|
|
3957
3974
|
}
|
|
3958
3975
|
this.startAdPrefetch(60, frag === null || frag === void 0 ? void 0 : frag.sn);
|
|
3976
|
+
if (isCurrentlyPlaying && !this.inAdBreak) {
|
|
3977
|
+
var _this_lastAdInsertionPoint_offset_seconds, _ref1;
|
|
3978
|
+
this.processedAdInsertionUpdatedAt = this.lastAdInsertionPoint.updated_at;
|
|
3979
|
+
var rawOffsetMs = ((_this_lastAdInsertionPoint_offset_seconds = this.lastAdInsertionPoint.offset_seconds) !== null && _this_lastAdInsertionPoint_offset_seconds !== void 0 ? _this_lastAdInsertionPoint_offset_seconds : 0) * 1e3;
|
|
3980
|
+
var elapsedInFragMs = (currentTime - fragStart) * 1e3;
|
|
3981
|
+
var remainingOffsetMs = Math.max(0, rawOffsetMs - elapsedInFragMs);
|
|
3982
|
+
this.pushAdInsertionDebug("segment_playing", segmentName, {
|
|
3983
|
+
offsetSeconds: this.lastAdInsertionPoint.offset_seconds,
|
|
3984
|
+
detail: "sn=".concat((_ref1 = frag === null || frag === void 0 ? void 0 : frag.sn) !== null && _ref1 !== void 0 ? _ref1 : "?", " (caught in manifest check)")
|
|
3985
|
+
});
|
|
3986
|
+
this.pushAdInsertionDebug("ad_scheduled", segmentName, {
|
|
3987
|
+
offsetSeconds: this.lastAdInsertionPoint.offset_seconds,
|
|
3988
|
+
detail: "in ".concat(remainingOffsetMs, "ms (adjusted for elapsed ").concat(Math.round(elapsedInFragMs), "ms)")
|
|
3989
|
+
});
|
|
3990
|
+
this.clearAdInsertionOffsetTimer();
|
|
3991
|
+
this.adInsertionOffsetTimerId = window.setTimeout(function() {
|
|
3992
|
+
_this.adInsertionOffsetTimerId = void 0;
|
|
3993
|
+
if (_this.inAdBreak) return;
|
|
3994
|
+
_this.pushAdInsertionDebug("ad_triggered", segmentName, {
|
|
3995
|
+
detail: "ad break started (60s, via manifest-check path)"
|
|
3996
|
+
});
|
|
3997
|
+
void _this.handleAdStart(60);
|
|
3998
|
+
}, remainingOffsetMs);
|
|
3999
|
+
}
|
|
3959
4000
|
return;
|
|
3960
4001
|
}
|
|
3961
4002
|
}
|