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/players/index.cjs
CHANGED
|
@@ -3915,7 +3915,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3915
3915
|
_this.showAds = true;
|
|
3916
3916
|
_this.resetGamNoFillCounter();
|
|
3917
3917
|
if (_this.inAdBreak && _this.expectedAdBreakDurationMs != null && _this.adStopTimerId == null) {
|
|
3918
|
-
_this.
|
|
3918
|
+
_this.scheduleAdStopAtBreakBoundary();
|
|
3919
3919
|
if (_this.config.debugAdTiming) {
|
|
3920
3920
|
console.log("[StormcloudVideoPlayer] Starting ad break timer on content_pause (first ad starting)");
|
|
3921
3921
|
}
|
|
@@ -4559,12 +4559,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4559
4559
|
if (marker.durationSeconds != null) {
|
|
4560
4560
|
var newDurationMs = marker.durationSeconds * 1e3;
|
|
4561
4561
|
if (this.expectedAdBreakDurationMs == null || newDurationMs > this.expectedAdBreakDurationMs) {
|
|
4562
|
-
this.
|
|
4563
|
-
|
|
4564
|
-
var remainingMs = Math.max(0, newDurationMs - elapsedMs);
|
|
4565
|
-
this.scheduleAdStopCountdown(remainingMs);
|
|
4562
|
+
this.setAdBreakDurationBoundary(newDurationMs);
|
|
4563
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
4566
4564
|
if (this.config.debugAdTiming) {
|
|
4567
|
-
console.log("[StormcloudVideoPlayer] Updated ad break duration from subsequent marker: ".concat(newDurationMs, "ms, remaining: ").concat(
|
|
4565
|
+
console.log("[StormcloudVideoPlayer] Updated ad break duration from subsequent marker: ".concat(newDurationMs, "ms, remaining: ").concat(this.getRemainingAdMs(), "ms"));
|
|
4568
4566
|
}
|
|
4569
4567
|
}
|
|
4570
4568
|
}
|
|
@@ -4638,13 +4636,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4638
4636
|
}
|
|
4639
4637
|
if (marker.type === "progress" && this.inAdBreak) {
|
|
4640
4638
|
if (marker.durationSeconds != null) {
|
|
4641
|
-
this.
|
|
4642
|
-
}
|
|
4643
|
-
if (this.expectedAdBreakDurationMs != null && this.currentAdBreakStartWallClockMs != null) {
|
|
4644
|
-
var elapsedMs1 = Date.now() - this.currentAdBreakStartWallClockMs;
|
|
4645
|
-
var remainingMs1 = Math.max(0, this.expectedAdBreakDurationMs - elapsedMs1);
|
|
4646
|
-
this.scheduleAdStopCountdown(remainingMs1);
|
|
4639
|
+
this.setAdBreakDurationBoundary(marker.durationSeconds * 1e3);
|
|
4647
4640
|
}
|
|
4641
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
4648
4642
|
if (!this.ima.isAdPlaying() && this.activeAdRequestToken === null && this.adRequestQueue.length > 0) {
|
|
4649
4643
|
this.tryNextAvailableAdWithRateLimit();
|
|
4650
4644
|
}
|
|
@@ -4669,15 +4663,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4669
4663
|
activeAdRequest: this.activeAdRequestToken !== null
|
|
4670
4664
|
});
|
|
4671
4665
|
}
|
|
4672
|
-
|
|
4673
|
-
if (this.config.debugAdTiming) {
|
|
4674
|
-
console.log("[StormcloudVideoPlayer] Ignoring premature SCTE-35 end marker - ads still active");
|
|
4675
|
-
}
|
|
4676
|
-
return;
|
|
4677
|
-
}
|
|
4678
|
-
this.inAdBreak = false;
|
|
4679
|
-
this.expectedAdBreakDurationMs = void 0;
|
|
4680
|
-
this.currentAdBreakStartWallClockMs = void 0;
|
|
4666
|
+
this.scteAdBreakEndWallClockMs = Date.now();
|
|
4681
4667
|
this.clearAdStartTimer();
|
|
4682
4668
|
this.clearAdStopTimer();
|
|
4683
4669
|
if (adPlaying) {
|
|
@@ -4701,12 +4687,46 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4701
4687
|
this.inAdBreak = true;
|
|
4702
4688
|
this.activeScte35BreakKey = cueKey !== null && cueKey !== void 0 ? cueKey : this.pendingScte35CueKey;
|
|
4703
4689
|
this.scheduledScte35BreakKey = void 0;
|
|
4704
|
-
this.
|
|
4705
|
-
this.
|
|
4690
|
+
this.currentAdBreakStartWallClockMs = this.resolveScteBreakStartWallClockMs(marker);
|
|
4691
|
+
this.setAdBreakDurationBoundary(durationMs);
|
|
4706
4692
|
this.handleAdStart(marker);
|
|
4707
|
-
|
|
4708
|
-
|
|
4693
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
4694
|
+
}
|
|
4695
|
+
},
|
|
4696
|
+
{
|
|
4697
|
+
key: "resolveScteBreakStartWallClockMs",
|
|
4698
|
+
value: function resolveScteBreakStartWallClockMs(marker) {
|
|
4699
|
+
var nowWallClockMs = Date.now();
|
|
4700
|
+
if (typeof marker.ptsSeconds !== "number") {
|
|
4701
|
+
return nowWallClockMs;
|
|
4709
4702
|
}
|
|
4703
|
+
var nowMs = this.video.currentTime * 1e3;
|
|
4704
|
+
var estimatedCurrentPtsMs = nowMs - this.ptsDriftEmaMs;
|
|
4705
|
+
var deltaMs = marker.ptsSeconds * 1e3 - estimatedCurrentPtsMs;
|
|
4706
|
+
if (!Number.isFinite(deltaMs)) {
|
|
4707
|
+
return nowWallClockMs;
|
|
4708
|
+
}
|
|
4709
|
+
return nowWallClockMs + Math.floor(deltaMs);
|
|
4710
|
+
}
|
|
4711
|
+
},
|
|
4712
|
+
{
|
|
4713
|
+
key: "setAdBreakDurationBoundary",
|
|
4714
|
+
value: function setAdBreakDurationBoundary(durationMs) {
|
|
4715
|
+
this.expectedAdBreakDurationMs = durationMs;
|
|
4716
|
+
if (durationMs != null && this.currentAdBreakStartWallClockMs != null) {
|
|
4717
|
+
this.scteAdBreakEndWallClockMs = this.currentAdBreakStartWallClockMs + durationMs;
|
|
4718
|
+
} else {
|
|
4719
|
+
this.scteAdBreakEndWallClockMs = void 0;
|
|
4720
|
+
}
|
|
4721
|
+
}
|
|
4722
|
+
},
|
|
4723
|
+
{
|
|
4724
|
+
key: "scheduleAdStopAtBreakBoundary",
|
|
4725
|
+
value: function scheduleAdStopAtBreakBoundary() {
|
|
4726
|
+
if (this.expectedAdBreakDurationMs == null) {
|
|
4727
|
+
return;
|
|
4728
|
+
}
|
|
4729
|
+
this.scheduleAdStopCountdown(this.getRemainingAdMs());
|
|
4710
4730
|
}
|
|
4711
4731
|
},
|
|
4712
4732
|
{
|
|
@@ -6334,7 +6354,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6334
6354
|
}
|
|
6335
6355
|
}
|
|
6336
6356
|
this.inAdBreak = true;
|
|
6337
|
-
this.currentAdBreakStartWallClockMs = Date.now();
|
|
6338
6357
|
this.currentAdIndex = 0;
|
|
6339
6358
|
this.totalAdsInBreak = 1;
|
|
6340
6359
|
this.adPodQueue = [];
|
|
@@ -6421,7 +6440,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6421
6440
|
case 2:
|
|
6422
6441
|
_state.sent();
|
|
6423
6442
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
6424
|
-
this.
|
|
6443
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
6425
6444
|
}
|
|
6426
6445
|
adVolume = currentMuted ? 0 : currentVolume;
|
|
6427
6446
|
this.ima.setAdVolume(adVolume);
|
|
@@ -6464,7 +6483,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6464
6483
|
case 6:
|
|
6465
6484
|
_state.sent();
|
|
6466
6485
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
6467
|
-
this.
|
|
6486
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
6468
6487
|
}
|
|
6469
6488
|
adVolume1 = currentMuted ? 0 : currentVolume;
|
|
6470
6489
|
this.ima.setAdVolume(adVolume1);
|
|
@@ -6519,7 +6538,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6519
6538
|
case 10:
|
|
6520
6539
|
_state.sent();
|
|
6521
6540
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
6522
|
-
this.
|
|
6541
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
6523
6542
|
}
|
|
6524
6543
|
adVolume2 = currentMuted ? 0 : currentVolume;
|
|
6525
6544
|
this.ima.setAdVolume(adVolume2);
|
|
@@ -6871,7 +6890,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6871
6890
|
case 2:
|
|
6872
6891
|
_state.sent();
|
|
6873
6892
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
6874
|
-
this.
|
|
6893
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
6875
6894
|
}
|
|
6876
6895
|
currentMuted = this.video.muted;
|
|
6877
6896
|
currentVolume = this.video.volume;
|
|
@@ -7371,21 +7390,16 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
7371
7390
|
{
|
|
7372
7391
|
key: "ensureAdStoppedByTimer",
|
|
7373
7392
|
value: function ensureAdStoppedByTimer() {
|
|
7374
|
-
var _this_config_adBreakCheckIntervalMs,
|
|
7393
|
+
var _this_config_adBreakCheckIntervalMs, _this_getAdBreakEndWallClockMs;
|
|
7375
7394
|
if (!this.inAdBreak) return;
|
|
7376
7395
|
this.adStopTimerId = void 0;
|
|
7377
7396
|
var adPlaying = this.ima.isAdPlaying();
|
|
7378
|
-
var pendingAds = this.adPodQueue.length > 0;
|
|
7379
7397
|
var checkIntervalMs = Math.max(250, Math.floor((_this_config_adBreakCheckIntervalMs = this.config.adBreakCheckIntervalMs) !== null && _this_config_adBreakCheckIntervalMs !== void 0 ? _this_config_adBreakCheckIntervalMs : 1e3));
|
|
7380
7398
|
var maxExtensionMsConfig = this.config.maxAdBreakExtensionMs;
|
|
7381
|
-
var maxExtensionMs = typeof maxExtensionMsConfig === "number" && maxExtensionMsConfig > 0 ? maxExtensionMsConfig :
|
|
7382
|
-
var
|
|
7383
|
-
|
|
7384
|
-
|
|
7385
|
-
}
|
|
7386
|
-
var expectedDurationMs = (_this_expectedAdBreakDurationMs = this.expectedAdBreakDurationMs) !== null && _this_expectedAdBreakDurationMs !== void 0 ? _this_expectedAdBreakDurationMs : 0;
|
|
7387
|
-
var overrunMs = Math.max(0, elapsedSinceStartMs - expectedDurationMs);
|
|
7388
|
-
var shouldExtendAdBreak = (adPlaying || pendingAds || this.showAds) && overrunMs < maxExtensionMs;
|
|
7399
|
+
var maxExtensionMs = typeof maxExtensionMsConfig === "number" && maxExtensionMsConfig > 0 ? maxExtensionMsConfig : 0;
|
|
7400
|
+
var endWallClockMs = (_this_getAdBreakEndWallClockMs = this.getAdBreakEndWallClockMs()) !== null && _this_getAdBreakEndWallClockMs !== void 0 ? _this_getAdBreakEndWallClockMs : Date.now();
|
|
7401
|
+
var overrunMs = Math.max(0, Date.now() - endWallClockMs);
|
|
7402
|
+
var shouldExtendAdBreak = adPlaying && overrunMs < maxExtensionMs;
|
|
7389
7403
|
if (shouldExtendAdBreak) {
|
|
7390
7404
|
this.scheduleAdStopCountdown(checkIntervalMs);
|
|
7391
7405
|
return;
|
|
@@ -7651,7 +7665,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
7651
7665
|
case 5:
|
|
7652
7666
|
_state.sent();
|
|
7653
7667
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
7654
|
-
this.
|
|
7668
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
7655
7669
|
}
|
|
7656
7670
|
currentMuted = this.video.muted;
|
|
7657
7671
|
currentVolume = this.video.volume;
|
|
@@ -7701,7 +7715,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
7701
7715
|
case 8:
|
|
7702
7716
|
_state.sent();
|
|
7703
7717
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
7704
|
-
this.
|
|
7718
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
7705
7719
|
}
|
|
7706
7720
|
currentMuted1 = this.video.muted;
|
|
7707
7721
|
currentVolume1 = this.video.volume;
|
|
@@ -7846,6 +7860,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
7846
7860
|
this.scheduledScte35BreakKey = void 0;
|
|
7847
7861
|
this.expectedAdBreakDurationMs = void 0;
|
|
7848
7862
|
this.currentAdBreakStartWallClockMs = void 0;
|
|
7863
|
+
this.scteAdBreakEndWallClockMs = void 0;
|
|
7849
7864
|
this.clearAdStartTimer();
|
|
7850
7865
|
this.clearAdStopTimer();
|
|
7851
7866
|
this.adPodQueue = [];
|
|
@@ -8035,9 +8050,21 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
8035
8050
|
{
|
|
8036
8051
|
key: "getRemainingAdMs",
|
|
8037
8052
|
value: function getRemainingAdMs() {
|
|
8038
|
-
|
|
8039
|
-
|
|
8040
|
-
|
|
8053
|
+
var endWallClockMs = this.getAdBreakEndWallClockMs();
|
|
8054
|
+
if (endWallClockMs != null) {
|
|
8055
|
+
return Math.max(0, endWallClockMs - Date.now());
|
|
8056
|
+
}
|
|
8057
|
+
return 0;
|
|
8058
|
+
}
|
|
8059
|
+
},
|
|
8060
|
+
{
|
|
8061
|
+
key: "getAdBreakEndWallClockMs",
|
|
8062
|
+
value: function getAdBreakEndWallClockMs() {
|
|
8063
|
+
if (this.scteAdBreakEndWallClockMs != null) {
|
|
8064
|
+
return this.scteAdBreakEndWallClockMs;
|
|
8065
|
+
}
|
|
8066
|
+
if (this.expectedAdBreakDurationMs == null || this.currentAdBreakStartWallClockMs == null) return void 0;
|
|
8067
|
+
return this.currentAdBreakStartWallClockMs + this.expectedAdBreakDurationMs;
|
|
8041
8068
|
}
|
|
8042
8069
|
},
|
|
8043
8070
|
{
|