stormcloud-video-player 0.6.13 → 0.6.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 +81 -49
- 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 +81 -49
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +81 -49
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/player/StormcloudVideoPlayer.d.cts +5 -0
- package/lib/players/HlsPlayer.cjs +81 -49
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/index.cjs +81 -49
- package/lib/players/index.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +81 -49
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/package.json +1 -1
|
@@ -3768,7 +3768,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3768
3768
|
_this.adLayer.showPlaceholder();
|
|
3769
3769
|
}
|
|
3770
3770
|
if (_this.inAdBreak && _this.expectedAdBreakDurationMs != null && _this.adStopTimerId == null) {
|
|
3771
|
-
_this.
|
|
3771
|
+
_this.scheduleAdStopAtBreakBoundary();
|
|
3772
3772
|
if (_this.config.debugAdTiming) {
|
|
3773
3773
|
console.log("[StormcloudVideoPlayer] Starting ad break timer on content_pause (first ad starting)");
|
|
3774
3774
|
}
|
|
@@ -4202,12 +4202,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4202
4202
|
if (marker.durationSeconds != null) {
|
|
4203
4203
|
var newDurationMs = marker.durationSeconds * 1e3;
|
|
4204
4204
|
if (this.expectedAdBreakDurationMs == null || newDurationMs > this.expectedAdBreakDurationMs) {
|
|
4205
|
-
this.
|
|
4206
|
-
|
|
4207
|
-
var remainingMs = Math.max(0, newDurationMs - elapsedMs);
|
|
4208
|
-
this.scheduleAdStopCountdown(remainingMs);
|
|
4205
|
+
this.setAdBreakDurationBoundary(newDurationMs);
|
|
4206
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
4209
4207
|
if (this.config.debugAdTiming) {
|
|
4210
|
-
console.log("[StormcloudVideoPlayer] Updated ad break duration from subsequent marker: ".concat(newDurationMs, "ms, remaining: ").concat(
|
|
4208
|
+
console.log("[StormcloudVideoPlayer] Updated ad break duration from subsequent marker: ".concat(newDurationMs, "ms, remaining: ").concat(this.getRemainingAdMs(), "ms"));
|
|
4211
4209
|
}
|
|
4212
4210
|
}
|
|
4213
4211
|
}
|
|
@@ -4215,8 +4213,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4215
4213
|
}
|
|
4216
4214
|
this.inAdBreak = true;
|
|
4217
4215
|
var durationMs = marker.durationSeconds != null ? marker.durationSeconds * 1e3 : ((_this_pendingAdBreak = this.pendingAdBreak) === null || _this_pendingAdBreak === void 0 ? void 0 : _this_pendingAdBreak.marker.durationSeconds) != null ? this.pendingAdBreak.marker.durationSeconds * 1e3 : void 0;
|
|
4218
|
-
this.
|
|
4219
|
-
this.
|
|
4216
|
+
this.currentAdBreakStartWallClockMs = this.resolveScteBreakStartWallClockMs(marker);
|
|
4217
|
+
this.setAdBreakDurationBoundary(durationMs);
|
|
4220
4218
|
if (this.config.licenseKey) {
|
|
4221
4219
|
var _this_pendingAdBreak1;
|
|
4222
4220
|
var adDetectInfo = _object_spread({
|
|
@@ -4280,20 +4278,14 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4280
4278
|
this.clearAdStartTimer();
|
|
4281
4279
|
this.handleAdStart(marker);
|
|
4282
4280
|
}
|
|
4283
|
-
|
|
4284
|
-
this.scheduleAdStopCountdown(this.expectedAdBreakDurationMs);
|
|
4285
|
-
}
|
|
4281
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
4286
4282
|
return;
|
|
4287
4283
|
}
|
|
4288
4284
|
if (marker.type === "progress" && this.inAdBreak) {
|
|
4289
4285
|
if (marker.durationSeconds != null) {
|
|
4290
|
-
this.
|
|
4291
|
-
}
|
|
4292
|
-
if (this.expectedAdBreakDurationMs != null && this.currentAdBreakStartWallClockMs != null) {
|
|
4293
|
-
var elapsedMs1 = Date.now() - this.currentAdBreakStartWallClockMs;
|
|
4294
|
-
var remainingMs1 = Math.max(0, this.expectedAdBreakDurationMs - elapsedMs1);
|
|
4295
|
-
this.scheduleAdStopCountdown(remainingMs1);
|
|
4286
|
+
this.setAdBreakDurationBoundary(marker.durationSeconds * 1e3);
|
|
4296
4287
|
}
|
|
4288
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
4297
4289
|
if (!this.adLayer.isAdPlaying() && this.pendingNextAdBids != null && this.pendingNextAdBids.length > 0) {
|
|
4298
4290
|
var bids = this.pendingNextAdBids;
|
|
4299
4291
|
this.pendingNextAdBids = null;
|
|
@@ -4324,15 +4316,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4324
4316
|
}
|
|
4325
4317
|
return;
|
|
4326
4318
|
}
|
|
4327
|
-
|
|
4328
|
-
if (this.config.debugAdTiming) {
|
|
4329
|
-
console.log("[StormcloudVideoPlayer] Ignoring premature SCTE-35 end marker - ads still active or time remaining");
|
|
4330
|
-
}
|
|
4331
|
-
return;
|
|
4332
|
-
}
|
|
4333
|
-
this.inAdBreak = false;
|
|
4334
|
-
this.expectedAdBreakDurationMs = void 0;
|
|
4335
|
-
this.currentAdBreakStartWallClockMs = void 0;
|
|
4319
|
+
this.scteAdBreakEndWallClockMs = Date.now();
|
|
4336
4320
|
this.clearAdStartTimer();
|
|
4337
4321
|
this.clearAdStopTimer();
|
|
4338
4322
|
if (adPlaying) {
|
|
@@ -4343,6 +4327,42 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4343
4327
|
}
|
|
4344
4328
|
}
|
|
4345
4329
|
},
|
|
4330
|
+
{
|
|
4331
|
+
key: "resolveScteBreakStartWallClockMs",
|
|
4332
|
+
value: function resolveScteBreakStartWallClockMs(marker) {
|
|
4333
|
+
var nowWallClockMs = Date.now();
|
|
4334
|
+
if (typeof marker.ptsSeconds !== "number") {
|
|
4335
|
+
return nowWallClockMs;
|
|
4336
|
+
}
|
|
4337
|
+
var nowMs = this.video.currentTime * 1e3;
|
|
4338
|
+
var estimatedCurrentPtsMs = nowMs - this.ptsDriftEmaMs;
|
|
4339
|
+
var deltaMs = marker.ptsSeconds * 1e3 - estimatedCurrentPtsMs;
|
|
4340
|
+
if (!Number.isFinite(deltaMs)) {
|
|
4341
|
+
return nowWallClockMs;
|
|
4342
|
+
}
|
|
4343
|
+
return nowWallClockMs + Math.floor(deltaMs);
|
|
4344
|
+
}
|
|
4345
|
+
},
|
|
4346
|
+
{
|
|
4347
|
+
key: "setAdBreakDurationBoundary",
|
|
4348
|
+
value: function setAdBreakDurationBoundary(durationMs) {
|
|
4349
|
+
this.expectedAdBreakDurationMs = durationMs;
|
|
4350
|
+
if (durationMs != null && this.currentAdBreakStartWallClockMs != null) {
|
|
4351
|
+
this.scteAdBreakEndWallClockMs = this.currentAdBreakStartWallClockMs + durationMs;
|
|
4352
|
+
} else {
|
|
4353
|
+
this.scteAdBreakEndWallClockMs = void 0;
|
|
4354
|
+
}
|
|
4355
|
+
}
|
|
4356
|
+
},
|
|
4357
|
+
{
|
|
4358
|
+
key: "scheduleAdStopAtBreakBoundary",
|
|
4359
|
+
value: function scheduleAdStopAtBreakBoundary() {
|
|
4360
|
+
if (this.expectedAdBreakDurationMs == null) {
|
|
4361
|
+
return;
|
|
4362
|
+
}
|
|
4363
|
+
this.scheduleAdStopCountdown(this.getRemainingAdMs());
|
|
4364
|
+
}
|
|
4365
|
+
},
|
|
4346
4366
|
{
|
|
4347
4367
|
key: "parseCueOutDuration",
|
|
4348
4368
|
value: function parseCueOutDuration(value) {
|
|
@@ -4978,7 +4998,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4978
4998
|
case 9:
|
|
4979
4999
|
_state.sent();
|
|
4980
5000
|
if (_this.expectedAdBreakDurationMs != null && _this.adStopTimerId == null) {
|
|
4981
|
-
_this.
|
|
5001
|
+
_this.scheduleAdStopAtBreakBoundary();
|
|
4982
5002
|
}
|
|
4983
5003
|
_this.adLayer.setAdVolume(_this.adLayer.getOriginalMutedState() ? 1 : _this.adLayer.getOriginalVolume());
|
|
4984
5004
|
return [
|
|
@@ -5083,7 +5103,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5083
5103
|
case 19:
|
|
5084
5104
|
_state.sent();
|
|
5085
5105
|
if (_this.expectedAdBreakDurationMs != null && _this.adStopTimerId == null) {
|
|
5086
|
-
_this.
|
|
5106
|
+
_this.scheduleAdStopAtBreakBoundary();
|
|
5087
5107
|
}
|
|
5088
5108
|
_this.adLayer.setAdVolume(_this.adLayer.getOriginalMutedState() ? 1 : _this.adLayer.getOriginalVolume());
|
|
5089
5109
|
_state.label = 20;
|
|
@@ -5166,7 +5186,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5166
5186
|
key: "handleAdStart",
|
|
5167
5187
|
value: function handleAdStart(_marker) {
|
|
5168
5188
|
return _async_to_generator(function() {
|
|
5169
|
-
var _this_savedMutedStateBeforeScte, adBreakDurationMs, mode, state, adBreakToken, adVolume, token, remaining, err;
|
|
5189
|
+
var _this_savedMutedStateBeforeScte, adBreakDurationMs, mode, state, fillerRemainingMs, adBreakToken, adVolume, token, remaining, err;
|
|
5170
5190
|
return _ts_generator(this, function(_state) {
|
|
5171
5191
|
switch(_state.label){
|
|
5172
5192
|
case 0:
|
|
@@ -5200,20 +5220,21 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5200
5220
|
}
|
|
5201
5221
|
}
|
|
5202
5222
|
this.inAdBreak = true;
|
|
5203
|
-
this.currentAdBreakStartWallClockMs = Date.now();
|
|
5204
5223
|
this.currentAdIndex = 0;
|
|
5205
5224
|
this.totalAdsInBreak = Math.max(1, this.preloadedTokens.length);
|
|
5206
5225
|
this.adPodQueue = [];
|
|
5207
5226
|
if (!this.config.disableFiller) this.showAds = true;
|
|
5208
|
-
if (adBreakDurationMs != null) {
|
|
5209
|
-
this.
|
|
5227
|
+
if (this.expectedAdBreakDurationMs == null && adBreakDurationMs != null) {
|
|
5228
|
+
this.currentAdBreakStartWallClockMs = Date.now();
|
|
5229
|
+
this.setAdBreakDurationBoundary(adBreakDurationMs);
|
|
5230
|
+
}
|
|
5231
|
+
fillerRemainingMs = this.getRemainingAdMs();
|
|
5232
|
+
if (this.expectedAdBreakDurationMs != null && fillerRemainingMs > 0) {
|
|
5233
|
+
this.startFillerBreakTimer(fillerRemainingMs);
|
|
5210
5234
|
} else if (!this.config.disableFiller && this.preloadedTokens.length === 0) {
|
|
5211
5235
|
this.showPlaceholderLayer();
|
|
5212
5236
|
}
|
|
5213
5237
|
if (!this.config.disableFiller) this.adLayer.showPlaceholder();
|
|
5214
|
-
if (this.expectedAdBreakDurationMs == null && adBreakDurationMs != null) {
|
|
5215
|
-
this.expectedAdBreakDurationMs = adBreakDurationMs;
|
|
5216
|
-
}
|
|
5217
5238
|
this.clearPendingAdBreak();
|
|
5218
5239
|
adBreakToken = Date.now();
|
|
5219
5240
|
this.activeAdRequestToken = adBreakToken;
|
|
@@ -5250,7 +5271,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5250
5271
|
case 2:
|
|
5251
5272
|
_state.sent();
|
|
5252
5273
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
5253
|
-
this.
|
|
5274
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
5254
5275
|
}
|
|
5255
5276
|
this.adLayer.setAdVolume(adVolume);
|
|
5256
5277
|
return [
|
|
@@ -5436,7 +5457,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5436
5457
|
case 4:
|
|
5437
5458
|
_state.sent();
|
|
5438
5459
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
5439
|
-
this.
|
|
5460
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
5440
5461
|
}
|
|
5441
5462
|
this.adLayer.setAdVolume(this.adLayer.getOriginalMutedState() ? 1 : this.adLayer.getOriginalVolume());
|
|
5442
5463
|
_state.label = 5;
|
|
@@ -5678,21 +5699,16 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5678
5699
|
{
|
|
5679
5700
|
key: "ensureAdStoppedByTimer",
|
|
5680
5701
|
value: function ensureAdStoppedByTimer() {
|
|
5681
|
-
var _this_config_adBreakCheckIntervalMs,
|
|
5702
|
+
var _this_config_adBreakCheckIntervalMs, _this_getAdBreakEndWallClockMs;
|
|
5682
5703
|
if (!this.inAdBreak) return;
|
|
5683
5704
|
this.adStopTimerId = void 0;
|
|
5684
5705
|
var adPlaying = this.adLayer.isAdPlaying();
|
|
5685
|
-
var pendingAds = this.adPodQueue.length > 0;
|
|
5686
5706
|
var checkIntervalMs = Math.max(250, Math.floor((_this_config_adBreakCheckIntervalMs = this.config.adBreakCheckIntervalMs) !== null && _this_config_adBreakCheckIntervalMs !== void 0 ? _this_config_adBreakCheckIntervalMs : 1e3));
|
|
5687
5707
|
var maxExtensionMsConfig = this.config.maxAdBreakExtensionMs;
|
|
5688
|
-
var maxExtensionMs = typeof maxExtensionMsConfig === "number" && maxExtensionMsConfig > 0 ? maxExtensionMsConfig :
|
|
5689
|
-
var
|
|
5690
|
-
|
|
5691
|
-
|
|
5692
|
-
}
|
|
5693
|
-
var expectedDurationMs = (_this_expectedAdBreakDurationMs = this.expectedAdBreakDurationMs) !== null && _this_expectedAdBreakDurationMs !== void 0 ? _this_expectedAdBreakDurationMs : 0;
|
|
5694
|
-
var overrunMs = Math.max(0, elapsedSinceStartMs - expectedDurationMs);
|
|
5695
|
-
var shouldExtendAdBreak = (adPlaying || pendingAds || this.showAds) && overrunMs < maxExtensionMs;
|
|
5708
|
+
var maxExtensionMs = typeof maxExtensionMsConfig === "number" && maxExtensionMsConfig > 0 ? maxExtensionMsConfig : 0;
|
|
5709
|
+
var endWallClockMs = (_this_getAdBreakEndWallClockMs = this.getAdBreakEndWallClockMs()) !== null && _this_getAdBreakEndWallClockMs !== void 0 ? _this_getAdBreakEndWallClockMs : Date.now();
|
|
5710
|
+
var overrunMs = Math.max(0, Date.now() - endWallClockMs);
|
|
5711
|
+
var shouldExtendAdBreak = adPlaying && overrunMs < maxExtensionMs;
|
|
5696
5712
|
if (shouldExtendAdBreak) {
|
|
5697
5713
|
this.scheduleAdStopCountdown(checkIntervalMs);
|
|
5698
5714
|
return;
|
|
@@ -5766,6 +5782,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5766
5782
|
this.inAdBreak = false;
|
|
5767
5783
|
this.expectedAdBreakDurationMs = void 0;
|
|
5768
5784
|
this.currentAdBreakStartWallClockMs = void 0;
|
|
5785
|
+
this.scteAdBreakEndWallClockMs = void 0;
|
|
5769
5786
|
this.clearAdStartTimer();
|
|
5770
5787
|
this.clearAdStopTimer();
|
|
5771
5788
|
this.adPodQueue = [];
|
|
@@ -6027,10 +6044,25 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6027
6044
|
{
|
|
6028
6045
|
key: "getRemainingAdMs",
|
|
6029
6046
|
value: function getRemainingAdMs() {
|
|
6047
|
+
var endWallClockMs = this.getAdBreakEndWallClockMs();
|
|
6048
|
+
if (endWallClockMs != null) {
|
|
6049
|
+
return Math.max(0, endWallClockMs - Date.now());
|
|
6050
|
+
}
|
|
6030
6051
|
if (this.currentAdBreakStartWallClockMs == null) return 0;
|
|
6031
6052
|
if (this.expectedAdBreakDurationMs == null) return Number.MAX_SAFE_INTEGER;
|
|
6032
|
-
|
|
6033
|
-
|
|
6053
|
+
return 0;
|
|
6054
|
+
}
|
|
6055
|
+
},
|
|
6056
|
+
{
|
|
6057
|
+
key: "getAdBreakEndWallClockMs",
|
|
6058
|
+
value: function getAdBreakEndWallClockMs() {
|
|
6059
|
+
if (this.scteAdBreakEndWallClockMs != null) {
|
|
6060
|
+
return this.scteAdBreakEndWallClockMs;
|
|
6061
|
+
}
|
|
6062
|
+
if (this.expectedAdBreakDurationMs == null || this.currentAdBreakStartWallClockMs == null) {
|
|
6063
|
+
return void 0;
|
|
6064
|
+
}
|
|
6065
|
+
return this.currentAdBreakStartWallClockMs + this.expectedAdBreakDurationMs;
|
|
6034
6066
|
}
|
|
6035
6067
|
},
|
|
6036
6068
|
{
|