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
package/lib/index.d.cts
CHANGED
|
@@ -151,6 +151,7 @@ declare class StormcloudVideoPlayer {
|
|
|
151
151
|
private inAdBreak;
|
|
152
152
|
private currentAdBreakStartWallClockMs;
|
|
153
153
|
private expectedAdBreakDurationMs;
|
|
154
|
+
private scteAdBreakEndWallClockMs;
|
|
154
155
|
private adStopTimerId;
|
|
155
156
|
private adStartTimerId;
|
|
156
157
|
private adFailsafeTimerId;
|
|
@@ -257,6 +258,9 @@ declare class StormcloudVideoPlayer {
|
|
|
257
258
|
private activatePendingScte35CuesForFragment;
|
|
258
259
|
private onScte35Marker;
|
|
259
260
|
private startScte35AdBreak;
|
|
261
|
+
private resolveScteBreakStartWallClockMs;
|
|
262
|
+
private setAdBreakDurationBoundary;
|
|
263
|
+
private scheduleAdStopAtBreakBoundary;
|
|
260
264
|
private parseCueOutDuration;
|
|
261
265
|
private parseCueOutCont;
|
|
262
266
|
private parseAttributeList;
|
|
@@ -340,6 +344,7 @@ declare class StormcloudVideoPlayer {
|
|
|
340
344
|
private selectVastTagsForBreak;
|
|
341
345
|
private logAdState;
|
|
342
346
|
private getWallClockRemainingAdMs;
|
|
347
|
+
private getAdBreakEndWallClockMs;
|
|
343
348
|
private getDurationBudgetRemainingMs;
|
|
344
349
|
private getLoadedAdDurationMs;
|
|
345
350
|
private adFitsRemainingBudget;
|
package/lib/index.d.ts
CHANGED
|
@@ -151,6 +151,7 @@ declare class StormcloudVideoPlayer {
|
|
|
151
151
|
private inAdBreak;
|
|
152
152
|
private currentAdBreakStartWallClockMs;
|
|
153
153
|
private expectedAdBreakDurationMs;
|
|
154
|
+
private scteAdBreakEndWallClockMs;
|
|
154
155
|
private adStopTimerId;
|
|
155
156
|
private adStartTimerId;
|
|
156
157
|
private adFailsafeTimerId;
|
|
@@ -257,6 +258,9 @@ declare class StormcloudVideoPlayer {
|
|
|
257
258
|
private activatePendingScte35CuesForFragment;
|
|
258
259
|
private onScte35Marker;
|
|
259
260
|
private startScte35AdBreak;
|
|
261
|
+
private resolveScteBreakStartWallClockMs;
|
|
262
|
+
private setAdBreakDurationBoundary;
|
|
263
|
+
private scheduleAdStopAtBreakBoundary;
|
|
260
264
|
private parseCueOutDuration;
|
|
261
265
|
private parseCueOutCont;
|
|
262
266
|
private parseAttributeList;
|
|
@@ -340,6 +344,7 @@ declare class StormcloudVideoPlayer {
|
|
|
340
344
|
private selectVastTagsForBreak;
|
|
341
345
|
private logAdState;
|
|
342
346
|
private getWallClockRemainingAdMs;
|
|
347
|
+
private getAdBreakEndWallClockMs;
|
|
343
348
|
private getDurationBudgetRemainingMs;
|
|
344
349
|
private getLoadedAdDurationMs;
|
|
345
350
|
private adFitsRemainingBudget;
|
package/lib/index.js
CHANGED
|
@@ -3591,7 +3591,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3591
3591
|
_this.showAds = true;
|
|
3592
3592
|
_this.resetGamNoFillCounter();
|
|
3593
3593
|
if (_this.inAdBreak && _this.expectedAdBreakDurationMs != null && _this.adStopTimerId == null) {
|
|
3594
|
-
_this.
|
|
3594
|
+
_this.scheduleAdStopAtBreakBoundary();
|
|
3595
3595
|
if (_this.config.debugAdTiming) {
|
|
3596
3596
|
console.log("[StormcloudVideoPlayer] Starting ad break timer on content_pause (first ad starting)");
|
|
3597
3597
|
}
|
|
@@ -4246,12 +4246,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4246
4246
|
if (marker.durationSeconds != null) {
|
|
4247
4247
|
var newDurationMs = marker.durationSeconds * 1e3;
|
|
4248
4248
|
if (this.expectedAdBreakDurationMs == null || newDurationMs > this.expectedAdBreakDurationMs) {
|
|
4249
|
-
this.
|
|
4250
|
-
|
|
4251
|
-
var remainingMs = Math.max(0, newDurationMs - elapsedMs);
|
|
4252
|
-
this.scheduleAdStopCountdown(remainingMs);
|
|
4249
|
+
this.setAdBreakDurationBoundary(newDurationMs);
|
|
4250
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
4253
4251
|
if (this.config.debugAdTiming) {
|
|
4254
|
-
console.log("[StormcloudVideoPlayer] Updated ad break duration from subsequent marker: ".concat(newDurationMs, "ms, remaining: ").concat(
|
|
4252
|
+
console.log("[StormcloudVideoPlayer] Updated ad break duration from subsequent marker: ".concat(newDurationMs, "ms, remaining: ").concat(this.getWallClockRemainingAdMs(), "ms"));
|
|
4255
4253
|
}
|
|
4256
4254
|
}
|
|
4257
4255
|
}
|
|
@@ -4325,13 +4323,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4325
4323
|
}
|
|
4326
4324
|
if (marker.type === "progress" && this.inAdBreak) {
|
|
4327
4325
|
if (marker.durationSeconds != null) {
|
|
4328
|
-
this.
|
|
4329
|
-
}
|
|
4330
|
-
if (this.expectedAdBreakDurationMs != null && this.currentAdBreakStartWallClockMs != null) {
|
|
4331
|
-
var elapsedMs1 = Date.now() - this.currentAdBreakStartWallClockMs;
|
|
4332
|
-
var remainingMs1 = Math.max(0, this.expectedAdBreakDurationMs - elapsedMs1);
|
|
4333
|
-
this.scheduleAdStopCountdown(remainingMs1);
|
|
4326
|
+
this.setAdBreakDurationBoundary(marker.durationSeconds * 1e3);
|
|
4334
4327
|
}
|
|
4328
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
4335
4329
|
if (!this.adPlayer.isAdPlaying() && this.activeAdRequestToken === null && this.adRequestQueue.length > 0 && this.hasTimeToStartAnotherAd()) {
|
|
4336
4330
|
this.tryNextAvailableAdWithRateLimit();
|
|
4337
4331
|
}
|
|
@@ -4355,15 +4349,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4355
4349
|
activeAdRequest: this.activeAdRequestToken !== null
|
|
4356
4350
|
});
|
|
4357
4351
|
}
|
|
4358
|
-
|
|
4359
|
-
if (this.config.debugAdTiming) {
|
|
4360
|
-
console.log("[StormcloudVideoPlayer] Ignoring premature SCTE-35 end marker - ads still active");
|
|
4361
|
-
}
|
|
4362
|
-
return;
|
|
4363
|
-
}
|
|
4364
|
-
this.inAdBreak = false;
|
|
4365
|
-
this.expectedAdBreakDurationMs = void 0;
|
|
4366
|
-
this.currentAdBreakStartWallClockMs = void 0;
|
|
4352
|
+
this.scteAdBreakEndWallClockMs = Date.now();
|
|
4367
4353
|
this.clearAdStartTimer();
|
|
4368
4354
|
this.clearAdStopTimer();
|
|
4369
4355
|
if (adPlaying) {
|
|
@@ -4380,14 +4366,48 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4380
4366
|
this.inAdBreak = true;
|
|
4381
4367
|
this.activeScte35BreakKey = cueKey !== null && cueKey !== void 0 ? cueKey : this.pendingScte35CueKey;
|
|
4382
4368
|
this.scheduledScte35BreakKey = void 0;
|
|
4383
|
-
this.
|
|
4384
|
-
this.
|
|
4369
|
+
this.currentAdBreakStartWallClockMs = this.resolveScteBreakStartWallClockMs(marker);
|
|
4370
|
+
this.setAdBreakDurationBoundary(durationMs);
|
|
4385
4371
|
this.handleAdStart(marker);
|
|
4386
|
-
|
|
4387
|
-
|
|
4372
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
4373
|
+
}
|
|
4374
|
+
},
|
|
4375
|
+
{
|
|
4376
|
+
key: "resolveScteBreakStartWallClockMs",
|
|
4377
|
+
value: function resolveScteBreakStartWallClockMs(marker) {
|
|
4378
|
+
var nowWallClockMs = Date.now();
|
|
4379
|
+
if (typeof marker.ptsSeconds !== "number") {
|
|
4380
|
+
return nowWallClockMs;
|
|
4381
|
+
}
|
|
4382
|
+
var nowMs = this.video.currentTime * 1e3;
|
|
4383
|
+
var estimatedCurrentPtsMs = nowMs - this.ptsDriftEmaMs;
|
|
4384
|
+
var deltaMs = marker.ptsSeconds * 1e3 - estimatedCurrentPtsMs;
|
|
4385
|
+
if (!Number.isFinite(deltaMs)) {
|
|
4386
|
+
return nowWallClockMs;
|
|
4387
|
+
}
|
|
4388
|
+
return nowWallClockMs + Math.floor(deltaMs);
|
|
4389
|
+
}
|
|
4390
|
+
},
|
|
4391
|
+
{
|
|
4392
|
+
key: "setAdBreakDurationBoundary",
|
|
4393
|
+
value: function setAdBreakDurationBoundary(durationMs) {
|
|
4394
|
+
this.expectedAdBreakDurationMs = durationMs;
|
|
4395
|
+
if (durationMs != null && this.currentAdBreakStartWallClockMs != null) {
|
|
4396
|
+
this.scteAdBreakEndWallClockMs = this.currentAdBreakStartWallClockMs + durationMs;
|
|
4397
|
+
} else {
|
|
4398
|
+
this.scteAdBreakEndWallClockMs = void 0;
|
|
4388
4399
|
}
|
|
4389
4400
|
}
|
|
4390
4401
|
},
|
|
4402
|
+
{
|
|
4403
|
+
key: "scheduleAdStopAtBreakBoundary",
|
|
4404
|
+
value: function scheduleAdStopAtBreakBoundary() {
|
|
4405
|
+
if (this.expectedAdBreakDurationMs == null) {
|
|
4406
|
+
return;
|
|
4407
|
+
}
|
|
4408
|
+
this.scheduleAdStopCountdown(this.getWallClockRemainingAdMs());
|
|
4409
|
+
}
|
|
4410
|
+
},
|
|
4391
4411
|
{
|
|
4392
4412
|
key: "parseCueOutDuration",
|
|
4393
4413
|
value: function parseCueOutDuration(value) {
|
|
@@ -6035,7 +6055,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6035
6055
|
currentVolume = this.video.volume;
|
|
6036
6056
|
this.adPlayer.updateOriginalMutedState(currentMuted, currentVolume);
|
|
6037
6057
|
this.inAdBreak = true;
|
|
6038
|
-
this.currentAdBreakStartWallClockMs = Date.now();
|
|
6039
6058
|
this.adBreakPlayedDurationMs = 0;
|
|
6040
6059
|
this.currentAdIndex = 0;
|
|
6041
6060
|
this.totalAdsInBreak = 0;
|
|
@@ -6141,7 +6160,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6141
6160
|
_state.sent();
|
|
6142
6161
|
this.markAdStarted();
|
|
6143
6162
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
6144
|
-
this.
|
|
6163
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
6145
6164
|
}
|
|
6146
6165
|
adVolume = currentMuted ? 0 : currentVolume;
|
|
6147
6166
|
this.adPlayer.setAdVolume(adVolume);
|
|
@@ -6201,7 +6220,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6201
6220
|
_state.sent();
|
|
6202
6221
|
this.markAdStarted();
|
|
6203
6222
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
6204
|
-
this.
|
|
6223
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
6205
6224
|
}
|
|
6206
6225
|
adVolume1 = currentMuted ? 0 : currentVolume;
|
|
6207
6226
|
this.adPlayer.setAdVolume(adVolume1);
|
|
@@ -6274,7 +6293,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6274
6293
|
_state.sent();
|
|
6275
6294
|
this.markAdStarted();
|
|
6276
6295
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
6277
|
-
this.
|
|
6296
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
6278
6297
|
}
|
|
6279
6298
|
adVolume2 = currentMuted ? 0 : currentVolume;
|
|
6280
6299
|
this.adPlayer.setAdVolume(adVolume2);
|
|
@@ -6657,7 +6676,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6657
6676
|
_state.sent();
|
|
6658
6677
|
this.markAdStarted();
|
|
6659
6678
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
6660
|
-
this.
|
|
6679
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
6661
6680
|
}
|
|
6662
6681
|
this.adPlayer.setAdVolume(this.getAdAudioVolume());
|
|
6663
6682
|
this.consecutiveFailures = 0;
|
|
@@ -7185,19 +7204,15 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
7185
7204
|
{
|
|
7186
7205
|
key: "ensureAdStoppedByTimer",
|
|
7187
7206
|
value: function ensureAdStoppedByTimer() {
|
|
7188
|
-
var _this_config_adBreakCheckIntervalMs,
|
|
7207
|
+
var _this_config_adBreakCheckIntervalMs, _this_getAdBreakEndWallClockMs;
|
|
7189
7208
|
if (!this.inAdBreak) return;
|
|
7190
7209
|
this.adStopTimerId = void 0;
|
|
7191
7210
|
var adPlaying = this.adPlayer.isAdPlaying();
|
|
7192
7211
|
var checkIntervalMs = Math.max(250, Math.floor((_this_config_adBreakCheckIntervalMs = this.config.adBreakCheckIntervalMs) !== null && _this_config_adBreakCheckIntervalMs !== void 0 ? _this_config_adBreakCheckIntervalMs : 1e3));
|
|
7193
7212
|
var maxExtensionMsConfig = this.config.maxAdBreakExtensionMs;
|
|
7194
7213
|
var maxExtensionMs = typeof maxExtensionMsConfig === "number" && maxExtensionMsConfig > 0 ? maxExtensionMsConfig : 0;
|
|
7195
|
-
var
|
|
7196
|
-
|
|
7197
|
-
elapsedSinceStartMs = Date.now() - this.currentAdBreakStartWallClockMs;
|
|
7198
|
-
}
|
|
7199
|
-
var expectedDurationMs = (_this_expectedAdBreakDurationMs = this.expectedAdBreakDurationMs) !== null && _this_expectedAdBreakDurationMs !== void 0 ? _this_expectedAdBreakDurationMs : 0;
|
|
7200
|
-
var overrunMs = Math.max(0, elapsedSinceStartMs - expectedDurationMs);
|
|
7214
|
+
var endWallClockMs = (_this_getAdBreakEndWallClockMs = this.getAdBreakEndWallClockMs()) !== null && _this_getAdBreakEndWallClockMs !== void 0 ? _this_getAdBreakEndWallClockMs : Date.now();
|
|
7215
|
+
var overrunMs = Math.max(0, Date.now() - endWallClockMs);
|
|
7201
7216
|
var shouldExtendAdBreak = adPlaying && overrunMs < maxExtensionMs;
|
|
7202
7217
|
if (shouldExtendAdBreak) {
|
|
7203
7218
|
this.scheduleAdStopCountdown(checkIntervalMs);
|
|
@@ -7473,7 +7488,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
7473
7488
|
_state.sent();
|
|
7474
7489
|
this.markAdStarted();
|
|
7475
7490
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
7476
|
-
this.
|
|
7491
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
7477
7492
|
}
|
|
7478
7493
|
this.adPlayer.setAdVolume(this.getAdAudioVolume());
|
|
7479
7494
|
this.consecutiveFailures = 0;
|
|
@@ -7525,7 +7540,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
7525
7540
|
_state.sent();
|
|
7526
7541
|
this.markAdStarted();
|
|
7527
7542
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
7528
|
-
this.
|
|
7543
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
7529
7544
|
}
|
|
7530
7545
|
this.adPlayer.setAdVolume(this.getAdAudioVolume());
|
|
7531
7546
|
return [
|
|
@@ -7671,6 +7686,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
7671
7686
|
this.scheduledScte35BreakKey = void 0;
|
|
7672
7687
|
this.expectedAdBreakDurationMs = void 0;
|
|
7673
7688
|
this.currentAdBreakStartWallClockMs = void 0;
|
|
7689
|
+
this.scteAdBreakEndWallClockMs = void 0;
|
|
7674
7690
|
this.clearAdStartTimer();
|
|
7675
7691
|
this.clearAdStopTimer();
|
|
7676
7692
|
this.adPodQueue = [];
|
|
@@ -7858,11 +7874,23 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
7858
7874
|
{
|
|
7859
7875
|
key: "getWallClockRemainingAdMs",
|
|
7860
7876
|
value: function getWallClockRemainingAdMs() {
|
|
7877
|
+
var endWallClockMs = this.getAdBreakEndWallClockMs();
|
|
7878
|
+
if (endWallClockMs != null) {
|
|
7879
|
+
return Math.max(0, endWallClockMs - Date.now());
|
|
7880
|
+
}
|
|
7881
|
+
return 0;
|
|
7882
|
+
}
|
|
7883
|
+
},
|
|
7884
|
+
{
|
|
7885
|
+
key: "getAdBreakEndWallClockMs",
|
|
7886
|
+
value: function getAdBreakEndWallClockMs() {
|
|
7887
|
+
if (this.scteAdBreakEndWallClockMs != null) {
|
|
7888
|
+
return this.scteAdBreakEndWallClockMs;
|
|
7889
|
+
}
|
|
7861
7890
|
if (this.expectedAdBreakDurationMs == null || this.currentAdBreakStartWallClockMs == null) {
|
|
7862
|
-
return 0;
|
|
7891
|
+
return void 0;
|
|
7863
7892
|
}
|
|
7864
|
-
|
|
7865
|
-
return Math.max(0, this.expectedAdBreakDurationMs - elapsed);
|
|
7893
|
+
return this.currentAdBreakStartWallClockMs + this.expectedAdBreakDurationMs;
|
|
7866
7894
|
}
|
|
7867
7895
|
},
|
|
7868
7896
|
{
|