stormcloud-video-player 0.8.15 → 0.8.16
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 +70 -42
- 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 +70 -42
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +70 -42
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/player/StormcloudVideoPlayer.d.cts +5 -0
- package/lib/players/HlsPlayer.cjs +70 -42
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/index.cjs +70 -42
- package/lib/players/index.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +70 -42
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/package.json +1 -1
|
@@ -3557,7 +3557,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3557
3557
|
_this.showAds = true;
|
|
3558
3558
|
_this.resetGamNoFillCounter();
|
|
3559
3559
|
if (_this.inAdBreak && _this.expectedAdBreakDurationMs != null && _this.adStopTimerId == null) {
|
|
3560
|
-
_this.
|
|
3560
|
+
_this.scheduleAdStopAtBreakBoundary();
|
|
3561
3561
|
if (_this.config.debugAdTiming) {
|
|
3562
3562
|
console.log("[StormcloudVideoPlayer] Starting ad break timer on content_pause (first ad starting)");
|
|
3563
3563
|
}
|
|
@@ -4212,12 +4212,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4212
4212
|
if (marker.durationSeconds != null) {
|
|
4213
4213
|
var newDurationMs = marker.durationSeconds * 1e3;
|
|
4214
4214
|
if (this.expectedAdBreakDurationMs == null || newDurationMs > this.expectedAdBreakDurationMs) {
|
|
4215
|
-
this.
|
|
4216
|
-
|
|
4217
|
-
var remainingMs = Math.max(0, newDurationMs - elapsedMs);
|
|
4218
|
-
this.scheduleAdStopCountdown(remainingMs);
|
|
4215
|
+
this.setAdBreakDurationBoundary(newDurationMs);
|
|
4216
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
4219
4217
|
if (this.config.debugAdTiming) {
|
|
4220
|
-
console.log("[StormcloudVideoPlayer] Updated ad break duration from subsequent marker: ".concat(newDurationMs, "ms, remaining: ").concat(
|
|
4218
|
+
console.log("[StormcloudVideoPlayer] Updated ad break duration from subsequent marker: ".concat(newDurationMs, "ms, remaining: ").concat(this.getWallClockRemainingAdMs(), "ms"));
|
|
4221
4219
|
}
|
|
4222
4220
|
}
|
|
4223
4221
|
}
|
|
@@ -4291,13 +4289,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4291
4289
|
}
|
|
4292
4290
|
if (marker.type === "progress" && this.inAdBreak) {
|
|
4293
4291
|
if (marker.durationSeconds != null) {
|
|
4294
|
-
this.
|
|
4295
|
-
}
|
|
4296
|
-
if (this.expectedAdBreakDurationMs != null && this.currentAdBreakStartWallClockMs != null) {
|
|
4297
|
-
var elapsedMs1 = Date.now() - this.currentAdBreakStartWallClockMs;
|
|
4298
|
-
var remainingMs1 = Math.max(0, this.expectedAdBreakDurationMs - elapsedMs1);
|
|
4299
|
-
this.scheduleAdStopCountdown(remainingMs1);
|
|
4292
|
+
this.setAdBreakDurationBoundary(marker.durationSeconds * 1e3);
|
|
4300
4293
|
}
|
|
4294
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
4301
4295
|
if (!this.adPlayer.isAdPlaying() && this.activeAdRequestToken === null && this.adRequestQueue.length > 0 && this.hasTimeToStartAnotherAd()) {
|
|
4302
4296
|
this.tryNextAvailableAdWithRateLimit();
|
|
4303
4297
|
}
|
|
@@ -4321,15 +4315,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4321
4315
|
activeAdRequest: this.activeAdRequestToken !== null
|
|
4322
4316
|
});
|
|
4323
4317
|
}
|
|
4324
|
-
|
|
4325
|
-
if (this.config.debugAdTiming) {
|
|
4326
|
-
console.log("[StormcloudVideoPlayer] Ignoring premature SCTE-35 end marker - ads still active");
|
|
4327
|
-
}
|
|
4328
|
-
return;
|
|
4329
|
-
}
|
|
4330
|
-
this.inAdBreak = false;
|
|
4331
|
-
this.expectedAdBreakDurationMs = void 0;
|
|
4332
|
-
this.currentAdBreakStartWallClockMs = void 0;
|
|
4318
|
+
this.scteAdBreakEndWallClockMs = Date.now();
|
|
4333
4319
|
this.clearAdStartTimer();
|
|
4334
4320
|
this.clearAdStopTimer();
|
|
4335
4321
|
if (adPlaying) {
|
|
@@ -4346,14 +4332,48 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4346
4332
|
this.inAdBreak = true;
|
|
4347
4333
|
this.activeScte35BreakKey = cueKey !== null && cueKey !== void 0 ? cueKey : this.pendingScte35CueKey;
|
|
4348
4334
|
this.scheduledScte35BreakKey = void 0;
|
|
4349
|
-
this.
|
|
4350
|
-
this.
|
|
4335
|
+
this.currentAdBreakStartWallClockMs = this.resolveScteBreakStartWallClockMs(marker);
|
|
4336
|
+
this.setAdBreakDurationBoundary(durationMs);
|
|
4351
4337
|
this.handleAdStart(marker);
|
|
4352
|
-
|
|
4353
|
-
|
|
4338
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
4339
|
+
}
|
|
4340
|
+
},
|
|
4341
|
+
{
|
|
4342
|
+
key: "resolveScteBreakStartWallClockMs",
|
|
4343
|
+
value: function resolveScteBreakStartWallClockMs(marker) {
|
|
4344
|
+
var nowWallClockMs = Date.now();
|
|
4345
|
+
if (typeof marker.ptsSeconds !== "number") {
|
|
4346
|
+
return nowWallClockMs;
|
|
4347
|
+
}
|
|
4348
|
+
var nowMs = this.video.currentTime * 1e3;
|
|
4349
|
+
var estimatedCurrentPtsMs = nowMs - this.ptsDriftEmaMs;
|
|
4350
|
+
var deltaMs = marker.ptsSeconds * 1e3 - estimatedCurrentPtsMs;
|
|
4351
|
+
if (!Number.isFinite(deltaMs)) {
|
|
4352
|
+
return nowWallClockMs;
|
|
4353
|
+
}
|
|
4354
|
+
return nowWallClockMs + Math.floor(deltaMs);
|
|
4355
|
+
}
|
|
4356
|
+
},
|
|
4357
|
+
{
|
|
4358
|
+
key: "setAdBreakDurationBoundary",
|
|
4359
|
+
value: function setAdBreakDurationBoundary(durationMs) {
|
|
4360
|
+
this.expectedAdBreakDurationMs = durationMs;
|
|
4361
|
+
if (durationMs != null && this.currentAdBreakStartWallClockMs != null) {
|
|
4362
|
+
this.scteAdBreakEndWallClockMs = this.currentAdBreakStartWallClockMs + durationMs;
|
|
4363
|
+
} else {
|
|
4364
|
+
this.scteAdBreakEndWallClockMs = void 0;
|
|
4354
4365
|
}
|
|
4355
4366
|
}
|
|
4356
4367
|
},
|
|
4368
|
+
{
|
|
4369
|
+
key: "scheduleAdStopAtBreakBoundary",
|
|
4370
|
+
value: function scheduleAdStopAtBreakBoundary() {
|
|
4371
|
+
if (this.expectedAdBreakDurationMs == null) {
|
|
4372
|
+
return;
|
|
4373
|
+
}
|
|
4374
|
+
this.scheduleAdStopCountdown(this.getWallClockRemainingAdMs());
|
|
4375
|
+
}
|
|
4376
|
+
},
|
|
4357
4377
|
{
|
|
4358
4378
|
key: "parseCueOutDuration",
|
|
4359
4379
|
value: function parseCueOutDuration(value) {
|
|
@@ -6001,7 +6021,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6001
6021
|
currentVolume = this.video.volume;
|
|
6002
6022
|
this.adPlayer.updateOriginalMutedState(currentMuted, currentVolume);
|
|
6003
6023
|
this.inAdBreak = true;
|
|
6004
|
-
this.currentAdBreakStartWallClockMs = Date.now();
|
|
6005
6024
|
this.adBreakPlayedDurationMs = 0;
|
|
6006
6025
|
this.currentAdIndex = 0;
|
|
6007
6026
|
this.totalAdsInBreak = 0;
|
|
@@ -6107,7 +6126,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6107
6126
|
_state.sent();
|
|
6108
6127
|
this.markAdStarted();
|
|
6109
6128
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
6110
|
-
this.
|
|
6129
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
6111
6130
|
}
|
|
6112
6131
|
adVolume = currentMuted ? 0 : currentVolume;
|
|
6113
6132
|
this.adPlayer.setAdVolume(adVolume);
|
|
@@ -6167,7 +6186,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6167
6186
|
_state.sent();
|
|
6168
6187
|
this.markAdStarted();
|
|
6169
6188
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
6170
|
-
this.
|
|
6189
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
6171
6190
|
}
|
|
6172
6191
|
adVolume1 = currentMuted ? 0 : currentVolume;
|
|
6173
6192
|
this.adPlayer.setAdVolume(adVolume1);
|
|
@@ -6240,7 +6259,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6240
6259
|
_state.sent();
|
|
6241
6260
|
this.markAdStarted();
|
|
6242
6261
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
6243
|
-
this.
|
|
6262
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
6244
6263
|
}
|
|
6245
6264
|
adVolume2 = currentMuted ? 0 : currentVolume;
|
|
6246
6265
|
this.adPlayer.setAdVolume(adVolume2);
|
|
@@ -6623,7 +6642,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6623
6642
|
_state.sent();
|
|
6624
6643
|
this.markAdStarted();
|
|
6625
6644
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
6626
|
-
this.
|
|
6645
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
6627
6646
|
}
|
|
6628
6647
|
this.adPlayer.setAdVolume(this.getAdAudioVolume());
|
|
6629
6648
|
this.consecutiveFailures = 0;
|
|
@@ -7151,19 +7170,15 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
7151
7170
|
{
|
|
7152
7171
|
key: "ensureAdStoppedByTimer",
|
|
7153
7172
|
value: function ensureAdStoppedByTimer() {
|
|
7154
|
-
var _this_config_adBreakCheckIntervalMs,
|
|
7173
|
+
var _this_config_adBreakCheckIntervalMs, _this_getAdBreakEndWallClockMs;
|
|
7155
7174
|
if (!this.inAdBreak) return;
|
|
7156
7175
|
this.adStopTimerId = void 0;
|
|
7157
7176
|
var adPlaying = this.adPlayer.isAdPlaying();
|
|
7158
7177
|
var checkIntervalMs = Math.max(250, Math.floor((_this_config_adBreakCheckIntervalMs = this.config.adBreakCheckIntervalMs) !== null && _this_config_adBreakCheckIntervalMs !== void 0 ? _this_config_adBreakCheckIntervalMs : 1e3));
|
|
7159
7178
|
var maxExtensionMsConfig = this.config.maxAdBreakExtensionMs;
|
|
7160
7179
|
var maxExtensionMs = typeof maxExtensionMsConfig === "number" && maxExtensionMsConfig > 0 ? maxExtensionMsConfig : 0;
|
|
7161
|
-
var
|
|
7162
|
-
|
|
7163
|
-
elapsedSinceStartMs = Date.now() - this.currentAdBreakStartWallClockMs;
|
|
7164
|
-
}
|
|
7165
|
-
var expectedDurationMs = (_this_expectedAdBreakDurationMs = this.expectedAdBreakDurationMs) !== null && _this_expectedAdBreakDurationMs !== void 0 ? _this_expectedAdBreakDurationMs : 0;
|
|
7166
|
-
var overrunMs = Math.max(0, elapsedSinceStartMs - expectedDurationMs);
|
|
7180
|
+
var endWallClockMs = (_this_getAdBreakEndWallClockMs = this.getAdBreakEndWallClockMs()) !== null && _this_getAdBreakEndWallClockMs !== void 0 ? _this_getAdBreakEndWallClockMs : Date.now();
|
|
7181
|
+
var overrunMs = Math.max(0, Date.now() - endWallClockMs);
|
|
7167
7182
|
var shouldExtendAdBreak = adPlaying && overrunMs < maxExtensionMs;
|
|
7168
7183
|
if (shouldExtendAdBreak) {
|
|
7169
7184
|
this.scheduleAdStopCountdown(checkIntervalMs);
|
|
@@ -7439,7 +7454,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
7439
7454
|
_state.sent();
|
|
7440
7455
|
this.markAdStarted();
|
|
7441
7456
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
7442
|
-
this.
|
|
7457
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
7443
7458
|
}
|
|
7444
7459
|
this.adPlayer.setAdVolume(this.getAdAudioVolume());
|
|
7445
7460
|
this.consecutiveFailures = 0;
|
|
@@ -7491,7 +7506,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
7491
7506
|
_state.sent();
|
|
7492
7507
|
this.markAdStarted();
|
|
7493
7508
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
7494
|
-
this.
|
|
7509
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
7495
7510
|
}
|
|
7496
7511
|
this.adPlayer.setAdVolume(this.getAdAudioVolume());
|
|
7497
7512
|
return [
|
|
@@ -7637,6 +7652,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
7637
7652
|
this.scheduledScte35BreakKey = void 0;
|
|
7638
7653
|
this.expectedAdBreakDurationMs = void 0;
|
|
7639
7654
|
this.currentAdBreakStartWallClockMs = void 0;
|
|
7655
|
+
this.scteAdBreakEndWallClockMs = void 0;
|
|
7640
7656
|
this.clearAdStartTimer();
|
|
7641
7657
|
this.clearAdStopTimer();
|
|
7642
7658
|
this.adPodQueue = [];
|
|
@@ -7824,11 +7840,23 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
7824
7840
|
{
|
|
7825
7841
|
key: "getWallClockRemainingAdMs",
|
|
7826
7842
|
value: function getWallClockRemainingAdMs() {
|
|
7843
|
+
var endWallClockMs = this.getAdBreakEndWallClockMs();
|
|
7844
|
+
if (endWallClockMs != null) {
|
|
7845
|
+
return Math.max(0, endWallClockMs - Date.now());
|
|
7846
|
+
}
|
|
7847
|
+
return 0;
|
|
7848
|
+
}
|
|
7849
|
+
},
|
|
7850
|
+
{
|
|
7851
|
+
key: "getAdBreakEndWallClockMs",
|
|
7852
|
+
value: function getAdBreakEndWallClockMs() {
|
|
7853
|
+
if (this.scteAdBreakEndWallClockMs != null) {
|
|
7854
|
+
return this.scteAdBreakEndWallClockMs;
|
|
7855
|
+
}
|
|
7827
7856
|
if (this.expectedAdBreakDurationMs == null || this.currentAdBreakStartWallClockMs == null) {
|
|
7828
|
-
return 0;
|
|
7857
|
+
return void 0;
|
|
7829
7858
|
}
|
|
7830
|
-
|
|
7831
|
-
return Math.max(0, this.expectedAdBreakDurationMs - elapsed);
|
|
7859
|
+
return this.currentAdBreakStartWallClockMs + this.expectedAdBreakDurationMs;
|
|
7832
7860
|
}
|
|
7833
7861
|
},
|
|
7834
7862
|
{
|