stormcloud-video-player 0.3.63 → 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 +3 -1
- package/lib/index.cjs +325 -215
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +35 -1
- package/lib/index.d.ts +35 -1
- package/lib/index.js +266 -216
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +241 -215
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/player/StormcloudVideoPlayer.d.cts +5 -0
- package/lib/players/HlsPlayer.cjs +241 -215
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/index.cjs +241 -215
- package/lib/players/index.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +241 -215
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/utils/mqttClient.cjs +245 -0
- package/lib/utils/mqttClient.cjs.map +1 -0
- package/lib/utils/mqttClient.d.cts +13 -0
- package/lib/utils/mqttConfig.cjs +141 -0
- package/lib/utils/mqttConfig.cjs.map +1 -0
- package/lib/utils/mqttConfig.d.cts +20 -0
- package/lib/utils/tracking.cjs +182 -170
- package/lib/utils/tracking.cjs.map +1 -1
- package/package.json +3 -1
- package/src/certs/emqxsl-ca.crt +22 -0
|
@@ -2416,6 +2416,99 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2416
2416
|
}
|
|
2417
2417
|
};
|
|
2418
2418
|
}
|
|
2419
|
+
// src/utils/mqttConfig.ts
|
|
2420
|
+
var DEFAULT_MQTT_CONFIG = {
|
|
2421
|
+
enabled: true,
|
|
2422
|
+
brokerAddress: "vecbae77.ala.us-east-1.emqxsl.com",
|
|
2423
|
+
brokerPort: 8883,
|
|
2424
|
+
wsPort: 8084,
|
|
2425
|
+
username: "for-sonifi",
|
|
2426
|
+
password: "sonifi-mqtt",
|
|
2427
|
+
topicPrefix: "adstorm/players",
|
|
2428
|
+
qos: 1
|
|
2429
|
+
};
|
|
2430
|
+
var mqttConfig = _object_spread({}, DEFAULT_MQTT_CONFIG);
|
|
2431
|
+
function isMQTTEnabled() {
|
|
2432
|
+
return mqttConfig.enabled;
|
|
2433
|
+
}
|
|
2434
|
+
function buildMQTTBrokerUrl() {
|
|
2435
|
+
if (mqttConfig.brokerUrl) return mqttConfig.brokerUrl;
|
|
2436
|
+
return "wss://".concat(mqttConfig.brokerAddress, ":").concat(mqttConfig.wsPort, "/mqtt");
|
|
2437
|
+
}
|
|
2438
|
+
function buildPlayerTopic(licenseKey, channel) {
|
|
2439
|
+
return "".concat(mqttConfig.topicPrefix, "/").concat(licenseKey, "/").concat(channel);
|
|
2440
|
+
}
|
|
2441
|
+
// src/utils/mqttClient.ts
|
|
2442
|
+
var import_mqtt = __toESM(require("mqtt"), 1);
|
|
2443
|
+
var LOG = "[StormcloudVideoPlayer][MQTT]";
|
|
2444
|
+
var client = null;
|
|
2445
|
+
var status = "disconnected";
|
|
2446
|
+
function initMQTTClient() {
|
|
2447
|
+
if (client || !isMQTTEnabled()) return;
|
|
2448
|
+
var url = buildMQTTBrokerUrl();
|
|
2449
|
+
status = "connecting";
|
|
2450
|
+
var clientId = "stormcloud-vp-".concat(Math.random().toString(36).slice(2, 9));
|
|
2451
|
+
try {
|
|
2452
|
+
client = import_mqtt.default.connect(url, {
|
|
2453
|
+
clientId: clientId,
|
|
2454
|
+
username: mqttConfig.username,
|
|
2455
|
+
password: mqttConfig.password,
|
|
2456
|
+
keepalive: 60,
|
|
2457
|
+
clean: true,
|
|
2458
|
+
reconnectPeriod: 5e3,
|
|
2459
|
+
connectTimeout: 1e4,
|
|
2460
|
+
queueQoSZero: false
|
|
2461
|
+
});
|
|
2462
|
+
} catch (err) {
|
|
2463
|
+
status = "error";
|
|
2464
|
+
console.warn("".concat(LOG, " connect() threw:"), err);
|
|
2465
|
+
return;
|
|
2466
|
+
}
|
|
2467
|
+
client.on("connect", function() {
|
|
2468
|
+
status = "connected";
|
|
2469
|
+
console.info("".concat(LOG, " connected to ").concat(url));
|
|
2470
|
+
});
|
|
2471
|
+
client.on("reconnect", function() {
|
|
2472
|
+
status = "connecting";
|
|
2473
|
+
console.info("".concat(LOG, " reconnecting…"));
|
|
2474
|
+
});
|
|
2475
|
+
client.on("offline", function() {
|
|
2476
|
+
status = "disconnected";
|
|
2477
|
+
console.warn("".concat(LOG, " offline"));
|
|
2478
|
+
});
|
|
2479
|
+
client.on("error", function(err) {
|
|
2480
|
+
status = "error";
|
|
2481
|
+
console.warn("".concat(LOG, " error:"), err.message);
|
|
2482
|
+
});
|
|
2483
|
+
client.on("close", function() {
|
|
2484
|
+
if (status === "connected") {
|
|
2485
|
+
status = "disconnected";
|
|
2486
|
+
}
|
|
2487
|
+
});
|
|
2488
|
+
}
|
|
2489
|
+
function ensureMQTTClient() {
|
|
2490
|
+
if (isMQTTEnabled() && !client) {
|
|
2491
|
+
initMQTTClient();
|
|
2492
|
+
}
|
|
2493
|
+
}
|
|
2494
|
+
function publishMQTT(topic, payload) {
|
|
2495
|
+
if (!isMQTTEnabled()) {
|
|
2496
|
+
return false;
|
|
2497
|
+
}
|
|
2498
|
+
ensureMQTTClient();
|
|
2499
|
+
if (!client) {
|
|
2500
|
+
return false;
|
|
2501
|
+
}
|
|
2502
|
+
try {
|
|
2503
|
+
client.publish(topic, JSON.stringify(payload), {
|
|
2504
|
+
qos: mqttConfig.qos
|
|
2505
|
+
});
|
|
2506
|
+
return true;
|
|
2507
|
+
} catch (err) {
|
|
2508
|
+
console.warn("".concat(LOG, " publish failed on ").concat(topic, ":"), err);
|
|
2509
|
+
return false;
|
|
2510
|
+
}
|
|
2511
|
+
}
|
|
2419
2512
|
// src/utils/tracking.ts
|
|
2420
2513
|
var cachedBrowserId = null;
|
|
2421
2514
|
function getClientInfo() {
|
|
@@ -2562,7 +2655,7 @@ function getClientInfo() {
|
|
|
2562
2655
|
}
|
|
2563
2656
|
function getBrowserID(clientInfo) {
|
|
2564
2657
|
return _async_to_generator(function() {
|
|
2565
|
-
var fingerprintString, encodedData, utf8, buffer, i, hashBuffer,
|
|
2658
|
+
var _crypto_subtle, fingerprintString, encodedData, utf8, buffer, i, hashBuffer, hashHex, unused, hash, i1, char, fallbackHash, timestamp, random;
|
|
2566
2659
|
return _ts_generator(this, function(_state) {
|
|
2567
2660
|
switch(_state.label){
|
|
2568
2661
|
case 0:
|
|
@@ -2573,7 +2666,7 @@ function getBrowserID(clientInfo) {
|
|
|
2573
2666
|
];
|
|
2574
2667
|
}
|
|
2575
2668
|
fingerprintString = JSON.stringify(clientInfo);
|
|
2576
|
-
if (!(typeof crypto !== "undefined" && crypto.subtle
|
|
2669
|
+
if (!(typeof crypto !== "undefined" && ((_crypto_subtle = crypto.subtle) === null || _crypto_subtle === void 0 ? void 0 : _crypto_subtle.digest))) return [
|
|
2577
2670
|
3,
|
|
2578
2671
|
5
|
|
2579
2672
|
];
|
|
@@ -2611,8 +2704,7 @@ function getBrowserID(clientInfo) {
|
|
|
2611
2704
|
];
|
|
2612
2705
|
case 3:
|
|
2613
2706
|
hashBuffer = _state.sent();
|
|
2614
|
-
|
|
2615
|
-
hashHex = hashArray.map(function(b) {
|
|
2707
|
+
hashHex = Array.from(new Uint8Array(hashBuffer)).map(function(b) {
|
|
2616
2708
|
return b.toString(16).padStart(2, "0");
|
|
2617
2709
|
}).join("");
|
|
2618
2710
|
cachedBrowserId = hashHex;
|
|
@@ -2621,8 +2713,8 @@ function getBrowserID(clientInfo) {
|
|
|
2621
2713
|
hashHex
|
|
2622
2714
|
];
|
|
2623
2715
|
case 4:
|
|
2624
|
-
|
|
2625
|
-
console.warn("[StormcloudVideoPlayer] crypto.subtle
|
|
2716
|
+
unused = _state.sent();
|
|
2717
|
+
console.warn("[StormcloudVideoPlayer] crypto.subtle not supported, using fallback hash");
|
|
2626
2718
|
return [
|
|
2627
2719
|
3,
|
|
2628
2720
|
5
|
|
@@ -2646,177 +2738,91 @@ function getBrowserID(clientInfo) {
|
|
|
2646
2738
|
});
|
|
2647
2739
|
})();
|
|
2648
2740
|
}
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
var HEARTBEAT_URL = "".concat(PLAYER_TRACKING_BASE_URL, "/heartbeat");
|
|
2652
|
-
var IMPRESSIONS_URL = "".concat(PLAYER_TRACKING_BASE_URL, "/impressions/ingest");
|
|
2653
|
-
function buildHeaders(licenseKey) {
|
|
2654
|
-
var headers = {
|
|
2655
|
-
"Content-Type": "application/json"
|
|
2656
|
-
};
|
|
2657
|
-
if (licenseKey) {
|
|
2658
|
-
headers["Authorization"] = "Bearer ".concat(licenseKey);
|
|
2659
|
-
}
|
|
2660
|
-
return headers;
|
|
2741
|
+
function canPublish(licenseKey) {
|
|
2742
|
+
return Boolean(isMQTTEnabled() && licenseKey);
|
|
2661
2743
|
}
|
|
2662
|
-
function
|
|
2744
|
+
function buildPlayerMetricEvent() {
|
|
2663
2745
|
return _async_to_generator(function() {
|
|
2664
|
-
var
|
|
2665
|
-
return _ts_generator(this, function(_state) {
|
|
2666
|
-
switch(_state.label){
|
|
2667
|
-
case 0:
|
|
2668
|
-
return [
|
|
2669
|
-
4,
|
|
2670
|
-
fetch(TRACK_URL, {
|
|
2671
|
-
method: "POST",
|
|
2672
|
-
headers: buildHeaders(licenseKey),
|
|
2673
|
-
body: JSON.stringify(body)
|
|
2674
|
-
})
|
|
2675
|
-
];
|
|
2676
|
-
case 1:
|
|
2677
|
-
response = _state.sent();
|
|
2678
|
-
if (!response.ok) {
|
|
2679
|
-
throw new Error("HTTP error! status: ".concat(response.status));
|
|
2680
|
-
}
|
|
2681
|
-
return [
|
|
2682
|
-
4,
|
|
2683
|
-
response.json()
|
|
2684
|
-
];
|
|
2685
|
-
case 2:
|
|
2686
|
-
_state.sent();
|
|
2687
|
-
return [
|
|
2688
|
-
2
|
|
2689
|
-
];
|
|
2690
|
-
}
|
|
2691
|
-
});
|
|
2692
|
-
})();
|
|
2693
|
-
}
|
|
2694
|
-
function postJson(url, licenseKey, body) {
|
|
2695
|
-
return _async_to_generator(function() {
|
|
2696
|
-
var response;
|
|
2697
|
-
return _ts_generator(this, function(_state) {
|
|
2698
|
-
switch(_state.label){
|
|
2699
|
-
case 0:
|
|
2700
|
-
return [
|
|
2701
|
-
4,
|
|
2702
|
-
fetch(url, {
|
|
2703
|
-
method: "POST",
|
|
2704
|
-
headers: buildHeaders(licenseKey),
|
|
2705
|
-
body: JSON.stringify(body)
|
|
2706
|
-
})
|
|
2707
|
-
];
|
|
2708
|
-
case 1:
|
|
2709
|
-
response = _state.sent();
|
|
2710
|
-
if (!response.ok) {
|
|
2711
|
-
throw new Error("HTTP error! status: ".concat(response.status));
|
|
2712
|
-
}
|
|
2713
|
-
return [
|
|
2714
|
-
4,
|
|
2715
|
-
response.json()
|
|
2716
|
-
];
|
|
2717
|
-
case 2:
|
|
2718
|
-
_state.sent();
|
|
2719
|
-
return [
|
|
2720
|
-
2
|
|
2721
|
-
];
|
|
2722
|
-
}
|
|
2723
|
-
});
|
|
2724
|
-
})();
|
|
2725
|
-
}
|
|
2726
|
-
function buildPlayerMetricEvent(_0) {
|
|
2727
|
-
return _async_to_generator(function(licenseKey) {
|
|
2728
|
-
var context, flags, _flags_captureAt, clientInfo, browserId, captureAt;
|
|
2746
|
+
var context, flags, _flags_captureAt, _flags_adLoaded, _flags_adDetect, clientInfo, playerId, captureAt;
|
|
2729
2747
|
var _arguments = arguments;
|
|
2730
2748
|
return _ts_generator(this, function(_state) {
|
|
2731
2749
|
switch(_state.label){
|
|
2732
2750
|
case 0:
|
|
2733
|
-
context = _arguments.length >
|
|
2751
|
+
context = _arguments.length > 0 && _arguments[0] !== void 0 ? _arguments[0] : {}, flags = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {};
|
|
2734
2752
|
clientInfo = getClientInfo();
|
|
2735
2753
|
return [
|
|
2736
2754
|
4,
|
|
2737
2755
|
getBrowserID(clientInfo)
|
|
2738
2756
|
];
|
|
2739
2757
|
case 1:
|
|
2740
|
-
|
|
2758
|
+
playerId = _state.sent();
|
|
2741
2759
|
captureAt = (_flags_captureAt = flags.captureAt) !== null && _flags_captureAt !== void 0 ? _flags_captureAt : /* @__PURE__ */ new Date().toISOString();
|
|
2742
2760
|
return [
|
|
2743
2761
|
2,
|
|
2744
|
-
{
|
|
2745
|
-
player_id:
|
|
2746
|
-
browserId: browserId,
|
|
2762
|
+
_object_spread({
|
|
2763
|
+
player_id: playerId,
|
|
2747
2764
|
device_type: clientInfo.deviceType,
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
timestamp: captureAt
|
|
2756
|
-
}
|
|
2765
|
+
os: clientInfo.os.toLowerCase(),
|
|
2766
|
+
ad_loaded: (_flags_adLoaded = flags.adLoaded) !== null && _flags_adLoaded !== void 0 ? _flags_adLoaded : false,
|
|
2767
|
+
ad_detect: (_flags_adDetect = flags.adDetect) !== null && _flags_adDetect !== void 0 ? _flags_adDetect : false,
|
|
2768
|
+
capture_at: captureAt
|
|
2769
|
+
}, context.inputStreamType ? {
|
|
2770
|
+
input_stream_type: context.inputStreamType
|
|
2771
|
+
} : {})
|
|
2757
2772
|
];
|
|
2758
2773
|
}
|
|
2759
2774
|
});
|
|
2760
2775
|
}).apply(this, arguments);
|
|
2761
2776
|
}
|
|
2777
|
+
function publishTracking(licenseKey, channel, body) {
|
|
2778
|
+
ensureMQTTClient();
|
|
2779
|
+
publishMQTT(buildPlayerTopic(licenseKey, channel), body);
|
|
2780
|
+
}
|
|
2762
2781
|
function sendInitialTracking(_0) {
|
|
2763
2782
|
return _async_to_generator(function(licenseKey) {
|
|
2764
|
-
var context,
|
|
2783
|
+
var context, metricEvent, error;
|
|
2765
2784
|
var _arguments = arguments;
|
|
2766
2785
|
return _ts_generator(this, function(_state) {
|
|
2767
2786
|
switch(_state.label){
|
|
2768
2787
|
case 0:
|
|
2769
2788
|
context = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {};
|
|
2789
|
+
if (!canPublish(licenseKey)) return [
|
|
2790
|
+
2
|
|
2791
|
+
];
|
|
2770
2792
|
_state.label = 1;
|
|
2771
2793
|
case 1:
|
|
2772
2794
|
_state.trys.push([
|
|
2773
2795
|
1,
|
|
2774
|
-
|
|
2796
|
+
3,
|
|
2775
2797
|
,
|
|
2776
|
-
|
|
2798
|
+
4
|
|
2777
2799
|
]);
|
|
2778
|
-
clientInfo = getClientInfo();
|
|
2779
|
-
return [
|
|
2780
|
-
4,
|
|
2781
|
-
getBrowserID(clientInfo)
|
|
2782
|
-
];
|
|
2783
|
-
case 2:
|
|
2784
|
-
browserId = _state.sent();
|
|
2785
|
-
trackingData = _object_spread({
|
|
2786
|
-
browserId: browserId
|
|
2787
|
-
}, clientInfo);
|
|
2788
2800
|
return [
|
|
2789
2801
|
4,
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
player_id: browserId,
|
|
2794
|
-
device_type: clientInfo.deviceType,
|
|
2795
|
-
input_stream_type: context.inputStreamType,
|
|
2796
|
-
os: clientInfo.os,
|
|
2797
|
-
ad_loaded: false,
|
|
2798
|
-
ad_detect: false,
|
|
2799
|
-
license_key: licenseKey,
|
|
2800
|
-
capture_at: /* @__PURE__ */ new Date().toISOString()
|
|
2801
|
-
}
|
|
2802
|
-
],
|
|
2803
|
-
trackingData: trackingData
|
|
2802
|
+
buildPlayerMetricEvent(context, {
|
|
2803
|
+
adLoaded: false,
|
|
2804
|
+
adDetect: false
|
|
2804
2805
|
})
|
|
2805
2806
|
];
|
|
2806
|
-
case
|
|
2807
|
-
_state.sent();
|
|
2807
|
+
case 2:
|
|
2808
|
+
metricEvent = _state.sent();
|
|
2809
|
+
publishTracking(licenseKey, "metrics", {
|
|
2810
|
+
events: [
|
|
2811
|
+
metricEvent
|
|
2812
|
+
]
|
|
2813
|
+
});
|
|
2808
2814
|
return [
|
|
2809
2815
|
3,
|
|
2810
|
-
|
|
2816
|
+
4
|
|
2811
2817
|
];
|
|
2812
|
-
case
|
|
2818
|
+
case 3:
|
|
2813
2819
|
error = _state.sent();
|
|
2814
2820
|
console.error("[StormcloudVideoPlayer] Error sending initial tracking data:", error);
|
|
2815
2821
|
return [
|
|
2816
2822
|
3,
|
|
2817
|
-
|
|
2823
|
+
4
|
|
2818
2824
|
];
|
|
2819
|
-
case
|
|
2825
|
+
case 4:
|
|
2820
2826
|
return [
|
|
2821
2827
|
2
|
|
2822
2828
|
];
|
|
@@ -2920,53 +2926,48 @@ function sendAdImpressionTracking(_0, _1) {
|
|
|
2920
2926
|
switch(_state.label){
|
|
2921
2927
|
case 0:
|
|
2922
2928
|
context = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : {};
|
|
2929
|
+
if (!canPublish(licenseKey)) return [
|
|
2930
|
+
2
|
|
2931
|
+
];
|
|
2923
2932
|
_state.label = 1;
|
|
2924
2933
|
case 1:
|
|
2925
2934
|
_state.trys.push([
|
|
2926
2935
|
1,
|
|
2927
|
-
|
|
2936
|
+
3,
|
|
2928
2937
|
,
|
|
2929
|
-
|
|
2938
|
+
4
|
|
2930
2939
|
]);
|
|
2931
2940
|
return [
|
|
2932
2941
|
4,
|
|
2933
|
-
buildPlayerMetricEvent(
|
|
2942
|
+
buildPlayerMetricEvent(context, {
|
|
2934
2943
|
captureAt: adImpressionInfo.timestamp
|
|
2935
2944
|
})
|
|
2936
2945
|
];
|
|
2937
2946
|
case 2:
|
|
2938
2947
|
metricEvent = _state.sent();
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
capture_at: adImpressionInfo.timestamp
|
|
2951
|
-
}
|
|
2952
|
-
]
|
|
2953
|
-
})
|
|
2954
|
-
])
|
|
2955
|
-
];
|
|
2956
|
-
case 3:
|
|
2957
|
-
_state.sent();
|
|
2948
|
+
publishTracking(licenseKey, "heartbeat", metricEvent);
|
|
2949
|
+
publishTracking(licenseKey, "impressions", {
|
|
2950
|
+
events: [
|
|
2951
|
+
{
|
|
2952
|
+
player_id: metricEvent.player_id,
|
|
2953
|
+
ad_played_count: 1,
|
|
2954
|
+
ad_url: adImpressionInfo.adUrl,
|
|
2955
|
+
capture_at: adImpressionInfo.timestamp
|
|
2956
|
+
}
|
|
2957
|
+
]
|
|
2958
|
+
});
|
|
2958
2959
|
return [
|
|
2959
2960
|
3,
|
|
2960
|
-
|
|
2961
|
+
4
|
|
2961
2962
|
];
|
|
2962
|
-
case
|
|
2963
|
+
case 3:
|
|
2963
2964
|
error = _state.sent();
|
|
2964
2965
|
console.error("[StormcloudVideoPlayer] Error sending ad impression tracking:", error);
|
|
2965
2966
|
return [
|
|
2966
2967
|
3,
|
|
2967
|
-
|
|
2968
|
+
4
|
|
2968
2969
|
];
|
|
2969
|
-
case
|
|
2970
|
+
case 4:
|
|
2970
2971
|
return [
|
|
2971
2972
|
2
|
|
2972
2973
|
];
|
|
@@ -2982,38 +2983,36 @@ function sendHeartbeat(_0) {
|
|
|
2982
2983
|
switch(_state.label){
|
|
2983
2984
|
case 0:
|
|
2984
2985
|
context = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {}, flags = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : {};
|
|
2986
|
+
if (!canPublish(licenseKey)) return [
|
|
2987
|
+
2
|
|
2988
|
+
];
|
|
2985
2989
|
_state.label = 1;
|
|
2986
2990
|
case 1:
|
|
2987
2991
|
_state.trys.push([
|
|
2988
2992
|
1,
|
|
2989
|
-
|
|
2993
|
+
3,
|
|
2990
2994
|
,
|
|
2991
|
-
|
|
2995
|
+
4
|
|
2992
2996
|
]);
|
|
2993
2997
|
return [
|
|
2994
2998
|
4,
|
|
2995
|
-
buildPlayerMetricEvent(
|
|
2999
|
+
buildPlayerMetricEvent(context, flags)
|
|
2996
3000
|
];
|
|
2997
3001
|
case 2:
|
|
2998
3002
|
heartbeatData = _state.sent();
|
|
2999
|
-
|
|
3000
|
-
4,
|
|
3001
|
-
postJson(HEARTBEAT_URL, licenseKey, heartbeatData)
|
|
3002
|
-
];
|
|
3003
|
-
case 3:
|
|
3004
|
-
_state.sent();
|
|
3003
|
+
publishTracking(licenseKey, "heartbeat", heartbeatData);
|
|
3005
3004
|
return [
|
|
3006
3005
|
3,
|
|
3007
|
-
|
|
3006
|
+
4
|
|
3008
3007
|
];
|
|
3009
|
-
case
|
|
3008
|
+
case 3:
|
|
3010
3009
|
error = _state.sent();
|
|
3011
3010
|
console.error("[StormcloudVideoPlayer] Error sending heartbeat:", error);
|
|
3012
3011
|
return [
|
|
3013
3012
|
3,
|
|
3014
|
-
|
|
3013
|
+
4
|
|
3015
3014
|
];
|
|
3016
|
-
case
|
|
3015
|
+
case 4:
|
|
3017
3016
|
return [
|
|
3018
3017
|
2
|
|
3019
3018
|
];
|
|
@@ -3866,7 +3865,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3866
3865
|
_this.showAds = true;
|
|
3867
3866
|
_this.resetGamNoFillCounter();
|
|
3868
3867
|
if (_this.inAdBreak && _this.expectedAdBreakDurationMs != null && _this.adStopTimerId == null) {
|
|
3869
|
-
_this.
|
|
3868
|
+
_this.scheduleAdStopAtBreakBoundary();
|
|
3870
3869
|
if (_this.config.debugAdTiming) {
|
|
3871
3870
|
console.log("[StormcloudVideoPlayer] Starting ad break timer on content_pause (first ad starting)");
|
|
3872
3871
|
}
|
|
@@ -4510,12 +4509,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4510
4509
|
if (marker.durationSeconds != null) {
|
|
4511
4510
|
var newDurationMs = marker.durationSeconds * 1e3;
|
|
4512
4511
|
if (this.expectedAdBreakDurationMs == null || newDurationMs > this.expectedAdBreakDurationMs) {
|
|
4513
|
-
this.
|
|
4514
|
-
|
|
4515
|
-
var remainingMs = Math.max(0, newDurationMs - elapsedMs);
|
|
4516
|
-
this.scheduleAdStopCountdown(remainingMs);
|
|
4512
|
+
this.setAdBreakDurationBoundary(newDurationMs);
|
|
4513
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
4517
4514
|
if (this.config.debugAdTiming) {
|
|
4518
|
-
console.log("[StormcloudVideoPlayer] Updated ad break duration from subsequent marker: ".concat(newDurationMs, "ms, remaining: ").concat(
|
|
4515
|
+
console.log("[StormcloudVideoPlayer] Updated ad break duration from subsequent marker: ".concat(newDurationMs, "ms, remaining: ").concat(this.getRemainingAdMs(), "ms"));
|
|
4519
4516
|
}
|
|
4520
4517
|
}
|
|
4521
4518
|
}
|
|
@@ -4589,13 +4586,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4589
4586
|
}
|
|
4590
4587
|
if (marker.type === "progress" && this.inAdBreak) {
|
|
4591
4588
|
if (marker.durationSeconds != null) {
|
|
4592
|
-
this.
|
|
4593
|
-
}
|
|
4594
|
-
if (this.expectedAdBreakDurationMs != null && this.currentAdBreakStartWallClockMs != null) {
|
|
4595
|
-
var elapsedMs1 = Date.now() - this.currentAdBreakStartWallClockMs;
|
|
4596
|
-
var remainingMs1 = Math.max(0, this.expectedAdBreakDurationMs - elapsedMs1);
|
|
4597
|
-
this.scheduleAdStopCountdown(remainingMs1);
|
|
4589
|
+
this.setAdBreakDurationBoundary(marker.durationSeconds * 1e3);
|
|
4598
4590
|
}
|
|
4591
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
4599
4592
|
if (!this.ima.isAdPlaying() && this.activeAdRequestToken === null && this.adRequestQueue.length > 0) {
|
|
4600
4593
|
this.tryNextAvailableAdWithRateLimit();
|
|
4601
4594
|
}
|
|
@@ -4620,15 +4613,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4620
4613
|
activeAdRequest: this.activeAdRequestToken !== null
|
|
4621
4614
|
});
|
|
4622
4615
|
}
|
|
4623
|
-
|
|
4624
|
-
if (this.config.debugAdTiming) {
|
|
4625
|
-
console.log("[StormcloudVideoPlayer] Ignoring premature SCTE-35 end marker - ads still active");
|
|
4626
|
-
}
|
|
4627
|
-
return;
|
|
4628
|
-
}
|
|
4629
|
-
this.inAdBreak = false;
|
|
4630
|
-
this.expectedAdBreakDurationMs = void 0;
|
|
4631
|
-
this.currentAdBreakStartWallClockMs = void 0;
|
|
4616
|
+
this.scteAdBreakEndWallClockMs = Date.now();
|
|
4632
4617
|
this.clearAdStartTimer();
|
|
4633
4618
|
this.clearAdStopTimer();
|
|
4634
4619
|
if (adPlaying) {
|
|
@@ -4652,14 +4637,48 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4652
4637
|
this.inAdBreak = true;
|
|
4653
4638
|
this.activeScte35BreakKey = cueKey !== null && cueKey !== void 0 ? cueKey : this.pendingScte35CueKey;
|
|
4654
4639
|
this.scheduledScte35BreakKey = void 0;
|
|
4655
|
-
this.
|
|
4656
|
-
this.
|
|
4640
|
+
this.currentAdBreakStartWallClockMs = this.resolveScteBreakStartWallClockMs(marker);
|
|
4641
|
+
this.setAdBreakDurationBoundary(durationMs);
|
|
4657
4642
|
this.handleAdStart(marker);
|
|
4658
|
-
|
|
4659
|
-
|
|
4643
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
4644
|
+
}
|
|
4645
|
+
},
|
|
4646
|
+
{
|
|
4647
|
+
key: "resolveScteBreakStartWallClockMs",
|
|
4648
|
+
value: function resolveScteBreakStartWallClockMs(marker) {
|
|
4649
|
+
var nowWallClockMs = Date.now();
|
|
4650
|
+
if (typeof marker.ptsSeconds !== "number") {
|
|
4651
|
+
return nowWallClockMs;
|
|
4652
|
+
}
|
|
4653
|
+
var nowMs = this.video.currentTime * 1e3;
|
|
4654
|
+
var estimatedCurrentPtsMs = nowMs - this.ptsDriftEmaMs;
|
|
4655
|
+
var deltaMs = marker.ptsSeconds * 1e3 - estimatedCurrentPtsMs;
|
|
4656
|
+
if (!Number.isFinite(deltaMs)) {
|
|
4657
|
+
return nowWallClockMs;
|
|
4658
|
+
}
|
|
4659
|
+
return nowWallClockMs + Math.floor(deltaMs);
|
|
4660
|
+
}
|
|
4661
|
+
},
|
|
4662
|
+
{
|
|
4663
|
+
key: "setAdBreakDurationBoundary",
|
|
4664
|
+
value: function setAdBreakDurationBoundary(durationMs) {
|
|
4665
|
+
this.expectedAdBreakDurationMs = durationMs;
|
|
4666
|
+
if (durationMs != null && this.currentAdBreakStartWallClockMs != null) {
|
|
4667
|
+
this.scteAdBreakEndWallClockMs = this.currentAdBreakStartWallClockMs + durationMs;
|
|
4668
|
+
} else {
|
|
4669
|
+
this.scteAdBreakEndWallClockMs = void 0;
|
|
4660
4670
|
}
|
|
4661
4671
|
}
|
|
4662
4672
|
},
|
|
4673
|
+
{
|
|
4674
|
+
key: "scheduleAdStopAtBreakBoundary",
|
|
4675
|
+
value: function scheduleAdStopAtBreakBoundary() {
|
|
4676
|
+
if (this.expectedAdBreakDurationMs == null) {
|
|
4677
|
+
return;
|
|
4678
|
+
}
|
|
4679
|
+
this.scheduleAdStopCountdown(this.getRemainingAdMs());
|
|
4680
|
+
}
|
|
4681
|
+
},
|
|
4663
4682
|
{
|
|
4664
4683
|
key: "parseCueOutDuration",
|
|
4665
4684
|
value: function parseCueOutDuration(value) {
|
|
@@ -6285,7 +6304,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6285
6304
|
}
|
|
6286
6305
|
}
|
|
6287
6306
|
this.inAdBreak = true;
|
|
6288
|
-
this.currentAdBreakStartWallClockMs = Date.now();
|
|
6289
6307
|
this.currentAdIndex = 0;
|
|
6290
6308
|
this.totalAdsInBreak = 1;
|
|
6291
6309
|
this.adPodQueue = [];
|
|
@@ -6372,7 +6390,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6372
6390
|
case 2:
|
|
6373
6391
|
_state.sent();
|
|
6374
6392
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
6375
|
-
this.
|
|
6393
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
6376
6394
|
}
|
|
6377
6395
|
adVolume = currentMuted ? 0 : currentVolume;
|
|
6378
6396
|
this.ima.setAdVolume(adVolume);
|
|
@@ -6415,7 +6433,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6415
6433
|
case 6:
|
|
6416
6434
|
_state.sent();
|
|
6417
6435
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
6418
|
-
this.
|
|
6436
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
6419
6437
|
}
|
|
6420
6438
|
adVolume1 = currentMuted ? 0 : currentVolume;
|
|
6421
6439
|
this.ima.setAdVolume(adVolume1);
|
|
@@ -6470,7 +6488,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6470
6488
|
case 10:
|
|
6471
6489
|
_state.sent();
|
|
6472
6490
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
6473
|
-
this.
|
|
6491
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
6474
6492
|
}
|
|
6475
6493
|
adVolume2 = currentMuted ? 0 : currentVolume;
|
|
6476
6494
|
this.ima.setAdVolume(adVolume2);
|
|
@@ -6822,7 +6840,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6822
6840
|
case 2:
|
|
6823
6841
|
_state.sent();
|
|
6824
6842
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
6825
|
-
this.
|
|
6843
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
6826
6844
|
}
|
|
6827
6845
|
currentMuted = this.video.muted;
|
|
6828
6846
|
currentVolume = this.video.volume;
|
|
@@ -7322,21 +7340,16 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
7322
7340
|
{
|
|
7323
7341
|
key: "ensureAdStoppedByTimer",
|
|
7324
7342
|
value: function ensureAdStoppedByTimer() {
|
|
7325
|
-
var _this_config_adBreakCheckIntervalMs,
|
|
7343
|
+
var _this_config_adBreakCheckIntervalMs, _this_getAdBreakEndWallClockMs;
|
|
7326
7344
|
if (!this.inAdBreak) return;
|
|
7327
7345
|
this.adStopTimerId = void 0;
|
|
7328
7346
|
var adPlaying = this.ima.isAdPlaying();
|
|
7329
|
-
var pendingAds = this.adPodQueue.length > 0;
|
|
7330
7347
|
var checkIntervalMs = Math.max(250, Math.floor((_this_config_adBreakCheckIntervalMs = this.config.adBreakCheckIntervalMs) !== null && _this_config_adBreakCheckIntervalMs !== void 0 ? _this_config_adBreakCheckIntervalMs : 1e3));
|
|
7331
7348
|
var maxExtensionMsConfig = this.config.maxAdBreakExtensionMs;
|
|
7332
|
-
var maxExtensionMs = typeof maxExtensionMsConfig === "number" && maxExtensionMsConfig > 0 ? maxExtensionMsConfig :
|
|
7333
|
-
var
|
|
7334
|
-
|
|
7335
|
-
|
|
7336
|
-
}
|
|
7337
|
-
var expectedDurationMs = (_this_expectedAdBreakDurationMs = this.expectedAdBreakDurationMs) !== null && _this_expectedAdBreakDurationMs !== void 0 ? _this_expectedAdBreakDurationMs : 0;
|
|
7338
|
-
var overrunMs = Math.max(0, elapsedSinceStartMs - expectedDurationMs);
|
|
7339
|
-
var shouldExtendAdBreak = (adPlaying || pendingAds || this.showAds) && overrunMs < maxExtensionMs;
|
|
7349
|
+
var maxExtensionMs = typeof maxExtensionMsConfig === "number" && maxExtensionMsConfig > 0 ? maxExtensionMsConfig : 0;
|
|
7350
|
+
var endWallClockMs = (_this_getAdBreakEndWallClockMs = this.getAdBreakEndWallClockMs()) !== null && _this_getAdBreakEndWallClockMs !== void 0 ? _this_getAdBreakEndWallClockMs : Date.now();
|
|
7351
|
+
var overrunMs = Math.max(0, Date.now() - endWallClockMs);
|
|
7352
|
+
var shouldExtendAdBreak = adPlaying && overrunMs < maxExtensionMs;
|
|
7340
7353
|
if (shouldExtendAdBreak) {
|
|
7341
7354
|
this.scheduleAdStopCountdown(checkIntervalMs);
|
|
7342
7355
|
return;
|
|
@@ -7602,7 +7615,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
7602
7615
|
case 5:
|
|
7603
7616
|
_state.sent();
|
|
7604
7617
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
7605
|
-
this.
|
|
7618
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
7606
7619
|
}
|
|
7607
7620
|
currentMuted = this.video.muted;
|
|
7608
7621
|
currentVolume = this.video.volume;
|
|
@@ -7652,7 +7665,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
7652
7665
|
case 8:
|
|
7653
7666
|
_state.sent();
|
|
7654
7667
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
7655
|
-
this.
|
|
7668
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
7656
7669
|
}
|
|
7657
7670
|
currentMuted1 = this.video.muted;
|
|
7658
7671
|
currentVolume1 = this.video.volume;
|
|
@@ -7797,6 +7810,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
7797
7810
|
this.scheduledScte35BreakKey = void 0;
|
|
7798
7811
|
this.expectedAdBreakDurationMs = void 0;
|
|
7799
7812
|
this.currentAdBreakStartWallClockMs = void 0;
|
|
7813
|
+
this.scteAdBreakEndWallClockMs = void 0;
|
|
7800
7814
|
this.clearAdStartTimer();
|
|
7801
7815
|
this.clearAdStopTimer();
|
|
7802
7816
|
this.adPodQueue = [];
|
|
@@ -7986,9 +8000,21 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
7986
8000
|
{
|
|
7987
8001
|
key: "getRemainingAdMs",
|
|
7988
8002
|
value: function getRemainingAdMs() {
|
|
7989
|
-
|
|
7990
|
-
|
|
7991
|
-
|
|
8003
|
+
var endWallClockMs = this.getAdBreakEndWallClockMs();
|
|
8004
|
+
if (endWallClockMs != null) {
|
|
8005
|
+
return Math.max(0, endWallClockMs - Date.now());
|
|
8006
|
+
}
|
|
8007
|
+
return 0;
|
|
8008
|
+
}
|
|
8009
|
+
},
|
|
8010
|
+
{
|
|
8011
|
+
key: "getAdBreakEndWallClockMs",
|
|
8012
|
+
value: function getAdBreakEndWallClockMs() {
|
|
8013
|
+
if (this.scteAdBreakEndWallClockMs != null) {
|
|
8014
|
+
return this.scteAdBreakEndWallClockMs;
|
|
8015
|
+
}
|
|
8016
|
+
if (this.expectedAdBreakDurationMs == null || this.currentAdBreakStartWallClockMs == null) return void 0;
|
|
8017
|
+
return this.currentAdBreakStartWallClockMs + this.expectedAdBreakDurationMs;
|
|
7992
8018
|
}
|
|
7993
8019
|
},
|
|
7994
8020
|
{
|