stormcloud-video-player 0.3.64 → 0.3.66
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 +87 -45
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +25 -19
- package/lib/index.d.ts +25 -19
- package/lib/index.js +87 -45
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +90 -45
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/player/StormcloudVideoPlayer.d.cts +6 -0
- package/lib/players/HlsPlayer.cjs +90 -45
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/index.cjs +90 -45
- package/lib/players/index.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +90 -45
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/package.json +1 -1
|
@@ -9,6 +9,7 @@ declare class StormcloudVideoPlayer {
|
|
|
9
9
|
private inAdBreak;
|
|
10
10
|
private currentAdBreakStartWallClockMs;
|
|
11
11
|
private expectedAdBreakDurationMs;
|
|
12
|
+
private scteAdBreakEndWallClockMs;
|
|
12
13
|
private adStopTimerId;
|
|
13
14
|
private adStartTimerId;
|
|
14
15
|
private adFailsafeTimerId;
|
|
@@ -105,6 +106,9 @@ declare class StormcloudVideoPlayer {
|
|
|
105
106
|
private activatePendingScte35CuesForFragment;
|
|
106
107
|
private onScte35Marker;
|
|
107
108
|
private startScte35AdBreak;
|
|
109
|
+
private resolveScteBreakStartWallClockMs;
|
|
110
|
+
private setAdBreakDurationBoundary;
|
|
111
|
+
private scheduleAdStopAtBreakBoundary;
|
|
108
112
|
private parseCueOutDuration;
|
|
109
113
|
private parseCueOutCont;
|
|
110
114
|
private parseAttributeList;
|
|
@@ -130,6 +134,7 @@ declare class StormcloudVideoPlayer {
|
|
|
130
134
|
private initializeTracking;
|
|
131
135
|
private sendHeartbeatIfNeeded;
|
|
132
136
|
private isVmapEnabled;
|
|
137
|
+
private applyMqttConfigFromResponse;
|
|
133
138
|
private fetchAdConfiguration;
|
|
134
139
|
private fetchAndParseVmap;
|
|
135
140
|
private parseVmapToBreaks;
|
|
@@ -188,6 +193,7 @@ declare class StormcloudVideoPlayer {
|
|
|
188
193
|
private selectVastTagsForBreak;
|
|
189
194
|
private logAdState;
|
|
190
195
|
private getRemainingAdMs;
|
|
196
|
+
private getAdBreakEndWallClockMs;
|
|
191
197
|
private findBreakForTime;
|
|
192
198
|
toggleMute(): void;
|
|
193
199
|
toggleFullscreen(): Promise<void>;
|
|
@@ -2442,6 +2442,9 @@ var DEFAULT_MQTT_CONFIG = {
|
|
|
2442
2442
|
qos: 1
|
|
2443
2443
|
};
|
|
2444
2444
|
var mqttConfig = _object_spread({}, DEFAULT_MQTT_CONFIG);
|
|
2445
|
+
function applyMQTTConfig(overrides) {
|
|
2446
|
+
Object.assign(mqttConfig, overrides);
|
|
2447
|
+
}
|
|
2445
2448
|
function isMQTTEnabled() {
|
|
2446
2449
|
return mqttConfig.enabled;
|
|
2447
2450
|
}
|
|
@@ -3879,7 +3882,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3879
3882
|
_this.showAds = true;
|
|
3880
3883
|
_this.resetGamNoFillCounter();
|
|
3881
3884
|
if (_this.inAdBreak && _this.expectedAdBreakDurationMs != null && _this.adStopTimerId == null) {
|
|
3882
|
-
_this.
|
|
3885
|
+
_this.scheduleAdStopAtBreakBoundary();
|
|
3883
3886
|
if (_this.config.debugAdTiming) {
|
|
3884
3887
|
console.log("[StormcloudVideoPlayer] Starting ad break timer on content_pause (first ad starting)");
|
|
3885
3888
|
}
|
|
@@ -4523,12 +4526,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4523
4526
|
if (marker.durationSeconds != null) {
|
|
4524
4527
|
var newDurationMs = marker.durationSeconds * 1e3;
|
|
4525
4528
|
if (this.expectedAdBreakDurationMs == null || newDurationMs > this.expectedAdBreakDurationMs) {
|
|
4526
|
-
this.
|
|
4527
|
-
|
|
4528
|
-
var remainingMs = Math.max(0, newDurationMs - elapsedMs);
|
|
4529
|
-
this.scheduleAdStopCountdown(remainingMs);
|
|
4529
|
+
this.setAdBreakDurationBoundary(newDurationMs);
|
|
4530
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
4530
4531
|
if (this.config.debugAdTiming) {
|
|
4531
|
-
console.log("[StormcloudVideoPlayer] Updated ad break duration from subsequent marker: ".concat(newDurationMs, "ms, remaining: ").concat(
|
|
4532
|
+
console.log("[StormcloudVideoPlayer] Updated ad break duration from subsequent marker: ".concat(newDurationMs, "ms, remaining: ").concat(this.getRemainingAdMs(), "ms"));
|
|
4532
4533
|
}
|
|
4533
4534
|
}
|
|
4534
4535
|
}
|
|
@@ -4602,13 +4603,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4602
4603
|
}
|
|
4603
4604
|
if (marker.type === "progress" && this.inAdBreak) {
|
|
4604
4605
|
if (marker.durationSeconds != null) {
|
|
4605
|
-
this.
|
|
4606
|
-
}
|
|
4607
|
-
if (this.expectedAdBreakDurationMs != null && this.currentAdBreakStartWallClockMs != null) {
|
|
4608
|
-
var elapsedMs1 = Date.now() - this.currentAdBreakStartWallClockMs;
|
|
4609
|
-
var remainingMs1 = Math.max(0, this.expectedAdBreakDurationMs - elapsedMs1);
|
|
4610
|
-
this.scheduleAdStopCountdown(remainingMs1);
|
|
4606
|
+
this.setAdBreakDurationBoundary(marker.durationSeconds * 1e3);
|
|
4611
4607
|
}
|
|
4608
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
4612
4609
|
if (!this.ima.isAdPlaying() && this.activeAdRequestToken === null && this.adRequestQueue.length > 0) {
|
|
4613
4610
|
this.tryNextAvailableAdWithRateLimit();
|
|
4614
4611
|
}
|
|
@@ -4633,15 +4630,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4633
4630
|
activeAdRequest: this.activeAdRequestToken !== null
|
|
4634
4631
|
});
|
|
4635
4632
|
}
|
|
4636
|
-
|
|
4637
|
-
if (this.config.debugAdTiming) {
|
|
4638
|
-
console.log("[StormcloudVideoPlayer] Ignoring premature SCTE-35 end marker - ads still active");
|
|
4639
|
-
}
|
|
4640
|
-
return;
|
|
4641
|
-
}
|
|
4642
|
-
this.inAdBreak = false;
|
|
4643
|
-
this.expectedAdBreakDurationMs = void 0;
|
|
4644
|
-
this.currentAdBreakStartWallClockMs = void 0;
|
|
4633
|
+
this.scteAdBreakEndWallClockMs = Date.now();
|
|
4645
4634
|
this.clearAdStartTimer();
|
|
4646
4635
|
this.clearAdStopTimer();
|
|
4647
4636
|
if (adPlaying) {
|
|
@@ -4665,12 +4654,46 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4665
4654
|
this.inAdBreak = true;
|
|
4666
4655
|
this.activeScte35BreakKey = cueKey !== null && cueKey !== void 0 ? cueKey : this.pendingScte35CueKey;
|
|
4667
4656
|
this.scheduledScte35BreakKey = void 0;
|
|
4668
|
-
this.
|
|
4669
|
-
this.
|
|
4657
|
+
this.currentAdBreakStartWallClockMs = this.resolveScteBreakStartWallClockMs(marker);
|
|
4658
|
+
this.setAdBreakDurationBoundary(durationMs);
|
|
4670
4659
|
this.handleAdStart(marker);
|
|
4671
|
-
|
|
4672
|
-
|
|
4660
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
4661
|
+
}
|
|
4662
|
+
},
|
|
4663
|
+
{
|
|
4664
|
+
key: "resolveScteBreakStartWallClockMs",
|
|
4665
|
+
value: function resolveScteBreakStartWallClockMs(marker) {
|
|
4666
|
+
var nowWallClockMs = Date.now();
|
|
4667
|
+
if (typeof marker.ptsSeconds !== "number") {
|
|
4668
|
+
return nowWallClockMs;
|
|
4669
|
+
}
|
|
4670
|
+
var nowMs = this.video.currentTime * 1e3;
|
|
4671
|
+
var estimatedCurrentPtsMs = nowMs - this.ptsDriftEmaMs;
|
|
4672
|
+
var deltaMs = marker.ptsSeconds * 1e3 - estimatedCurrentPtsMs;
|
|
4673
|
+
if (!Number.isFinite(deltaMs)) {
|
|
4674
|
+
return nowWallClockMs;
|
|
4673
4675
|
}
|
|
4676
|
+
return nowWallClockMs + Math.floor(deltaMs);
|
|
4677
|
+
}
|
|
4678
|
+
},
|
|
4679
|
+
{
|
|
4680
|
+
key: "setAdBreakDurationBoundary",
|
|
4681
|
+
value: function setAdBreakDurationBoundary(durationMs) {
|
|
4682
|
+
this.expectedAdBreakDurationMs = durationMs;
|
|
4683
|
+
if (durationMs != null && this.currentAdBreakStartWallClockMs != null) {
|
|
4684
|
+
this.scteAdBreakEndWallClockMs = this.currentAdBreakStartWallClockMs + durationMs;
|
|
4685
|
+
} else {
|
|
4686
|
+
this.scteAdBreakEndWallClockMs = void 0;
|
|
4687
|
+
}
|
|
4688
|
+
}
|
|
4689
|
+
},
|
|
4690
|
+
{
|
|
4691
|
+
key: "scheduleAdStopAtBreakBoundary",
|
|
4692
|
+
value: function scheduleAdStopAtBreakBoundary() {
|
|
4693
|
+
if (this.expectedAdBreakDurationMs == null) {
|
|
4694
|
+
return;
|
|
4695
|
+
}
|
|
4696
|
+
this.scheduleAdStopCountdown(this.getRemainingAdMs());
|
|
4674
4697
|
}
|
|
4675
4698
|
},
|
|
4676
4699
|
{
|
|
@@ -5396,6 +5419,20 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5396
5419
|
return !!(this.config.isVmap && ((_this_config_vmapUrl = this.config.vmapUrl) === null || _this_config_vmapUrl === void 0 ? void 0 : _this_config_vmapUrl.trim()));
|
|
5397
5420
|
}
|
|
5398
5421
|
},
|
|
5422
|
+
{
|
|
5423
|
+
key: "applyMqttConfigFromResponse",
|
|
5424
|
+
value: function applyMqttConfigFromResponse(data) {
|
|
5425
|
+
var _data_response;
|
|
5426
|
+
var mqttConfig2 = (_data_response = data.response) === null || _data_response === void 0 ? void 0 : _data_response.mqtt_config;
|
|
5427
|
+
if (!mqttConfig2 || (typeof mqttConfig2 === "undefined" ? "undefined" : _type_of(mqttConfig2)) !== "object") {
|
|
5428
|
+
return;
|
|
5429
|
+
}
|
|
5430
|
+
applyMQTTConfig(mqttConfig2);
|
|
5431
|
+
if (this.config.debugAdTiming) {
|
|
5432
|
+
console.log("[StormcloudVideoPlayer] Applied MQTT config from /ads/web:", mqttConfig2);
|
|
5433
|
+
}
|
|
5434
|
+
}
|
|
5435
|
+
},
|
|
5399
5436
|
{
|
|
5400
5437
|
key: "fetchAdConfiguration",
|
|
5401
5438
|
value: function fetchAdConfiguration() {
|
|
@@ -5482,6 +5519,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5482
5519
|
];
|
|
5483
5520
|
case 4:
|
|
5484
5521
|
data = _state.sent();
|
|
5522
|
+
this.applyMqttConfigFromResponse(data);
|
|
5485
5523
|
imaPayload = (_data_response = data.response) === null || _data_response === void 0 ? void 0 : (_data_response_ima = _data_response.ima) === null || _data_response_ima === void 0 ? void 0 : (_data_response_ima_publisherdeskima = _data_response_ima["publisherdesk.ima"]) === null || _data_response_ima_publisherdeskima === void 0 ? void 0 : _data_response_ima_publisherdeskima.payload;
|
|
5486
5524
|
if (imaPayload) {
|
|
5487
5525
|
this.apiVastTagUrl = decodeURIComponent(imaPayload);
|
|
@@ -6298,7 +6336,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6298
6336
|
}
|
|
6299
6337
|
}
|
|
6300
6338
|
this.inAdBreak = true;
|
|
6301
|
-
this.currentAdBreakStartWallClockMs = Date.now();
|
|
6302
6339
|
this.currentAdIndex = 0;
|
|
6303
6340
|
this.totalAdsInBreak = 1;
|
|
6304
6341
|
this.adPodQueue = [];
|
|
@@ -6385,7 +6422,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6385
6422
|
case 2:
|
|
6386
6423
|
_state.sent();
|
|
6387
6424
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
6388
|
-
this.
|
|
6425
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
6389
6426
|
}
|
|
6390
6427
|
adVolume = currentMuted ? 0 : currentVolume;
|
|
6391
6428
|
this.ima.setAdVolume(adVolume);
|
|
@@ -6428,7 +6465,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6428
6465
|
case 6:
|
|
6429
6466
|
_state.sent();
|
|
6430
6467
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
6431
|
-
this.
|
|
6468
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
6432
6469
|
}
|
|
6433
6470
|
adVolume1 = currentMuted ? 0 : currentVolume;
|
|
6434
6471
|
this.ima.setAdVolume(adVolume1);
|
|
@@ -6483,7 +6520,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6483
6520
|
case 10:
|
|
6484
6521
|
_state.sent();
|
|
6485
6522
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
6486
|
-
this.
|
|
6523
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
6487
6524
|
}
|
|
6488
6525
|
adVolume2 = currentMuted ? 0 : currentVolume;
|
|
6489
6526
|
this.ima.setAdVolume(adVolume2);
|
|
@@ -6835,7 +6872,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6835
6872
|
case 2:
|
|
6836
6873
|
_state.sent();
|
|
6837
6874
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
6838
|
-
this.
|
|
6875
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
6839
6876
|
}
|
|
6840
6877
|
currentMuted = this.video.muted;
|
|
6841
6878
|
currentVolume = this.video.volume;
|
|
@@ -7335,21 +7372,16 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
7335
7372
|
{
|
|
7336
7373
|
key: "ensureAdStoppedByTimer",
|
|
7337
7374
|
value: function ensureAdStoppedByTimer() {
|
|
7338
|
-
var _this_config_adBreakCheckIntervalMs,
|
|
7375
|
+
var _this_config_adBreakCheckIntervalMs, _this_getAdBreakEndWallClockMs;
|
|
7339
7376
|
if (!this.inAdBreak) return;
|
|
7340
7377
|
this.adStopTimerId = void 0;
|
|
7341
7378
|
var adPlaying = this.ima.isAdPlaying();
|
|
7342
|
-
var pendingAds = this.adPodQueue.length > 0;
|
|
7343
7379
|
var checkIntervalMs = Math.max(250, Math.floor((_this_config_adBreakCheckIntervalMs = this.config.adBreakCheckIntervalMs) !== null && _this_config_adBreakCheckIntervalMs !== void 0 ? _this_config_adBreakCheckIntervalMs : 1e3));
|
|
7344
7380
|
var maxExtensionMsConfig = this.config.maxAdBreakExtensionMs;
|
|
7345
|
-
var maxExtensionMs = typeof maxExtensionMsConfig === "number" && maxExtensionMsConfig > 0 ? maxExtensionMsConfig :
|
|
7346
|
-
var
|
|
7347
|
-
|
|
7348
|
-
|
|
7349
|
-
}
|
|
7350
|
-
var expectedDurationMs = (_this_expectedAdBreakDurationMs = this.expectedAdBreakDurationMs) !== null && _this_expectedAdBreakDurationMs !== void 0 ? _this_expectedAdBreakDurationMs : 0;
|
|
7351
|
-
var overrunMs = Math.max(0, elapsedSinceStartMs - expectedDurationMs);
|
|
7352
|
-
var shouldExtendAdBreak = (adPlaying || pendingAds || this.showAds) && overrunMs < maxExtensionMs;
|
|
7381
|
+
var maxExtensionMs = typeof maxExtensionMsConfig === "number" && maxExtensionMsConfig > 0 ? maxExtensionMsConfig : 0;
|
|
7382
|
+
var endWallClockMs = (_this_getAdBreakEndWallClockMs = this.getAdBreakEndWallClockMs()) !== null && _this_getAdBreakEndWallClockMs !== void 0 ? _this_getAdBreakEndWallClockMs : Date.now();
|
|
7383
|
+
var overrunMs = Math.max(0, Date.now() - endWallClockMs);
|
|
7384
|
+
var shouldExtendAdBreak = adPlaying && overrunMs < maxExtensionMs;
|
|
7353
7385
|
if (shouldExtendAdBreak) {
|
|
7354
7386
|
this.scheduleAdStopCountdown(checkIntervalMs);
|
|
7355
7387
|
return;
|
|
@@ -7615,7 +7647,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
7615
7647
|
case 5:
|
|
7616
7648
|
_state.sent();
|
|
7617
7649
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
7618
|
-
this.
|
|
7650
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
7619
7651
|
}
|
|
7620
7652
|
currentMuted = this.video.muted;
|
|
7621
7653
|
currentVolume = this.video.volume;
|
|
@@ -7665,7 +7697,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
7665
7697
|
case 8:
|
|
7666
7698
|
_state.sent();
|
|
7667
7699
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
7668
|
-
this.
|
|
7700
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
7669
7701
|
}
|
|
7670
7702
|
currentMuted1 = this.video.muted;
|
|
7671
7703
|
currentVolume1 = this.video.volume;
|
|
@@ -7810,6 +7842,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
7810
7842
|
this.scheduledScte35BreakKey = void 0;
|
|
7811
7843
|
this.expectedAdBreakDurationMs = void 0;
|
|
7812
7844
|
this.currentAdBreakStartWallClockMs = void 0;
|
|
7845
|
+
this.scteAdBreakEndWallClockMs = void 0;
|
|
7813
7846
|
this.clearAdStartTimer();
|
|
7814
7847
|
this.clearAdStopTimer();
|
|
7815
7848
|
this.adPodQueue = [];
|
|
@@ -7999,9 +8032,21 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
7999
8032
|
{
|
|
8000
8033
|
key: "getRemainingAdMs",
|
|
8001
8034
|
value: function getRemainingAdMs() {
|
|
8002
|
-
|
|
8003
|
-
|
|
8004
|
-
|
|
8035
|
+
var endWallClockMs = this.getAdBreakEndWallClockMs();
|
|
8036
|
+
if (endWallClockMs != null) {
|
|
8037
|
+
return Math.max(0, endWallClockMs - Date.now());
|
|
8038
|
+
}
|
|
8039
|
+
return 0;
|
|
8040
|
+
}
|
|
8041
|
+
},
|
|
8042
|
+
{
|
|
8043
|
+
key: "getAdBreakEndWallClockMs",
|
|
8044
|
+
value: function getAdBreakEndWallClockMs() {
|
|
8045
|
+
if (this.scteAdBreakEndWallClockMs != null) {
|
|
8046
|
+
return this.scteAdBreakEndWallClockMs;
|
|
8047
|
+
}
|
|
8048
|
+
if (this.expectedAdBreakDurationMs == null || this.currentAdBreakStartWallClockMs == null) return void 0;
|
|
8049
|
+
return this.currentAdBreakStartWallClockMs + this.expectedAdBreakDurationMs;
|
|
8005
8050
|
}
|
|
8006
8051
|
},
|
|
8007
8052
|
{
|