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
package/lib/players/index.cjs
CHANGED
|
@@ -2466,6 +2466,99 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2466
2466
|
}
|
|
2467
2467
|
};
|
|
2468
2468
|
}
|
|
2469
|
+
// src/utils/mqttConfig.ts
|
|
2470
|
+
var DEFAULT_MQTT_CONFIG = {
|
|
2471
|
+
enabled: true,
|
|
2472
|
+
brokerAddress: "vecbae77.ala.us-east-1.emqxsl.com",
|
|
2473
|
+
brokerPort: 8883,
|
|
2474
|
+
wsPort: 8084,
|
|
2475
|
+
username: "for-sonifi",
|
|
2476
|
+
password: "sonifi-mqtt",
|
|
2477
|
+
topicPrefix: "adstorm/players",
|
|
2478
|
+
qos: 1
|
|
2479
|
+
};
|
|
2480
|
+
var mqttConfig = _object_spread({}, DEFAULT_MQTT_CONFIG);
|
|
2481
|
+
function isMQTTEnabled() {
|
|
2482
|
+
return mqttConfig.enabled;
|
|
2483
|
+
}
|
|
2484
|
+
function buildMQTTBrokerUrl() {
|
|
2485
|
+
if (mqttConfig.brokerUrl) return mqttConfig.brokerUrl;
|
|
2486
|
+
return "wss://".concat(mqttConfig.brokerAddress, ":").concat(mqttConfig.wsPort, "/mqtt");
|
|
2487
|
+
}
|
|
2488
|
+
function buildPlayerTopic(licenseKey, channel) {
|
|
2489
|
+
return "".concat(mqttConfig.topicPrefix, "/").concat(licenseKey, "/").concat(channel);
|
|
2490
|
+
}
|
|
2491
|
+
// src/utils/mqttClient.ts
|
|
2492
|
+
var import_mqtt = __toESM(require("mqtt"), 1);
|
|
2493
|
+
var LOG = "[StormcloudVideoPlayer][MQTT]";
|
|
2494
|
+
var client = null;
|
|
2495
|
+
var status = "disconnected";
|
|
2496
|
+
function initMQTTClient() {
|
|
2497
|
+
if (client || !isMQTTEnabled()) return;
|
|
2498
|
+
var url = buildMQTTBrokerUrl();
|
|
2499
|
+
status = "connecting";
|
|
2500
|
+
var clientId = "stormcloud-vp-".concat(Math.random().toString(36).slice(2, 9));
|
|
2501
|
+
try {
|
|
2502
|
+
client = import_mqtt.default.connect(url, {
|
|
2503
|
+
clientId: clientId,
|
|
2504
|
+
username: mqttConfig.username,
|
|
2505
|
+
password: mqttConfig.password,
|
|
2506
|
+
keepalive: 60,
|
|
2507
|
+
clean: true,
|
|
2508
|
+
reconnectPeriod: 5e3,
|
|
2509
|
+
connectTimeout: 1e4,
|
|
2510
|
+
queueQoSZero: false
|
|
2511
|
+
});
|
|
2512
|
+
} catch (err) {
|
|
2513
|
+
status = "error";
|
|
2514
|
+
console.warn("".concat(LOG, " connect() threw:"), err);
|
|
2515
|
+
return;
|
|
2516
|
+
}
|
|
2517
|
+
client.on("connect", function() {
|
|
2518
|
+
status = "connected";
|
|
2519
|
+
console.info("".concat(LOG, " connected to ").concat(url));
|
|
2520
|
+
});
|
|
2521
|
+
client.on("reconnect", function() {
|
|
2522
|
+
status = "connecting";
|
|
2523
|
+
console.info("".concat(LOG, " reconnecting…"));
|
|
2524
|
+
});
|
|
2525
|
+
client.on("offline", function() {
|
|
2526
|
+
status = "disconnected";
|
|
2527
|
+
console.warn("".concat(LOG, " offline"));
|
|
2528
|
+
});
|
|
2529
|
+
client.on("error", function(err) {
|
|
2530
|
+
status = "error";
|
|
2531
|
+
console.warn("".concat(LOG, " error:"), err.message);
|
|
2532
|
+
});
|
|
2533
|
+
client.on("close", function() {
|
|
2534
|
+
if (status === "connected") {
|
|
2535
|
+
status = "disconnected";
|
|
2536
|
+
}
|
|
2537
|
+
});
|
|
2538
|
+
}
|
|
2539
|
+
function ensureMQTTClient() {
|
|
2540
|
+
if (isMQTTEnabled() && !client) {
|
|
2541
|
+
initMQTTClient();
|
|
2542
|
+
}
|
|
2543
|
+
}
|
|
2544
|
+
function publishMQTT(topic, payload) {
|
|
2545
|
+
if (!isMQTTEnabled()) {
|
|
2546
|
+
return false;
|
|
2547
|
+
}
|
|
2548
|
+
ensureMQTTClient();
|
|
2549
|
+
if (!client) {
|
|
2550
|
+
return false;
|
|
2551
|
+
}
|
|
2552
|
+
try {
|
|
2553
|
+
client.publish(topic, JSON.stringify(payload), {
|
|
2554
|
+
qos: mqttConfig.qos
|
|
2555
|
+
});
|
|
2556
|
+
return true;
|
|
2557
|
+
} catch (err) {
|
|
2558
|
+
console.warn("".concat(LOG, " publish failed on ").concat(topic, ":"), err);
|
|
2559
|
+
return false;
|
|
2560
|
+
}
|
|
2561
|
+
}
|
|
2469
2562
|
// src/utils/tracking.ts
|
|
2470
2563
|
var cachedBrowserId = null;
|
|
2471
2564
|
function getClientInfo() {
|
|
@@ -2612,7 +2705,7 @@ function getClientInfo() {
|
|
|
2612
2705
|
}
|
|
2613
2706
|
function getBrowserID(clientInfo) {
|
|
2614
2707
|
return _async_to_generator(function() {
|
|
2615
|
-
var fingerprintString, encodedData, utf8, buffer, i, hashBuffer,
|
|
2708
|
+
var _crypto_subtle, fingerprintString, encodedData, utf8, buffer, i, hashBuffer, hashHex, unused, hash, i1, char, fallbackHash, timestamp, random;
|
|
2616
2709
|
return _ts_generator(this, function(_state) {
|
|
2617
2710
|
switch(_state.label){
|
|
2618
2711
|
case 0:
|
|
@@ -2623,7 +2716,7 @@ function getBrowserID(clientInfo) {
|
|
|
2623
2716
|
];
|
|
2624
2717
|
}
|
|
2625
2718
|
fingerprintString = JSON.stringify(clientInfo);
|
|
2626
|
-
if (!(typeof crypto !== "undefined" && crypto.subtle
|
|
2719
|
+
if (!(typeof crypto !== "undefined" && ((_crypto_subtle = crypto.subtle) === null || _crypto_subtle === void 0 ? void 0 : _crypto_subtle.digest))) return [
|
|
2627
2720
|
3,
|
|
2628
2721
|
5
|
|
2629
2722
|
];
|
|
@@ -2661,8 +2754,7 @@ function getBrowserID(clientInfo) {
|
|
|
2661
2754
|
];
|
|
2662
2755
|
case 3:
|
|
2663
2756
|
hashBuffer = _state.sent();
|
|
2664
|
-
|
|
2665
|
-
hashHex = hashArray.map(function(b) {
|
|
2757
|
+
hashHex = Array.from(new Uint8Array(hashBuffer)).map(function(b) {
|
|
2666
2758
|
return b.toString(16).padStart(2, "0");
|
|
2667
2759
|
}).join("");
|
|
2668
2760
|
cachedBrowserId = hashHex;
|
|
@@ -2671,8 +2763,8 @@ function getBrowserID(clientInfo) {
|
|
|
2671
2763
|
hashHex
|
|
2672
2764
|
];
|
|
2673
2765
|
case 4:
|
|
2674
|
-
|
|
2675
|
-
console.warn("[StormcloudVideoPlayer] crypto.subtle
|
|
2766
|
+
unused = _state.sent();
|
|
2767
|
+
console.warn("[StormcloudVideoPlayer] crypto.subtle not supported, using fallback hash");
|
|
2676
2768
|
return [
|
|
2677
2769
|
3,
|
|
2678
2770
|
5
|
|
@@ -2696,177 +2788,91 @@ function getBrowserID(clientInfo) {
|
|
|
2696
2788
|
});
|
|
2697
2789
|
})();
|
|
2698
2790
|
}
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
var HEARTBEAT_URL = "".concat(PLAYER_TRACKING_BASE_URL, "/heartbeat");
|
|
2702
|
-
var IMPRESSIONS_URL = "".concat(PLAYER_TRACKING_BASE_URL, "/impressions/ingest");
|
|
2703
|
-
function buildHeaders(licenseKey) {
|
|
2704
|
-
var headers = {
|
|
2705
|
-
"Content-Type": "application/json"
|
|
2706
|
-
};
|
|
2707
|
-
if (licenseKey) {
|
|
2708
|
-
headers["Authorization"] = "Bearer ".concat(licenseKey);
|
|
2709
|
-
}
|
|
2710
|
-
return headers;
|
|
2711
|
-
}
|
|
2712
|
-
function sendTrackRequest(licenseKey, body) {
|
|
2713
|
-
return _async_to_generator(function() {
|
|
2714
|
-
var response;
|
|
2715
|
-
return _ts_generator(this, function(_state) {
|
|
2716
|
-
switch(_state.label){
|
|
2717
|
-
case 0:
|
|
2718
|
-
return [
|
|
2719
|
-
4,
|
|
2720
|
-
fetch(TRACK_URL, {
|
|
2721
|
-
method: "POST",
|
|
2722
|
-
headers: buildHeaders(licenseKey),
|
|
2723
|
-
body: JSON.stringify(body)
|
|
2724
|
-
})
|
|
2725
|
-
];
|
|
2726
|
-
case 1:
|
|
2727
|
-
response = _state.sent();
|
|
2728
|
-
if (!response.ok) {
|
|
2729
|
-
throw new Error("HTTP error! status: ".concat(response.status));
|
|
2730
|
-
}
|
|
2731
|
-
return [
|
|
2732
|
-
4,
|
|
2733
|
-
response.json()
|
|
2734
|
-
];
|
|
2735
|
-
case 2:
|
|
2736
|
-
_state.sent();
|
|
2737
|
-
return [
|
|
2738
|
-
2
|
|
2739
|
-
];
|
|
2740
|
-
}
|
|
2741
|
-
});
|
|
2742
|
-
})();
|
|
2791
|
+
function canPublish(licenseKey) {
|
|
2792
|
+
return Boolean(isMQTTEnabled() && licenseKey);
|
|
2743
2793
|
}
|
|
2744
|
-
function
|
|
2794
|
+
function buildPlayerMetricEvent() {
|
|
2745
2795
|
return _async_to_generator(function() {
|
|
2746
|
-
var
|
|
2747
|
-
return _ts_generator(this, function(_state) {
|
|
2748
|
-
switch(_state.label){
|
|
2749
|
-
case 0:
|
|
2750
|
-
return [
|
|
2751
|
-
4,
|
|
2752
|
-
fetch(url, {
|
|
2753
|
-
method: "POST",
|
|
2754
|
-
headers: buildHeaders(licenseKey),
|
|
2755
|
-
body: JSON.stringify(body)
|
|
2756
|
-
})
|
|
2757
|
-
];
|
|
2758
|
-
case 1:
|
|
2759
|
-
response = _state.sent();
|
|
2760
|
-
if (!response.ok) {
|
|
2761
|
-
throw new Error("HTTP error! status: ".concat(response.status));
|
|
2762
|
-
}
|
|
2763
|
-
return [
|
|
2764
|
-
4,
|
|
2765
|
-
response.json()
|
|
2766
|
-
];
|
|
2767
|
-
case 2:
|
|
2768
|
-
_state.sent();
|
|
2769
|
-
return [
|
|
2770
|
-
2
|
|
2771
|
-
];
|
|
2772
|
-
}
|
|
2773
|
-
});
|
|
2774
|
-
})();
|
|
2775
|
-
}
|
|
2776
|
-
function buildPlayerMetricEvent(_0) {
|
|
2777
|
-
return _async_to_generator(function(licenseKey) {
|
|
2778
|
-
var context, flags, _flags_captureAt, clientInfo, browserId, captureAt;
|
|
2796
|
+
var context, flags, _flags_captureAt, _flags_adLoaded, _flags_adDetect, clientInfo, playerId, captureAt;
|
|
2779
2797
|
var _arguments = arguments;
|
|
2780
2798
|
return _ts_generator(this, function(_state) {
|
|
2781
2799
|
switch(_state.label){
|
|
2782
2800
|
case 0:
|
|
2783
|
-
context = _arguments.length >
|
|
2801
|
+
context = _arguments.length > 0 && _arguments[0] !== void 0 ? _arguments[0] : {}, flags = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {};
|
|
2784
2802
|
clientInfo = getClientInfo();
|
|
2785
2803
|
return [
|
|
2786
2804
|
4,
|
|
2787
2805
|
getBrowserID(clientInfo)
|
|
2788
2806
|
];
|
|
2789
2807
|
case 1:
|
|
2790
|
-
|
|
2808
|
+
playerId = _state.sent();
|
|
2791
2809
|
captureAt = (_flags_captureAt = flags.captureAt) !== null && _flags_captureAt !== void 0 ? _flags_captureAt : /* @__PURE__ */ new Date().toISOString();
|
|
2792
2810
|
return [
|
|
2793
2811
|
2,
|
|
2794
|
-
{
|
|
2795
|
-
player_id:
|
|
2796
|
-
browserId: browserId,
|
|
2812
|
+
_object_spread({
|
|
2813
|
+
player_id: playerId,
|
|
2797
2814
|
device_type: clientInfo.deviceType,
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
timestamp: captureAt
|
|
2806
|
-
}
|
|
2815
|
+
os: clientInfo.os.toLowerCase(),
|
|
2816
|
+
ad_loaded: (_flags_adLoaded = flags.adLoaded) !== null && _flags_adLoaded !== void 0 ? _flags_adLoaded : false,
|
|
2817
|
+
ad_detect: (_flags_adDetect = flags.adDetect) !== null && _flags_adDetect !== void 0 ? _flags_adDetect : false,
|
|
2818
|
+
capture_at: captureAt
|
|
2819
|
+
}, context.inputStreamType ? {
|
|
2820
|
+
input_stream_type: context.inputStreamType
|
|
2821
|
+
} : {})
|
|
2807
2822
|
];
|
|
2808
2823
|
}
|
|
2809
2824
|
});
|
|
2810
2825
|
}).apply(this, arguments);
|
|
2811
2826
|
}
|
|
2827
|
+
function publishTracking(licenseKey, channel, body) {
|
|
2828
|
+
ensureMQTTClient();
|
|
2829
|
+
publishMQTT(buildPlayerTopic(licenseKey, channel), body);
|
|
2830
|
+
}
|
|
2812
2831
|
function sendInitialTracking(_0) {
|
|
2813
2832
|
return _async_to_generator(function(licenseKey) {
|
|
2814
|
-
var context,
|
|
2833
|
+
var context, metricEvent, error;
|
|
2815
2834
|
var _arguments = arguments;
|
|
2816
2835
|
return _ts_generator(this, function(_state) {
|
|
2817
2836
|
switch(_state.label){
|
|
2818
2837
|
case 0:
|
|
2819
2838
|
context = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {};
|
|
2839
|
+
if (!canPublish(licenseKey)) return [
|
|
2840
|
+
2
|
|
2841
|
+
];
|
|
2820
2842
|
_state.label = 1;
|
|
2821
2843
|
case 1:
|
|
2822
2844
|
_state.trys.push([
|
|
2823
2845
|
1,
|
|
2824
|
-
|
|
2846
|
+
3,
|
|
2825
2847
|
,
|
|
2826
|
-
|
|
2848
|
+
4
|
|
2827
2849
|
]);
|
|
2828
|
-
clientInfo = getClientInfo();
|
|
2829
2850
|
return [
|
|
2830
2851
|
4,
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
browserId = _state.sent();
|
|
2835
|
-
trackingData = _object_spread({
|
|
2836
|
-
browserId: browserId
|
|
2837
|
-
}, clientInfo);
|
|
2838
|
-
return [
|
|
2839
|
-
4,
|
|
2840
|
-
sendTrackRequest(licenseKey, {
|
|
2841
|
-
events: [
|
|
2842
|
-
{
|
|
2843
|
-
player_id: browserId,
|
|
2844
|
-
device_type: clientInfo.deviceType,
|
|
2845
|
-
input_stream_type: context.inputStreamType,
|
|
2846
|
-
os: clientInfo.os,
|
|
2847
|
-
ad_loaded: false,
|
|
2848
|
-
ad_detect: false,
|
|
2849
|
-
license_key: licenseKey,
|
|
2850
|
-
capture_at: /* @__PURE__ */ new Date().toISOString()
|
|
2851
|
-
}
|
|
2852
|
-
],
|
|
2853
|
-
trackingData: trackingData
|
|
2852
|
+
buildPlayerMetricEvent(context, {
|
|
2853
|
+
adLoaded: false,
|
|
2854
|
+
adDetect: false
|
|
2854
2855
|
})
|
|
2855
2856
|
];
|
|
2856
|
-
case
|
|
2857
|
-
_state.sent();
|
|
2857
|
+
case 2:
|
|
2858
|
+
metricEvent = _state.sent();
|
|
2859
|
+
publishTracking(licenseKey, "metrics", {
|
|
2860
|
+
events: [
|
|
2861
|
+
metricEvent
|
|
2862
|
+
]
|
|
2863
|
+
});
|
|
2858
2864
|
return [
|
|
2859
2865
|
3,
|
|
2860
|
-
|
|
2866
|
+
4
|
|
2861
2867
|
];
|
|
2862
|
-
case
|
|
2868
|
+
case 3:
|
|
2863
2869
|
error = _state.sent();
|
|
2864
2870
|
console.error("[StormcloudVideoPlayer] Error sending initial tracking data:", error);
|
|
2865
2871
|
return [
|
|
2866
2872
|
3,
|
|
2867
|
-
|
|
2873
|
+
4
|
|
2868
2874
|
];
|
|
2869
|
-
case
|
|
2875
|
+
case 4:
|
|
2870
2876
|
return [
|
|
2871
2877
|
2
|
|
2872
2878
|
];
|
|
@@ -2970,53 +2976,48 @@ function sendAdImpressionTracking(_0, _1) {
|
|
|
2970
2976
|
switch(_state.label){
|
|
2971
2977
|
case 0:
|
|
2972
2978
|
context = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : {};
|
|
2979
|
+
if (!canPublish(licenseKey)) return [
|
|
2980
|
+
2
|
|
2981
|
+
];
|
|
2973
2982
|
_state.label = 1;
|
|
2974
2983
|
case 1:
|
|
2975
2984
|
_state.trys.push([
|
|
2976
2985
|
1,
|
|
2977
|
-
|
|
2986
|
+
3,
|
|
2978
2987
|
,
|
|
2979
|
-
|
|
2988
|
+
4
|
|
2980
2989
|
]);
|
|
2981
2990
|
return [
|
|
2982
2991
|
4,
|
|
2983
|
-
buildPlayerMetricEvent(
|
|
2992
|
+
buildPlayerMetricEvent(context, {
|
|
2984
2993
|
captureAt: adImpressionInfo.timestamp
|
|
2985
2994
|
})
|
|
2986
2995
|
];
|
|
2987
2996
|
case 2:
|
|
2988
2997
|
metricEvent = _state.sent();
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
capture_at: adImpressionInfo.timestamp
|
|
3001
|
-
}
|
|
3002
|
-
]
|
|
3003
|
-
})
|
|
3004
|
-
])
|
|
3005
|
-
];
|
|
3006
|
-
case 3:
|
|
3007
|
-
_state.sent();
|
|
2998
|
+
publishTracking(licenseKey, "heartbeat", metricEvent);
|
|
2999
|
+
publishTracking(licenseKey, "impressions", {
|
|
3000
|
+
events: [
|
|
3001
|
+
{
|
|
3002
|
+
player_id: metricEvent.player_id,
|
|
3003
|
+
ad_played_count: 1,
|
|
3004
|
+
ad_url: adImpressionInfo.adUrl,
|
|
3005
|
+
capture_at: adImpressionInfo.timestamp
|
|
3006
|
+
}
|
|
3007
|
+
]
|
|
3008
|
+
});
|
|
3008
3009
|
return [
|
|
3009
3010
|
3,
|
|
3010
|
-
|
|
3011
|
+
4
|
|
3011
3012
|
];
|
|
3012
|
-
case
|
|
3013
|
+
case 3:
|
|
3013
3014
|
error = _state.sent();
|
|
3014
3015
|
console.error("[StormcloudVideoPlayer] Error sending ad impression tracking:", error);
|
|
3015
3016
|
return [
|
|
3016
3017
|
3,
|
|
3017
|
-
|
|
3018
|
+
4
|
|
3018
3019
|
];
|
|
3019
|
-
case
|
|
3020
|
+
case 4:
|
|
3020
3021
|
return [
|
|
3021
3022
|
2
|
|
3022
3023
|
];
|
|
@@ -3032,38 +3033,36 @@ function sendHeartbeat(_0) {
|
|
|
3032
3033
|
switch(_state.label){
|
|
3033
3034
|
case 0:
|
|
3034
3035
|
context = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {}, flags = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : {};
|
|
3036
|
+
if (!canPublish(licenseKey)) return [
|
|
3037
|
+
2
|
|
3038
|
+
];
|
|
3035
3039
|
_state.label = 1;
|
|
3036
3040
|
case 1:
|
|
3037
3041
|
_state.trys.push([
|
|
3038
3042
|
1,
|
|
3039
|
-
|
|
3043
|
+
3,
|
|
3040
3044
|
,
|
|
3041
|
-
|
|
3045
|
+
4
|
|
3042
3046
|
]);
|
|
3043
3047
|
return [
|
|
3044
3048
|
4,
|
|
3045
|
-
buildPlayerMetricEvent(
|
|
3049
|
+
buildPlayerMetricEvent(context, flags)
|
|
3046
3050
|
];
|
|
3047
3051
|
case 2:
|
|
3048
3052
|
heartbeatData = _state.sent();
|
|
3049
|
-
|
|
3050
|
-
4,
|
|
3051
|
-
postJson(HEARTBEAT_URL, licenseKey, heartbeatData)
|
|
3052
|
-
];
|
|
3053
|
-
case 3:
|
|
3054
|
-
_state.sent();
|
|
3053
|
+
publishTracking(licenseKey, "heartbeat", heartbeatData);
|
|
3055
3054
|
return [
|
|
3056
3055
|
3,
|
|
3057
|
-
|
|
3056
|
+
4
|
|
3058
3057
|
];
|
|
3059
|
-
case
|
|
3058
|
+
case 3:
|
|
3060
3059
|
error = _state.sent();
|
|
3061
3060
|
console.error("[StormcloudVideoPlayer] Error sending heartbeat:", error);
|
|
3062
3061
|
return [
|
|
3063
3062
|
3,
|
|
3064
|
-
|
|
3063
|
+
4
|
|
3065
3064
|
];
|
|
3066
|
-
case
|
|
3065
|
+
case 4:
|
|
3067
3066
|
return [
|
|
3068
3067
|
2
|
|
3069
3068
|
];
|
|
@@ -3916,7 +3915,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3916
3915
|
_this.showAds = true;
|
|
3917
3916
|
_this.resetGamNoFillCounter();
|
|
3918
3917
|
if (_this.inAdBreak && _this.expectedAdBreakDurationMs != null && _this.adStopTimerId == null) {
|
|
3919
|
-
_this.
|
|
3918
|
+
_this.scheduleAdStopAtBreakBoundary();
|
|
3920
3919
|
if (_this.config.debugAdTiming) {
|
|
3921
3920
|
console.log("[StormcloudVideoPlayer] Starting ad break timer on content_pause (first ad starting)");
|
|
3922
3921
|
}
|
|
@@ -4560,12 +4559,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4560
4559
|
if (marker.durationSeconds != null) {
|
|
4561
4560
|
var newDurationMs = marker.durationSeconds * 1e3;
|
|
4562
4561
|
if (this.expectedAdBreakDurationMs == null || newDurationMs > this.expectedAdBreakDurationMs) {
|
|
4563
|
-
this.
|
|
4564
|
-
|
|
4565
|
-
var remainingMs = Math.max(0, newDurationMs - elapsedMs);
|
|
4566
|
-
this.scheduleAdStopCountdown(remainingMs);
|
|
4562
|
+
this.setAdBreakDurationBoundary(newDurationMs);
|
|
4563
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
4567
4564
|
if (this.config.debugAdTiming) {
|
|
4568
|
-
console.log("[StormcloudVideoPlayer] Updated ad break duration from subsequent marker: ".concat(newDurationMs, "ms, remaining: ").concat(
|
|
4565
|
+
console.log("[StormcloudVideoPlayer] Updated ad break duration from subsequent marker: ".concat(newDurationMs, "ms, remaining: ").concat(this.getRemainingAdMs(), "ms"));
|
|
4569
4566
|
}
|
|
4570
4567
|
}
|
|
4571
4568
|
}
|
|
@@ -4639,13 +4636,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4639
4636
|
}
|
|
4640
4637
|
if (marker.type === "progress" && this.inAdBreak) {
|
|
4641
4638
|
if (marker.durationSeconds != null) {
|
|
4642
|
-
this.
|
|
4643
|
-
}
|
|
4644
|
-
if (this.expectedAdBreakDurationMs != null && this.currentAdBreakStartWallClockMs != null) {
|
|
4645
|
-
var elapsedMs1 = Date.now() - this.currentAdBreakStartWallClockMs;
|
|
4646
|
-
var remainingMs1 = Math.max(0, this.expectedAdBreakDurationMs - elapsedMs1);
|
|
4647
|
-
this.scheduleAdStopCountdown(remainingMs1);
|
|
4639
|
+
this.setAdBreakDurationBoundary(marker.durationSeconds * 1e3);
|
|
4648
4640
|
}
|
|
4641
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
4649
4642
|
if (!this.ima.isAdPlaying() && this.activeAdRequestToken === null && this.adRequestQueue.length > 0) {
|
|
4650
4643
|
this.tryNextAvailableAdWithRateLimit();
|
|
4651
4644
|
}
|
|
@@ -4670,15 +4663,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4670
4663
|
activeAdRequest: this.activeAdRequestToken !== null
|
|
4671
4664
|
});
|
|
4672
4665
|
}
|
|
4673
|
-
|
|
4674
|
-
if (this.config.debugAdTiming) {
|
|
4675
|
-
console.log("[StormcloudVideoPlayer] Ignoring premature SCTE-35 end marker - ads still active");
|
|
4676
|
-
}
|
|
4677
|
-
return;
|
|
4678
|
-
}
|
|
4679
|
-
this.inAdBreak = false;
|
|
4680
|
-
this.expectedAdBreakDurationMs = void 0;
|
|
4681
|
-
this.currentAdBreakStartWallClockMs = void 0;
|
|
4666
|
+
this.scteAdBreakEndWallClockMs = Date.now();
|
|
4682
4667
|
this.clearAdStartTimer();
|
|
4683
4668
|
this.clearAdStopTimer();
|
|
4684
4669
|
if (adPlaying) {
|
|
@@ -4702,12 +4687,46 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4702
4687
|
this.inAdBreak = true;
|
|
4703
4688
|
this.activeScte35BreakKey = cueKey !== null && cueKey !== void 0 ? cueKey : this.pendingScte35CueKey;
|
|
4704
4689
|
this.scheduledScte35BreakKey = void 0;
|
|
4705
|
-
this.
|
|
4706
|
-
this.
|
|
4690
|
+
this.currentAdBreakStartWallClockMs = this.resolveScteBreakStartWallClockMs(marker);
|
|
4691
|
+
this.setAdBreakDurationBoundary(durationMs);
|
|
4707
4692
|
this.handleAdStart(marker);
|
|
4708
|
-
|
|
4709
|
-
|
|
4693
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
4694
|
+
}
|
|
4695
|
+
},
|
|
4696
|
+
{
|
|
4697
|
+
key: "resolveScteBreakStartWallClockMs",
|
|
4698
|
+
value: function resolveScteBreakStartWallClockMs(marker) {
|
|
4699
|
+
var nowWallClockMs = Date.now();
|
|
4700
|
+
if (typeof marker.ptsSeconds !== "number") {
|
|
4701
|
+
return nowWallClockMs;
|
|
4710
4702
|
}
|
|
4703
|
+
var nowMs = this.video.currentTime * 1e3;
|
|
4704
|
+
var estimatedCurrentPtsMs = nowMs - this.ptsDriftEmaMs;
|
|
4705
|
+
var deltaMs = marker.ptsSeconds * 1e3 - estimatedCurrentPtsMs;
|
|
4706
|
+
if (!Number.isFinite(deltaMs)) {
|
|
4707
|
+
return nowWallClockMs;
|
|
4708
|
+
}
|
|
4709
|
+
return nowWallClockMs + Math.floor(deltaMs);
|
|
4710
|
+
}
|
|
4711
|
+
},
|
|
4712
|
+
{
|
|
4713
|
+
key: "setAdBreakDurationBoundary",
|
|
4714
|
+
value: function setAdBreakDurationBoundary(durationMs) {
|
|
4715
|
+
this.expectedAdBreakDurationMs = durationMs;
|
|
4716
|
+
if (durationMs != null && this.currentAdBreakStartWallClockMs != null) {
|
|
4717
|
+
this.scteAdBreakEndWallClockMs = this.currentAdBreakStartWallClockMs + durationMs;
|
|
4718
|
+
} else {
|
|
4719
|
+
this.scteAdBreakEndWallClockMs = void 0;
|
|
4720
|
+
}
|
|
4721
|
+
}
|
|
4722
|
+
},
|
|
4723
|
+
{
|
|
4724
|
+
key: "scheduleAdStopAtBreakBoundary",
|
|
4725
|
+
value: function scheduleAdStopAtBreakBoundary() {
|
|
4726
|
+
if (this.expectedAdBreakDurationMs == null) {
|
|
4727
|
+
return;
|
|
4728
|
+
}
|
|
4729
|
+
this.scheduleAdStopCountdown(this.getRemainingAdMs());
|
|
4711
4730
|
}
|
|
4712
4731
|
},
|
|
4713
4732
|
{
|
|
@@ -6335,7 +6354,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6335
6354
|
}
|
|
6336
6355
|
}
|
|
6337
6356
|
this.inAdBreak = true;
|
|
6338
|
-
this.currentAdBreakStartWallClockMs = Date.now();
|
|
6339
6357
|
this.currentAdIndex = 0;
|
|
6340
6358
|
this.totalAdsInBreak = 1;
|
|
6341
6359
|
this.adPodQueue = [];
|
|
@@ -6422,7 +6440,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6422
6440
|
case 2:
|
|
6423
6441
|
_state.sent();
|
|
6424
6442
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
6425
|
-
this.
|
|
6443
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
6426
6444
|
}
|
|
6427
6445
|
adVolume = currentMuted ? 0 : currentVolume;
|
|
6428
6446
|
this.ima.setAdVolume(adVolume);
|
|
@@ -6465,7 +6483,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6465
6483
|
case 6:
|
|
6466
6484
|
_state.sent();
|
|
6467
6485
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
6468
|
-
this.
|
|
6486
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
6469
6487
|
}
|
|
6470
6488
|
adVolume1 = currentMuted ? 0 : currentVolume;
|
|
6471
6489
|
this.ima.setAdVolume(adVolume1);
|
|
@@ -6520,7 +6538,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6520
6538
|
case 10:
|
|
6521
6539
|
_state.sent();
|
|
6522
6540
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
6523
|
-
this.
|
|
6541
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
6524
6542
|
}
|
|
6525
6543
|
adVolume2 = currentMuted ? 0 : currentVolume;
|
|
6526
6544
|
this.ima.setAdVolume(adVolume2);
|
|
@@ -6872,7 +6890,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6872
6890
|
case 2:
|
|
6873
6891
|
_state.sent();
|
|
6874
6892
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
6875
|
-
this.
|
|
6893
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
6876
6894
|
}
|
|
6877
6895
|
currentMuted = this.video.muted;
|
|
6878
6896
|
currentVolume = this.video.volume;
|
|
@@ -7372,21 +7390,16 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
7372
7390
|
{
|
|
7373
7391
|
key: "ensureAdStoppedByTimer",
|
|
7374
7392
|
value: function ensureAdStoppedByTimer() {
|
|
7375
|
-
var _this_config_adBreakCheckIntervalMs,
|
|
7393
|
+
var _this_config_adBreakCheckIntervalMs, _this_getAdBreakEndWallClockMs;
|
|
7376
7394
|
if (!this.inAdBreak) return;
|
|
7377
7395
|
this.adStopTimerId = void 0;
|
|
7378
7396
|
var adPlaying = this.ima.isAdPlaying();
|
|
7379
|
-
var pendingAds = this.adPodQueue.length > 0;
|
|
7380
7397
|
var checkIntervalMs = Math.max(250, Math.floor((_this_config_adBreakCheckIntervalMs = this.config.adBreakCheckIntervalMs) !== null && _this_config_adBreakCheckIntervalMs !== void 0 ? _this_config_adBreakCheckIntervalMs : 1e3));
|
|
7381
7398
|
var maxExtensionMsConfig = this.config.maxAdBreakExtensionMs;
|
|
7382
|
-
var maxExtensionMs = typeof maxExtensionMsConfig === "number" && maxExtensionMsConfig > 0 ? maxExtensionMsConfig :
|
|
7383
|
-
var
|
|
7384
|
-
|
|
7385
|
-
|
|
7386
|
-
}
|
|
7387
|
-
var expectedDurationMs = (_this_expectedAdBreakDurationMs = this.expectedAdBreakDurationMs) !== null && _this_expectedAdBreakDurationMs !== void 0 ? _this_expectedAdBreakDurationMs : 0;
|
|
7388
|
-
var overrunMs = Math.max(0, elapsedSinceStartMs - expectedDurationMs);
|
|
7389
|
-
var shouldExtendAdBreak = (adPlaying || pendingAds || this.showAds) && overrunMs < maxExtensionMs;
|
|
7399
|
+
var maxExtensionMs = typeof maxExtensionMsConfig === "number" && maxExtensionMsConfig > 0 ? maxExtensionMsConfig : 0;
|
|
7400
|
+
var endWallClockMs = (_this_getAdBreakEndWallClockMs = this.getAdBreakEndWallClockMs()) !== null && _this_getAdBreakEndWallClockMs !== void 0 ? _this_getAdBreakEndWallClockMs : Date.now();
|
|
7401
|
+
var overrunMs = Math.max(0, Date.now() - endWallClockMs);
|
|
7402
|
+
var shouldExtendAdBreak = adPlaying && overrunMs < maxExtensionMs;
|
|
7390
7403
|
if (shouldExtendAdBreak) {
|
|
7391
7404
|
this.scheduleAdStopCountdown(checkIntervalMs);
|
|
7392
7405
|
return;
|
|
@@ -7652,7 +7665,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
7652
7665
|
case 5:
|
|
7653
7666
|
_state.sent();
|
|
7654
7667
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
7655
|
-
this.
|
|
7668
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
7656
7669
|
}
|
|
7657
7670
|
currentMuted = this.video.muted;
|
|
7658
7671
|
currentVolume = this.video.volume;
|
|
@@ -7702,7 +7715,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
7702
7715
|
case 8:
|
|
7703
7716
|
_state.sent();
|
|
7704
7717
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
7705
|
-
this.
|
|
7718
|
+
this.scheduleAdStopAtBreakBoundary();
|
|
7706
7719
|
}
|
|
7707
7720
|
currentMuted1 = this.video.muted;
|
|
7708
7721
|
currentVolume1 = this.video.volume;
|
|
@@ -7847,6 +7860,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
7847
7860
|
this.scheduledScte35BreakKey = void 0;
|
|
7848
7861
|
this.expectedAdBreakDurationMs = void 0;
|
|
7849
7862
|
this.currentAdBreakStartWallClockMs = void 0;
|
|
7863
|
+
this.scteAdBreakEndWallClockMs = void 0;
|
|
7850
7864
|
this.clearAdStartTimer();
|
|
7851
7865
|
this.clearAdStopTimer();
|
|
7852
7866
|
this.adPodQueue = [];
|
|
@@ -8036,9 +8050,21 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
8036
8050
|
{
|
|
8037
8051
|
key: "getRemainingAdMs",
|
|
8038
8052
|
value: function getRemainingAdMs() {
|
|
8039
|
-
|
|
8040
|
-
|
|
8041
|
-
|
|
8053
|
+
var endWallClockMs = this.getAdBreakEndWallClockMs();
|
|
8054
|
+
if (endWallClockMs != null) {
|
|
8055
|
+
return Math.max(0, endWallClockMs - Date.now());
|
|
8056
|
+
}
|
|
8057
|
+
return 0;
|
|
8058
|
+
}
|
|
8059
|
+
},
|
|
8060
|
+
{
|
|
8061
|
+
key: "getAdBreakEndWallClockMs",
|
|
8062
|
+
value: function getAdBreakEndWallClockMs() {
|
|
8063
|
+
if (this.scteAdBreakEndWallClockMs != null) {
|
|
8064
|
+
return this.scteAdBreakEndWallClockMs;
|
|
8065
|
+
}
|
|
8066
|
+
if (this.expectedAdBreakDurationMs == null || this.currentAdBreakStartWallClockMs == null) return void 0;
|
|
8067
|
+
return this.currentAdBreakStartWallClockMs + this.expectedAdBreakDurationMs;
|
|
8042
8068
|
}
|
|
8043
8069
|
},
|
|
8044
8070
|
{
|