stormcloud-video-player 0.3.64 → 0.3.65
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 +2 -2
- package/lib/index.cjs +72 -45
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +5 -0
- package/lib/index.d.ts +5 -0
- package/lib/index.js +72 -45
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +72 -45
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/player/StormcloudVideoPlayer.d.cts +5 -0
- package/lib/players/HlsPlayer.cjs +72 -45
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/index.cjs +72 -45
- package/lib/players/index.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +72 -45
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/package.json +1 -1
package/lib/index.cjs
CHANGED
|
@@ -4122,7 +4122,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4122
4122
|
_this.showAds = true;
|
|
4123
4123
|
_this.resetGamNoFillCounter();
|
|
4124
4124
|
if (_this.inAdBreak && _this.expectedAdBreakDurationMs != null && _this.adStopTimerId == null) {
|
|
4125
|
-
_this.
|
|
4125
|
+
_this.scheduleAdStopAtBreakBoundary();
|
|
4126
4126
|
if (_this.config.debugAdTiming) {
|
|
4127
4127
|
console.log("[StormcloudVideoPlayer] Starting ad break timer on content_pause (first ad starting)");
|
|
4128
4128
|
}
|
|
@@ -4766,12 +4766,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4766
4766
|
if (marker.durationSeconds != null) {
|
|
4767
4767
|
var newDurationMs = marker.durationSeconds * 1e3;
|
|
4768
4768
|
if (this.expectedAdBreakDurationMs == null || newDurationMs > this.expectedAdBreakDurationMs) {
|
|
4769
|
-
this.
|
|
4770
|
-
|
|
4771
|
-
var remainingMs = Math.max(0, newDurationMs - elapsedMs);
|
|
4772
|
-
this.scheduleAdStopCountdown(remainingMs);
|
|
4769
|
+
this.setAdBreakDurationBoundary(newDurationMs);
|
|
4770
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
4773
4771
|
if (this.config.debugAdTiming) {
|
|
4774
|
-
console.log("[StormcloudVideoPlayer] Updated ad break duration from subsequent marker: ".concat(newDurationMs, "ms, remaining: ").concat(
|
|
4772
|
+
console.log("[StormcloudVideoPlayer] Updated ad break duration from subsequent marker: ".concat(newDurationMs, "ms, remaining: ").concat(this.getRemainingAdMs(), "ms"));
|
|
4775
4773
|
}
|
|
4776
4774
|
}
|
|
4777
4775
|
}
|
|
@@ -4845,13 +4843,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4845
4843
|
}
|
|
4846
4844
|
if (marker.type === "progress" && this.inAdBreak) {
|
|
4847
4845
|
if (marker.durationSeconds != null) {
|
|
4848
|
-
this.
|
|
4849
|
-
}
|
|
4850
|
-
if (this.expectedAdBreakDurationMs != null && this.currentAdBreakStartWallClockMs != null) {
|
|
4851
|
-
var elapsedMs1 = Date.now() - this.currentAdBreakStartWallClockMs;
|
|
4852
|
-
var remainingMs1 = Math.max(0, this.expectedAdBreakDurationMs - elapsedMs1);
|
|
4853
|
-
this.scheduleAdStopCountdown(remainingMs1);
|
|
4846
|
+
this.setAdBreakDurationBoundary(marker.durationSeconds * 1e3);
|
|
4854
4847
|
}
|
|
4848
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
4855
4849
|
if (!this.ima.isAdPlaying() && this.activeAdRequestToken === null && this.adRequestQueue.length > 0) {
|
|
4856
4850
|
this.tryNextAvailableAdWithRateLimit();
|
|
4857
4851
|
}
|
|
@@ -4876,15 +4870,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4876
4870
|
activeAdRequest: this.activeAdRequestToken !== null
|
|
4877
4871
|
});
|
|
4878
4872
|
}
|
|
4879
|
-
|
|
4880
|
-
if (this.config.debugAdTiming) {
|
|
4881
|
-
console.log("[StormcloudVideoPlayer] Ignoring premature SCTE-35 end marker - ads still active");
|
|
4882
|
-
}
|
|
4883
|
-
return;
|
|
4884
|
-
}
|
|
4885
|
-
this.inAdBreak = false;
|
|
4886
|
-
this.expectedAdBreakDurationMs = void 0;
|
|
4887
|
-
this.currentAdBreakStartWallClockMs = void 0;
|
|
4873
|
+
this.scteAdBreakEndWallClockMs = Date.now();
|
|
4888
4874
|
this.clearAdStartTimer();
|
|
4889
4875
|
this.clearAdStopTimer();
|
|
4890
4876
|
if (adPlaying) {
|
|
@@ -4908,12 +4894,46 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4908
4894
|
this.inAdBreak = true;
|
|
4909
4895
|
this.activeScte35BreakKey = cueKey !== null && cueKey !== void 0 ? cueKey : this.pendingScte35CueKey;
|
|
4910
4896
|
this.scheduledScte35BreakKey = void 0;
|
|
4911
|
-
this.
|
|
4912
|
-
this.
|
|
4897
|
+
this.currentAdBreakStartWallClockMs = this.resolveScteBreakStartWallClockMs(marker);
|
|
4898
|
+
this.setAdBreakDurationBoundary(durationMs);
|
|
4913
4899
|
this.handleAdStart(marker);
|
|
4914
|
-
|
|
4915
|
-
|
|
4900
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
4901
|
+
}
|
|
4902
|
+
},
|
|
4903
|
+
{
|
|
4904
|
+
key: "resolveScteBreakStartWallClockMs",
|
|
4905
|
+
value: function resolveScteBreakStartWallClockMs(marker) {
|
|
4906
|
+
var nowWallClockMs = Date.now();
|
|
4907
|
+
if (typeof marker.ptsSeconds !== "number") {
|
|
4908
|
+
return nowWallClockMs;
|
|
4916
4909
|
}
|
|
4910
|
+
var nowMs = this.video.currentTime * 1e3;
|
|
4911
|
+
var estimatedCurrentPtsMs = nowMs - this.ptsDriftEmaMs;
|
|
4912
|
+
var deltaMs = marker.ptsSeconds * 1e3 - estimatedCurrentPtsMs;
|
|
4913
|
+
if (!Number.isFinite(deltaMs)) {
|
|
4914
|
+
return nowWallClockMs;
|
|
4915
|
+
}
|
|
4916
|
+
return nowWallClockMs + Math.floor(deltaMs);
|
|
4917
|
+
}
|
|
4918
|
+
},
|
|
4919
|
+
{
|
|
4920
|
+
key: "setAdBreakDurationBoundary",
|
|
4921
|
+
value: function setAdBreakDurationBoundary(durationMs) {
|
|
4922
|
+
this.expectedAdBreakDurationMs = durationMs;
|
|
4923
|
+
if (durationMs != null && this.currentAdBreakStartWallClockMs != null) {
|
|
4924
|
+
this.scteAdBreakEndWallClockMs = this.currentAdBreakStartWallClockMs + durationMs;
|
|
4925
|
+
} else {
|
|
4926
|
+
this.scteAdBreakEndWallClockMs = void 0;
|
|
4927
|
+
}
|
|
4928
|
+
}
|
|
4929
|
+
},
|
|
4930
|
+
{
|
|
4931
|
+
key: "scheduleAdStopAtBreakBoundary",
|
|
4932
|
+
value: function scheduleAdStopAtBreakBoundary() {
|
|
4933
|
+
if (this.expectedAdBreakDurationMs == null) {
|
|
4934
|
+
return;
|
|
4935
|
+
}
|
|
4936
|
+
this.scheduleAdStopCountdown(this.getRemainingAdMs());
|
|
4917
4937
|
}
|
|
4918
4938
|
},
|
|
4919
4939
|
{
|
|
@@ -6541,7 +6561,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6541
6561
|
}
|
|
6542
6562
|
}
|
|
6543
6563
|
this.inAdBreak = true;
|
|
6544
|
-
this.currentAdBreakStartWallClockMs = Date.now();
|
|
6545
6564
|
this.currentAdIndex = 0;
|
|
6546
6565
|
this.totalAdsInBreak = 1;
|
|
6547
6566
|
this.adPodQueue = [];
|
|
@@ -6628,7 +6647,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6628
6647
|
case 2:
|
|
6629
6648
|
_state.sent();
|
|
6630
6649
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
6631
|
-
this.
|
|
6650
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
6632
6651
|
}
|
|
6633
6652
|
adVolume = currentMuted ? 0 : currentVolume;
|
|
6634
6653
|
this.ima.setAdVolume(adVolume);
|
|
@@ -6671,7 +6690,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6671
6690
|
case 6:
|
|
6672
6691
|
_state.sent();
|
|
6673
6692
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
6674
|
-
this.
|
|
6693
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
6675
6694
|
}
|
|
6676
6695
|
adVolume1 = currentMuted ? 0 : currentVolume;
|
|
6677
6696
|
this.ima.setAdVolume(adVolume1);
|
|
@@ -6726,7 +6745,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6726
6745
|
case 10:
|
|
6727
6746
|
_state.sent();
|
|
6728
6747
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
6729
|
-
this.
|
|
6748
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
6730
6749
|
}
|
|
6731
6750
|
adVolume2 = currentMuted ? 0 : currentVolume;
|
|
6732
6751
|
this.ima.setAdVolume(adVolume2);
|
|
@@ -7078,7 +7097,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
7078
7097
|
case 2:
|
|
7079
7098
|
_state.sent();
|
|
7080
7099
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
7081
|
-
this.
|
|
7100
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
7082
7101
|
}
|
|
7083
7102
|
currentMuted = this.video.muted;
|
|
7084
7103
|
currentVolume = this.video.volume;
|
|
@@ -7578,21 +7597,16 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
7578
7597
|
{
|
|
7579
7598
|
key: "ensureAdStoppedByTimer",
|
|
7580
7599
|
value: function ensureAdStoppedByTimer() {
|
|
7581
|
-
var _this_config_adBreakCheckIntervalMs,
|
|
7600
|
+
var _this_config_adBreakCheckIntervalMs, _this_getAdBreakEndWallClockMs;
|
|
7582
7601
|
if (!this.inAdBreak) return;
|
|
7583
7602
|
this.adStopTimerId = void 0;
|
|
7584
7603
|
var adPlaying = this.ima.isAdPlaying();
|
|
7585
|
-
var pendingAds = this.adPodQueue.length > 0;
|
|
7586
7604
|
var checkIntervalMs = Math.max(250, Math.floor((_this_config_adBreakCheckIntervalMs = this.config.adBreakCheckIntervalMs) !== null && _this_config_adBreakCheckIntervalMs !== void 0 ? _this_config_adBreakCheckIntervalMs : 1e3));
|
|
7587
7605
|
var maxExtensionMsConfig = this.config.maxAdBreakExtensionMs;
|
|
7588
|
-
var maxExtensionMs = typeof maxExtensionMsConfig === "number" && maxExtensionMsConfig > 0 ? maxExtensionMsConfig :
|
|
7589
|
-
var
|
|
7590
|
-
|
|
7591
|
-
|
|
7592
|
-
}
|
|
7593
|
-
var expectedDurationMs = (_this_expectedAdBreakDurationMs = this.expectedAdBreakDurationMs) !== null && _this_expectedAdBreakDurationMs !== void 0 ? _this_expectedAdBreakDurationMs : 0;
|
|
7594
|
-
var overrunMs = Math.max(0, elapsedSinceStartMs - expectedDurationMs);
|
|
7595
|
-
var shouldExtendAdBreak = (adPlaying || pendingAds || this.showAds) && overrunMs < maxExtensionMs;
|
|
7606
|
+
var maxExtensionMs = typeof maxExtensionMsConfig === "number" && maxExtensionMsConfig > 0 ? maxExtensionMsConfig : 0;
|
|
7607
|
+
var endWallClockMs = (_this_getAdBreakEndWallClockMs = this.getAdBreakEndWallClockMs()) !== null && _this_getAdBreakEndWallClockMs !== void 0 ? _this_getAdBreakEndWallClockMs : Date.now();
|
|
7608
|
+
var overrunMs = Math.max(0, Date.now() - endWallClockMs);
|
|
7609
|
+
var shouldExtendAdBreak = adPlaying && overrunMs < maxExtensionMs;
|
|
7596
7610
|
if (shouldExtendAdBreak) {
|
|
7597
7611
|
this.scheduleAdStopCountdown(checkIntervalMs);
|
|
7598
7612
|
return;
|
|
@@ -7858,7 +7872,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
7858
7872
|
case 5:
|
|
7859
7873
|
_state.sent();
|
|
7860
7874
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
7861
|
-
this.
|
|
7875
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
7862
7876
|
}
|
|
7863
7877
|
currentMuted = this.video.muted;
|
|
7864
7878
|
currentVolume = this.video.volume;
|
|
@@ -7908,7 +7922,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
7908
7922
|
case 8:
|
|
7909
7923
|
_state.sent();
|
|
7910
7924
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
7911
|
-
this.
|
|
7925
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
7912
7926
|
}
|
|
7913
7927
|
currentMuted1 = this.video.muted;
|
|
7914
7928
|
currentVolume1 = this.video.volume;
|
|
@@ -8053,6 +8067,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
8053
8067
|
this.scheduledScte35BreakKey = void 0;
|
|
8054
8068
|
this.expectedAdBreakDurationMs = void 0;
|
|
8055
8069
|
this.currentAdBreakStartWallClockMs = void 0;
|
|
8070
|
+
this.scteAdBreakEndWallClockMs = void 0;
|
|
8056
8071
|
this.clearAdStartTimer();
|
|
8057
8072
|
this.clearAdStopTimer();
|
|
8058
8073
|
this.adPodQueue = [];
|
|
@@ -8242,9 +8257,21 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
8242
8257
|
{
|
|
8243
8258
|
key: "getRemainingAdMs",
|
|
8244
8259
|
value: function getRemainingAdMs() {
|
|
8245
|
-
|
|
8246
|
-
|
|
8247
|
-
|
|
8260
|
+
var endWallClockMs = this.getAdBreakEndWallClockMs();
|
|
8261
|
+
if (endWallClockMs != null) {
|
|
8262
|
+
return Math.max(0, endWallClockMs - Date.now());
|
|
8263
|
+
}
|
|
8264
|
+
return 0;
|
|
8265
|
+
}
|
|
8266
|
+
},
|
|
8267
|
+
{
|
|
8268
|
+
key: "getAdBreakEndWallClockMs",
|
|
8269
|
+
value: function getAdBreakEndWallClockMs() {
|
|
8270
|
+
if (this.scteAdBreakEndWallClockMs != null) {
|
|
8271
|
+
return this.scteAdBreakEndWallClockMs;
|
|
8272
|
+
}
|
|
8273
|
+
if (this.expectedAdBreakDurationMs == null || this.currentAdBreakStartWallClockMs == null) return void 0;
|
|
8274
|
+
return this.currentAdBreakStartWallClockMs + this.expectedAdBreakDurationMs;
|
|
8248
8275
|
}
|
|
8249
8276
|
},
|
|
8250
8277
|
{
|