stormcloud-video-player 0.7.12 → 0.7.14
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 +57 -9
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +1 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +57 -9
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +57 -9
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/player/StormcloudVideoPlayer.d.cts +1 -0
- package/lib/players/HlsPlayer.cjs +57 -9
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/index.cjs +57 -9
- package/lib/players/index.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +57 -9
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/package.json +1 -1
package/lib/index.d.cts
CHANGED
|
@@ -204,6 +204,7 @@ declare class StormcloudVideoPlayer {
|
|
|
204
204
|
private stopAdInsertionPolling;
|
|
205
205
|
private fetchAdInsertionPoint;
|
|
206
206
|
private checkAdInsertionInManifest;
|
|
207
|
+
private extractTsFilename;
|
|
207
208
|
private fragmentMatchesSegment;
|
|
208
209
|
private clearAdInsertionOffsetTimer;
|
|
209
210
|
private startContinuousFetchLoop;
|
package/lib/index.d.ts
CHANGED
|
@@ -204,6 +204,7 @@ declare class StormcloudVideoPlayer {
|
|
|
204
204
|
private stopAdInsertionPolling;
|
|
205
205
|
private fetchAdInsertionPoint;
|
|
206
206
|
private checkAdInsertionInManifest;
|
|
207
|
+
private extractTsFilename;
|
|
207
208
|
private fragmentMatchesSegment;
|
|
208
209
|
private clearAdInsertionOffsetTimer;
|
|
209
210
|
private startContinuousFetchLoop;
|
package/lib/index.js
CHANGED
|
@@ -3641,6 +3641,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3641
3641
|
if (this.config.debugAdTiming) {
|
|
3642
3642
|
console.log("[PREFETCH] First VAST request returned no ad, aborting prefetch");
|
|
3643
3643
|
}
|
|
3644
|
+
this.clearPendingAdBreak();
|
|
3644
3645
|
return [
|
|
3645
3646
|
2
|
|
3646
3647
|
];
|
|
@@ -3874,7 +3875,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3874
3875
|
key: "fetchAdInsertionPoint",
|
|
3875
3876
|
value: function fetchAdInsertionPoint() {
|
|
3876
3877
|
return _async_to_generator(function() {
|
|
3877
|
-
var _this_lastAdInsertionPoint, resp, data, isNew, unused;
|
|
3878
|
+
var _this_lastAdInsertionPoint, _this_lastAdInsertionPoint1, resp, data, prevSegment, isNew, segmentChanged, unused;
|
|
3878
3879
|
return _ts_generator(this, function(_state) {
|
|
3879
3880
|
switch(_state.label){
|
|
3880
3881
|
case 0:
|
|
@@ -3904,7 +3905,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3904
3905
|
];
|
|
3905
3906
|
case 3:
|
|
3906
3907
|
data = _state.sent();
|
|
3907
|
-
|
|
3908
|
+
prevSegment = (_this_lastAdInsertionPoint = this.lastAdInsertionPoint) === null || _this_lastAdInsertionPoint === void 0 ? void 0 : _this_lastAdInsertionPoint.segment_ts_name;
|
|
3909
|
+
isNew = data.updated_at !== ((_this_lastAdInsertionPoint1 = this.lastAdInsertionPoint) === null || _this_lastAdInsertionPoint1 === void 0 ? void 0 : _this_lastAdInsertionPoint1.updated_at);
|
|
3910
|
+
segmentChanged = prevSegment !== data.segment_ts_name;
|
|
3908
3911
|
this.lastAdInsertionPoint = data;
|
|
3909
3912
|
if (isNew) {
|
|
3910
3913
|
this.pushAdInsertionDebug("api_response", data.segment_ts_name, {
|
|
@@ -3912,6 +3915,15 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3912
3915
|
updatedAt: data.updated_at,
|
|
3913
3916
|
detail: "project=".concat(data.project_id)
|
|
3914
3917
|
});
|
|
3918
|
+
if (segmentChanged && (this.pendingAdBreak || this.adInsertionOffsetTimerId != null)) {
|
|
3919
|
+
this.clearAdInsertionOffsetTimer();
|
|
3920
|
+
this.clearPendingAdBreak();
|
|
3921
|
+
this.cancelAndClearPreloadedTokens();
|
|
3922
|
+
if (this.config.debugAdTiming) {
|
|
3923
|
+
console.log("[StormcloudVideoPlayer] Insertion segment changed (".concat(prevSegment, " → ").concat(data.segment_ts_name, "), stale pending state cleared"));
|
|
3924
|
+
}
|
|
3925
|
+
}
|
|
3926
|
+
this.checkAdInsertionInManifest();
|
|
3915
3927
|
}
|
|
3916
3928
|
if (this.config.debugAdTiming) {
|
|
3917
3929
|
console.log("[StormcloudVideoPlayer] Ad insertion point API response:", data);
|
|
@@ -3941,6 +3953,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3941
3953
|
{
|
|
3942
3954
|
key: "checkAdInsertionInManifest",
|
|
3943
3955
|
value: function checkAdInsertionInManifest() {
|
|
3956
|
+
var _this = this;
|
|
3944
3957
|
var _this_hls;
|
|
3945
3958
|
if (!this.lastAdInsertionPoint) return;
|
|
3946
3959
|
if (this.inAdBreak || this.pendingAdBreak) return;
|
|
@@ -3960,14 +3973,42 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3960
3973
|
for(var _iterator1 = fragments[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
3961
3974
|
var frag = _step1.value;
|
|
3962
3975
|
if (this.fragmentMatchesSegment(frag, segmentName)) {
|
|
3963
|
-
var _ref;
|
|
3976
|
+
var _frag_start, _frag_duration, _ref;
|
|
3977
|
+
var currentTime = this.video.currentTime;
|
|
3978
|
+
var fragStart = (_frag_start = frag.start) !== null && _frag_start !== void 0 ? _frag_start : 0;
|
|
3979
|
+
var fragDuration = (_frag_duration = frag.duration) !== null && _frag_duration !== void 0 ? _frag_duration : 0;
|
|
3980
|
+
var isCurrentlyPlaying = fragDuration > 0 && currentTime >= fragStart && currentTime < fragStart + fragDuration;
|
|
3964
3981
|
this.pushAdInsertionDebug("segment_found", segmentName, {
|
|
3965
|
-
detail: "sn=".concat((_ref = frag === null || frag === void 0 ? void 0 : frag.sn) !== null && _ref !== void 0 ? _ref : "?")
|
|
3982
|
+
detail: "sn=".concat((_ref = frag === null || frag === void 0 ? void 0 : frag.sn) !== null && _ref !== void 0 ? _ref : "?", " ").concat(isCurrentlyPlaying ? "(playing)" : "(future)")
|
|
3966
3983
|
});
|
|
3967
3984
|
if (this.config.debugAdTiming) {
|
|
3968
|
-
console.log('[StormcloudVideoPlayer] Ad insertion segment "'.concat(segmentName, '" found in manifest — starting pre-fetch
|
|
3985
|
+
console.log('[StormcloudVideoPlayer] Ad insertion segment "'.concat(segmentName, '" found in manifest — ') + (isCurrentlyPlaying ? "currently playing, scheduling directly" : "starting pre-fetch"));
|
|
3969
3986
|
}
|
|
3970
3987
|
this.startAdPrefetch(60, frag === null || frag === void 0 ? void 0 : frag.sn);
|
|
3988
|
+
if (isCurrentlyPlaying && !this.inAdBreak) {
|
|
3989
|
+
var _this_lastAdInsertionPoint_offset_seconds, _ref1;
|
|
3990
|
+
this.processedAdInsertionUpdatedAt = this.lastAdInsertionPoint.updated_at;
|
|
3991
|
+
var rawOffsetMs = ((_this_lastAdInsertionPoint_offset_seconds = this.lastAdInsertionPoint.offset_seconds) !== null && _this_lastAdInsertionPoint_offset_seconds !== void 0 ? _this_lastAdInsertionPoint_offset_seconds : 0) * 1e3;
|
|
3992
|
+
var elapsedInFragMs = (currentTime - fragStart) * 1e3;
|
|
3993
|
+
var remainingOffsetMs = Math.max(0, rawOffsetMs - elapsedInFragMs);
|
|
3994
|
+
this.pushAdInsertionDebug("segment_playing", segmentName, {
|
|
3995
|
+
offsetSeconds: this.lastAdInsertionPoint.offset_seconds,
|
|
3996
|
+
detail: "sn=".concat((_ref1 = frag === null || frag === void 0 ? void 0 : frag.sn) !== null && _ref1 !== void 0 ? _ref1 : "?", " (caught in manifest check)")
|
|
3997
|
+
});
|
|
3998
|
+
this.pushAdInsertionDebug("ad_scheduled", segmentName, {
|
|
3999
|
+
offsetSeconds: this.lastAdInsertionPoint.offset_seconds,
|
|
4000
|
+
detail: "in ".concat(remainingOffsetMs, "ms (adjusted for elapsed ").concat(Math.round(elapsedInFragMs), "ms)")
|
|
4001
|
+
});
|
|
4002
|
+
this.clearAdInsertionOffsetTimer();
|
|
4003
|
+
this.adInsertionOffsetTimerId = window.setTimeout(function() {
|
|
4004
|
+
_this.adInsertionOffsetTimerId = void 0;
|
|
4005
|
+
if (_this.inAdBreak) return;
|
|
4006
|
+
_this.pushAdInsertionDebug("ad_triggered", segmentName, {
|
|
4007
|
+
detail: "ad break started (60s, via manifest-check path)"
|
|
4008
|
+
});
|
|
4009
|
+
void _this.handleAdStart(60);
|
|
4010
|
+
}, remainingOffsetMs);
|
|
4011
|
+
}
|
|
3971
4012
|
return;
|
|
3972
4013
|
}
|
|
3973
4014
|
}
|
|
@@ -4002,14 +4043,21 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4002
4043
|
}
|
|
4003
4044
|
}
|
|
4004
4045
|
},
|
|
4046
|
+
{
|
|
4047
|
+
key: "extractTsFilename",
|
|
4048
|
+
value: function extractTsFilename(url) {
|
|
4049
|
+
var _parts_;
|
|
4050
|
+
var clean = url.includes("?") ? url.slice(0, url.indexOf("?")) : url;
|
|
4051
|
+
var parts = clean.split("/");
|
|
4052
|
+
return (_parts_ = parts[parts.length - 1]) !== null && _parts_ !== void 0 ? _parts_ : clean;
|
|
4053
|
+
}
|
|
4054
|
+
},
|
|
4005
4055
|
{
|
|
4006
4056
|
key: "fragmentMatchesSegment",
|
|
4007
4057
|
value: function fragmentMatchesSegment(frag, segmentName) {
|
|
4008
|
-
var _rawUrl_split_;
|
|
4009
4058
|
var rawUrl = (frag === null || frag === void 0 ? void 0 : frag.url) || (frag === null || frag === void 0 ? void 0 : frag.relurl) || "";
|
|
4010
|
-
|
|
4011
|
-
|
|
4012
|
-
return url.endsWith(name) || url.includes(name);
|
|
4059
|
+
if (!rawUrl) return false;
|
|
4060
|
+
return this.extractTsFilename(rawUrl) === this.extractTsFilename(segmentName);
|
|
4013
4061
|
}
|
|
4014
4062
|
},
|
|
4015
4063
|
{
|