stormcloud-video-player 0.6.11 → 0.6.12
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 +195 -97
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +10 -1
- package/lib/index.d.ts +10 -1
- package/lib/index.js +172 -98
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +161 -95
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/player/StormcloudVideoPlayer.d.cts +1 -1
- package/lib/players/HlsPlayer.cjs +161 -95
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.d.cts +1 -1
- package/lib/players/index.cjs +161 -95
- package/lib/players/index.cjs.map +1 -1
- package/lib/sdk/vastAdLayer.d.cts +1 -1
- package/lib/sdk/vastManager.d.cts +1 -1
- package/lib/{types-DSKC4ySr.d.cts → types-FjAlGhAL.d.cts} +1 -0
- package/lib/ui/StormcloudVideoPlayer.cjs +165 -97
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.d.cts +1 -1
- package/lib/utils/mqttClient.cjs +174 -0
- package/lib/utils/mqttClient.cjs.map +1 -0
- package/lib/utils/mqttClient.d.cts +9 -0
- package/lib/utils/tracking.cjs +119 -96
- package/lib/utils/tracking.cjs.map +1 -1
- package/lib/utils/tracking.d.cts +3 -2
- package/package.json +2 -1
package/lib/index.cjs
CHANGED
|
@@ -473,6 +473,9 @@ __export(index_exports, {
|
|
|
473
473
|
detectBrowser: function detectBrowser1() {
|
|
474
474
|
return detectBrowser;
|
|
475
475
|
},
|
|
476
|
+
disconnectMQTT: function disconnectMQTT1() {
|
|
477
|
+
return disconnectMQTT;
|
|
478
|
+
},
|
|
476
479
|
getBrowserConfigOverrides: function getBrowserConfigOverrides1() {
|
|
477
480
|
return getBrowserConfigOverrides;
|
|
478
481
|
},
|
|
@@ -482,9 +485,21 @@ __export(index_exports, {
|
|
|
482
485
|
getClientInfo: function getClientInfo1() {
|
|
483
486
|
return getClientInfo;
|
|
484
487
|
},
|
|
488
|
+
getMQTTStatus: function getMQTTStatus1() {
|
|
489
|
+
return getMQTTStatus;
|
|
490
|
+
},
|
|
491
|
+
initMQTTClient: function initMQTTClient1() {
|
|
492
|
+
return initMQTTClient;
|
|
493
|
+
},
|
|
485
494
|
initializePolyfills: function initializePolyfills1() {
|
|
486
495
|
return initializePolyfills;
|
|
487
496
|
},
|
|
497
|
+
isMQTTConfigured: function isMQTTConfigured1() {
|
|
498
|
+
return isMQTTConfigured;
|
|
499
|
+
},
|
|
500
|
+
isMQTTConnected: function isMQTTConnected1() {
|
|
501
|
+
return isMQTTConnected;
|
|
502
|
+
},
|
|
488
503
|
isMediaStream: function isMediaStream1() {
|
|
489
504
|
return isMediaStream;
|
|
490
505
|
},
|
|
@@ -506,6 +521,9 @@ __export(index_exports, {
|
|
|
506
521
|
players: function players() {
|
|
507
522
|
return players_default;
|
|
508
523
|
},
|
|
524
|
+
publishMQTT: function publishMQTT1() {
|
|
525
|
+
return publishMQTT;
|
|
526
|
+
},
|
|
509
527
|
randomString: function randomString1() {
|
|
510
528
|
return randomString;
|
|
511
529
|
},
|
|
@@ -2190,6 +2208,85 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
2190
2208
|
}
|
|
2191
2209
|
};
|
|
2192
2210
|
}
|
|
2211
|
+
// src/utils/mqttClient.ts
|
|
2212
|
+
var import_mqtt = __toESM(require("mqtt"), 1);
|
|
2213
|
+
var LOG2 = "[StormcloudVideoPlayer][MQTT]";
|
|
2214
|
+
var client = null;
|
|
2215
|
+
var status = "disconnected";
|
|
2216
|
+
var brokerUrl = "";
|
|
2217
|
+
function getMQTTStatus() {
|
|
2218
|
+
return status;
|
|
2219
|
+
}
|
|
2220
|
+
function isMQTTConnected() {
|
|
2221
|
+
return status === "connected" && client !== null && client.connected;
|
|
2222
|
+
}
|
|
2223
|
+
function isMQTTConfigured() {
|
|
2224
|
+
return client !== null;
|
|
2225
|
+
}
|
|
2226
|
+
function initMQTTClient(url) {
|
|
2227
|
+
var _topicPrefix = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "adstorm";
|
|
2228
|
+
if (client) return;
|
|
2229
|
+
brokerUrl = url;
|
|
2230
|
+
status = "connecting";
|
|
2231
|
+
var clientId = "stormcloud-vp-".concat(Math.random().toString(36).slice(2, 9));
|
|
2232
|
+
try {
|
|
2233
|
+
client = import_mqtt.default.connect(url, {
|
|
2234
|
+
clientId: clientId,
|
|
2235
|
+
keepalive: 60,
|
|
2236
|
+
clean: true,
|
|
2237
|
+
reconnectPeriod: 5e3,
|
|
2238
|
+
connectTimeout: 1e4,
|
|
2239
|
+
queueQoSZero: false
|
|
2240
|
+
});
|
|
2241
|
+
} catch (err) {
|
|
2242
|
+
status = "error";
|
|
2243
|
+
console.warn("".concat(LOG2, " connect() threw:"), err);
|
|
2244
|
+
return;
|
|
2245
|
+
}
|
|
2246
|
+
client.on("connect", function() {
|
|
2247
|
+
status = "connected";
|
|
2248
|
+
console.info("".concat(LOG2, " connected to ").concat(url));
|
|
2249
|
+
});
|
|
2250
|
+
client.on("reconnect", function() {
|
|
2251
|
+
status = "connecting";
|
|
2252
|
+
console.info("".concat(LOG2, " reconnecting…"));
|
|
2253
|
+
});
|
|
2254
|
+
client.on("offline", function() {
|
|
2255
|
+
status = "disconnected";
|
|
2256
|
+
console.warn("".concat(LOG2, " offline"));
|
|
2257
|
+
});
|
|
2258
|
+
client.on("error", function(err) {
|
|
2259
|
+
status = "error";
|
|
2260
|
+
console.warn("".concat(LOG2, " error:"), err.message);
|
|
2261
|
+
});
|
|
2262
|
+
client.on("close", function() {
|
|
2263
|
+
if (status === "connected") {
|
|
2264
|
+
status = "disconnected";
|
|
2265
|
+
}
|
|
2266
|
+
});
|
|
2267
|
+
}
|
|
2268
|
+
function publishMQTT(topic, payload) {
|
|
2269
|
+
if (!client) {
|
|
2270
|
+
return false;
|
|
2271
|
+
}
|
|
2272
|
+
try {
|
|
2273
|
+
client.publish(topic, JSON.stringify(payload), {
|
|
2274
|
+
qos: 1
|
|
2275
|
+
});
|
|
2276
|
+
return true;
|
|
2277
|
+
} catch (err) {
|
|
2278
|
+
console.warn("".concat(LOG2, " publish failed on ").concat(topic, ":"), err);
|
|
2279
|
+
return false;
|
|
2280
|
+
}
|
|
2281
|
+
}
|
|
2282
|
+
function disconnectMQTT() {
|
|
2283
|
+
if (client) {
|
|
2284
|
+
client.end(true);
|
|
2285
|
+
client = null;
|
|
2286
|
+
status = "disconnected";
|
|
2287
|
+
brokerUrl = "";
|
|
2288
|
+
}
|
|
2289
|
+
}
|
|
2193
2290
|
// src/utils/tracking.ts
|
|
2194
2291
|
var cachedBrowserId = null;
|
|
2195
2292
|
function getClientInfo() {
|
|
@@ -2221,8 +2318,8 @@ function getClientInfo() {
|
|
|
2221
2318
|
os = "webOS";
|
|
2222
2319
|
isSmartTV = true;
|
|
2223
2320
|
deviceType = "tv";
|
|
2224
|
-
var
|
|
2225
|
-
model =
|
|
2321
|
+
var m = ua.match(/Web0S\/([^\s]+)/);
|
|
2322
|
+
model = m ? "webOS ".concat(m[1]) : "webOS TV";
|
|
2226
2323
|
} else if (ua.includes("Tizen")) {
|
|
2227
2324
|
brand = "Samsung";
|
|
2228
2325
|
os = "Tizen";
|
|
@@ -2266,23 +2363,19 @@ function getClientInfo() {
|
|
|
2266
2363
|
isAndroid = true;
|
|
2267
2364
|
os = "Android";
|
|
2268
2365
|
deviceType = /Mobile/.test(ua) ? "mobile" : "tablet";
|
|
2269
|
-
if (
|
|
2366
|
+
if (maxTouchPoints === 0 || ua.includes("Google TV") || ua.includes("XiaoMi")) {
|
|
2270
2367
|
deviceType = "tv";
|
|
2271
2368
|
isSmartTV = true;
|
|
2272
2369
|
brand = brand === "Unknown" ? "Android TV" : brand;
|
|
2273
2370
|
}
|
|
2274
2371
|
var androidModelMatch = ua.match(/\(([^)]*Android[^)]*)\)/);
|
|
2275
|
-
if (androidModelMatch
|
|
2276
|
-
model = androidModelMatch[1];
|
|
2277
|
-
}
|
|
2372
|
+
if (androidModelMatch === null || androidModelMatch === void 0 ? void 0 : androidModelMatch[1]) model = androidModelMatch[1];
|
|
2278
2373
|
}
|
|
2279
2374
|
if (/iPad|iPhone|iPod/.test(ua)) {
|
|
2280
2375
|
os = "iOS";
|
|
2281
2376
|
deviceType = "mobile";
|
|
2282
2377
|
brand = "Apple";
|
|
2283
|
-
if (navigator.maxTouchPoints > 1 && /iPad/.test(ua))
|
|
2284
|
-
deviceType = "tablet";
|
|
2285
|
-
}
|
|
2378
|
+
if (navigator.maxTouchPoints > 1 && /iPad/.test(ua)) deviceType = "tablet";
|
|
2286
2379
|
}
|
|
2287
2380
|
if (!isAndroid && !isSmartTV && !/Mobile/.test(ua)) {
|
|
2288
2381
|
if (ua.includes("Windows")) {
|
|
@@ -2303,9 +2396,7 @@ function getClientInfo() {
|
|
|
2303
2396
|
if (vendor.includes("Samsung") || ua.includes("SM-")) brand = "Samsung";
|
|
2304
2397
|
}
|
|
2305
2398
|
isWebView = /wv|WebView|Linux; U;/.test(ua);
|
|
2306
|
-
if (((_window = window) === null || _window === void 0 ? void 0 : _window.outerHeight) === 0 && ((_window1 = window) === null || _window1 === void 0 ? void 0 : _window1.outerWidth) === 0)
|
|
2307
|
-
isWebView = true;
|
|
2308
|
-
}
|
|
2399
|
+
if (((_window = window) === null || _window === void 0 ? void 0 : _window.outerHeight) === 0 && ((_window1 = window) === null || _window1 === void 0 ? void 0 : _window1.outerWidth) === 0) isWebView = true;
|
|
2309
2400
|
isWebApp = window.matchMedia("(display-mode: standalone)").matches || window.navigator.standalone === true || ((_window_screen = window.screen) === null || _window_screen === void 0 ? void 0 : (_window_screen_orientation = _window_screen.orientation) === null || _window_screen_orientation === void 0 ? void 0 : _window_screen_orientation.angle) !== void 0;
|
|
2310
2401
|
return {
|
|
2311
2402
|
brand: brand,
|
|
@@ -2336,18 +2427,16 @@ function getClientInfo() {
|
|
|
2336
2427
|
}
|
|
2337
2428
|
function getBrowserID(clientInfo) {
|
|
2338
2429
|
return _async_to_generator(function() {
|
|
2339
|
-
var fingerprintString, encodedData, utf8, buffer, i, hashBuffer,
|
|
2430
|
+
var _crypto_subtle, fingerprintString, encodedData, utf8, buffer, i, hashBuffer, hashHex, unused, hash, i1, char, fallbackHash, timestamp, random;
|
|
2340
2431
|
return _ts_generator(this, function(_state) {
|
|
2341
2432
|
switch(_state.label){
|
|
2342
2433
|
case 0:
|
|
2343
|
-
if (cachedBrowserId)
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
];
|
|
2348
|
-
}
|
|
2434
|
+
if (cachedBrowserId) return [
|
|
2435
|
+
2,
|
|
2436
|
+
cachedBrowserId
|
|
2437
|
+
];
|
|
2349
2438
|
fingerprintString = JSON.stringify(clientInfo);
|
|
2350
|
-
if (!(typeof crypto !== "undefined" && crypto.subtle
|
|
2439
|
+
if (!(typeof crypto !== "undefined" && ((_crypto_subtle = crypto.subtle) === null || _crypto_subtle === void 0 ? void 0 : _crypto_subtle.digest))) return [
|
|
2351
2440
|
3,
|
|
2352
2441
|
5
|
|
2353
2442
|
];
|
|
@@ -2374,9 +2463,7 @@ function getBrowserID(clientInfo) {
|
|
|
2374
2463
|
} else {
|
|
2375
2464
|
utf8 = unescape(encodeURIComponent(fingerprintString));
|
|
2376
2465
|
buffer = new Uint8Array(utf8.length);
|
|
2377
|
-
for(i = 0; i < utf8.length; i++)
|
|
2378
|
-
buffer[i] = utf8.charCodeAt(i);
|
|
2379
|
-
}
|
|
2466
|
+
for(i = 0; i < utf8.length; i++)buffer[i] = utf8.charCodeAt(i);
|
|
2380
2467
|
encodedData = buffer;
|
|
2381
2468
|
}
|
|
2382
2469
|
return [
|
|
@@ -2385,8 +2472,7 @@ function getBrowserID(clientInfo) {
|
|
|
2385
2472
|
];
|
|
2386
2473
|
case 3:
|
|
2387
2474
|
hashBuffer = _state.sent();
|
|
2388
|
-
|
|
2389
|
-
hashHex = hashArray.map(function(b) {
|
|
2475
|
+
hashHex = Array.from(new Uint8Array(hashBuffer)).map(function(b) {
|
|
2390
2476
|
return b.toString(16).padStart(2, "0");
|
|
2391
2477
|
}).join("");
|
|
2392
2478
|
cachedBrowserId = hashHex;
|
|
@@ -2395,8 +2481,8 @@ function getBrowserID(clientInfo) {
|
|
|
2395
2481
|
hashHex
|
|
2396
2482
|
];
|
|
2397
2483
|
case 4:
|
|
2398
|
-
|
|
2399
|
-
console.warn("[StormcloudVideoPlayer] crypto.subtle
|
|
2484
|
+
unused = _state.sent();
|
|
2485
|
+
console.warn("[StormcloudVideoPlayer] crypto.subtle not supported, using fallback hash");
|
|
2400
2486
|
return [
|
|
2401
2487
|
3,
|
|
2402
2488
|
5
|
|
@@ -2420,6 +2506,10 @@ function getBrowserID(clientInfo) {
|
|
|
2420
2506
|
});
|
|
2421
2507
|
})();
|
|
2422
2508
|
}
|
|
2509
|
+
var mqttTopicPrefix = "adstorm";
|
|
2510
|
+
function setMQTTTopicPrefix(prefix) {
|
|
2511
|
+
mqttTopicPrefix = prefix || "adstorm";
|
|
2512
|
+
}
|
|
2423
2513
|
var PLAYER_TRACKING_BASE_URL = "https://adstorm.co/api-adstorm-dev/adstorm/player-tracking";
|
|
2424
2514
|
var TRACK_URL = "".concat(PLAYER_TRACKING_BASE_URL, "/metrics/ingest");
|
|
2425
2515
|
var HEARTBEAT_URL = "".concat(PLAYER_TRACKING_BASE_URL, "/heartbeat");
|
|
@@ -2428,43 +2518,9 @@ function buildHeaders(licenseKey) {
|
|
|
2428
2518
|
var headers = {
|
|
2429
2519
|
"Content-Type": "application/json"
|
|
2430
2520
|
};
|
|
2431
|
-
if (licenseKey)
|
|
2432
|
-
headers["Authorization"] = "Bearer ".concat(licenseKey);
|
|
2433
|
-
}
|
|
2521
|
+
if (licenseKey) headers["Authorization"] = "Bearer ".concat(licenseKey);
|
|
2434
2522
|
return headers;
|
|
2435
2523
|
}
|
|
2436
|
-
function sendTrackRequest(licenseKey, body) {
|
|
2437
|
-
return _async_to_generator(function() {
|
|
2438
|
-
var response;
|
|
2439
|
-
return _ts_generator(this, function(_state) {
|
|
2440
|
-
switch(_state.label){
|
|
2441
|
-
case 0:
|
|
2442
|
-
return [
|
|
2443
|
-
4,
|
|
2444
|
-
fetch(TRACK_URL, {
|
|
2445
|
-
method: "POST",
|
|
2446
|
-
headers: buildHeaders(licenseKey),
|
|
2447
|
-
body: JSON.stringify(body)
|
|
2448
|
-
})
|
|
2449
|
-
];
|
|
2450
|
-
case 1:
|
|
2451
|
-
response = _state.sent();
|
|
2452
|
-
if (!response.ok) {
|
|
2453
|
-
throw new Error("HTTP error! status: ".concat(response.status));
|
|
2454
|
-
}
|
|
2455
|
-
return [
|
|
2456
|
-
4,
|
|
2457
|
-
response.json()
|
|
2458
|
-
];
|
|
2459
|
-
case 2:
|
|
2460
|
-
_state.sent();
|
|
2461
|
-
return [
|
|
2462
|
-
2
|
|
2463
|
-
];
|
|
2464
|
-
}
|
|
2465
|
-
});
|
|
2466
|
-
})();
|
|
2467
|
-
}
|
|
2468
2524
|
function postJson(url, licenseKey, body) {
|
|
2469
2525
|
return _async_to_generator(function() {
|
|
2470
2526
|
var response;
|
|
@@ -2481,9 +2537,7 @@ function postJson(url, licenseKey, body) {
|
|
|
2481
2537
|
];
|
|
2482
2538
|
case 1:
|
|
2483
2539
|
response = _state.sent();
|
|
2484
|
-
if (!response.ok)
|
|
2485
|
-
throw new Error("HTTP error! status: ".concat(response.status));
|
|
2486
|
-
}
|
|
2540
|
+
if (!response.ok) throw new Error("HTTP error! status: ".concat(response.status));
|
|
2487
2541
|
return [
|
|
2488
2542
|
4,
|
|
2489
2543
|
response.json()
|
|
@@ -2533,9 +2587,33 @@ function buildPlayerMetricEvent(_0) {
|
|
|
2533
2587
|
});
|
|
2534
2588
|
}).apply(this, arguments);
|
|
2535
2589
|
}
|
|
2590
|
+
function publishOrPost(mqttTopic, httpUrl, licenseKey, body) {
|
|
2591
|
+
return _async_to_generator(function() {
|
|
2592
|
+
return _ts_generator(this, function(_state) {
|
|
2593
|
+
switch(_state.label){
|
|
2594
|
+
case 0:
|
|
2595
|
+
if (isMQTTConfigured()) {
|
|
2596
|
+
publishMQTT(mqttTopic, body);
|
|
2597
|
+
return [
|
|
2598
|
+
2
|
|
2599
|
+
];
|
|
2600
|
+
}
|
|
2601
|
+
return [
|
|
2602
|
+
4,
|
|
2603
|
+
postJson(httpUrl, licenseKey, body)
|
|
2604
|
+
];
|
|
2605
|
+
case 1:
|
|
2606
|
+
_state.sent();
|
|
2607
|
+
return [
|
|
2608
|
+
2
|
|
2609
|
+
];
|
|
2610
|
+
}
|
|
2611
|
+
});
|
|
2612
|
+
})();
|
|
2613
|
+
}
|
|
2536
2614
|
function sendInitialTracking(_0) {
|
|
2537
2615
|
return _async_to_generator(function(licenseKey) {
|
|
2538
|
-
var context, clientInfo, browserId, trackingData, error;
|
|
2616
|
+
var context, clientInfo, browserId, captureAt, trackingData, metricsBody, error;
|
|
2539
2617
|
var _arguments = arguments;
|
|
2540
2618
|
return _ts_generator(this, function(_state) {
|
|
2541
2619
|
switch(_state.label){
|
|
@@ -2556,26 +2634,28 @@ function sendInitialTracking(_0) {
|
|
|
2556
2634
|
];
|
|
2557
2635
|
case 2:
|
|
2558
2636
|
browserId = _state.sent();
|
|
2637
|
+
captureAt = /* @__PURE__ */ new Date().toISOString();
|
|
2559
2638
|
trackingData = _object_spread({
|
|
2560
2639
|
browserId: browserId
|
|
2561
2640
|
}, clientInfo);
|
|
2641
|
+
metricsBody = {
|
|
2642
|
+
events: [
|
|
2643
|
+
{
|
|
2644
|
+
player_id: browserId,
|
|
2645
|
+
device_type: clientInfo.deviceType,
|
|
2646
|
+
input_stream_type: context.inputStreamType,
|
|
2647
|
+
os: clientInfo.os,
|
|
2648
|
+
ad_loaded: false,
|
|
2649
|
+
ad_detect: false,
|
|
2650
|
+
license_key: licenseKey,
|
|
2651
|
+
capture_at: captureAt
|
|
2652
|
+
}
|
|
2653
|
+
],
|
|
2654
|
+
trackingData: trackingData
|
|
2655
|
+
};
|
|
2562
2656
|
return [
|
|
2563
2657
|
4,
|
|
2564
|
-
|
|
2565
|
-
events: [
|
|
2566
|
-
{
|
|
2567
|
-
player_id: browserId,
|
|
2568
|
-
device_type: clientInfo.deviceType,
|
|
2569
|
-
input_stream_type: context.inputStreamType,
|
|
2570
|
-
os: clientInfo.os,
|
|
2571
|
-
ad_loaded: false,
|
|
2572
|
-
ad_detect: false,
|
|
2573
|
-
license_key: licenseKey,
|
|
2574
|
-
capture_at: /* @__PURE__ */ new Date().toISOString()
|
|
2575
|
-
}
|
|
2576
|
-
],
|
|
2577
|
-
trackingData: trackingData
|
|
2578
|
-
})
|
|
2658
|
+
publishOrPost("".concat(mqttTopicPrefix, "/tracking/metrics"), TRACK_URL, licenseKey, metricsBody)
|
|
2579
2659
|
];
|
|
2580
2660
|
case 3:
|
|
2581
2661
|
_state.sent();
|
|
@@ -2688,7 +2768,7 @@ function sendAdLoadedTracking(_0, _1) {
|
|
|
2688
2768
|
}
|
|
2689
2769
|
function sendAdImpressionTracking(_0, _1) {
|
|
2690
2770
|
return _async_to_generator(function(licenseKey, adImpressionInfo) {
|
|
2691
|
-
var context, metricEvent, error;
|
|
2771
|
+
var context, metricEvent, heartbeatBody, impressionsBody, error;
|
|
2692
2772
|
var _arguments = arguments;
|
|
2693
2773
|
return _ts_generator(this, function(_state) {
|
|
2694
2774
|
switch(_state.label){
|
|
@@ -2710,21 +2790,23 @@ function sendAdImpressionTracking(_0, _1) {
|
|
|
2710
2790
|
];
|
|
2711
2791
|
case 2:
|
|
2712
2792
|
metricEvent = _state.sent();
|
|
2793
|
+
heartbeatBody = metricEvent;
|
|
2794
|
+
impressionsBody = {
|
|
2795
|
+
events: [
|
|
2796
|
+
{
|
|
2797
|
+
player_id: metricEvent.player_id,
|
|
2798
|
+
ad_played_count: 1,
|
|
2799
|
+
ad_url: adImpressionInfo.adUrl,
|
|
2800
|
+
license_key: licenseKey,
|
|
2801
|
+
capture_at: adImpressionInfo.timestamp
|
|
2802
|
+
}
|
|
2803
|
+
]
|
|
2804
|
+
};
|
|
2713
2805
|
return [
|
|
2714
2806
|
4,
|
|
2715
2807
|
Promise.all([
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
events: [
|
|
2719
|
-
{
|
|
2720
|
-
player_id: metricEvent.player_id,
|
|
2721
|
-
ad_played_count: 1,
|
|
2722
|
-
ad_url: adImpressionInfo.adUrl,
|
|
2723
|
-
license_key: licenseKey,
|
|
2724
|
-
capture_at: adImpressionInfo.timestamp
|
|
2725
|
-
}
|
|
2726
|
-
]
|
|
2727
|
-
})
|
|
2808
|
+
publishOrPost("".concat(mqttTopicPrefix, "/tracking/heartbeat"), HEARTBEAT_URL, licenseKey, heartbeatBody),
|
|
2809
|
+
publishOrPost("".concat(mqttTopicPrefix, "/tracking/impressions"), IMPRESSIONS_URL, licenseKey, impressionsBody)
|
|
2728
2810
|
])
|
|
2729
2811
|
];
|
|
2730
2812
|
case 3:
|
|
@@ -2772,7 +2854,7 @@ function sendHeartbeat(_0) {
|
|
|
2772
2854
|
heartbeatData = _state.sent();
|
|
2773
2855
|
return [
|
|
2774
2856
|
4,
|
|
2775
|
-
|
|
2857
|
+
publishOrPost("".concat(mqttTopicPrefix, "/tracking/heartbeat"), HEARTBEAT_URL, licenseKey, heartbeatData)
|
|
2776
2858
|
];
|
|
2777
2859
|
case 3:
|
|
2778
2860
|
_state.sent();
|
|
@@ -4726,6 +4808,11 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4726
4808
|
key: "initializeTracking",
|
|
4727
4809
|
value: function initializeTracking() {
|
|
4728
4810
|
var _this = this;
|
|
4811
|
+
if (this.config.mqttBrokerUrl) {
|
|
4812
|
+
var topicPrefix = "adstorm";
|
|
4813
|
+
setMQTTTopicPrefix(topicPrefix);
|
|
4814
|
+
initMQTTClient(this.config.mqttBrokerUrl, topicPrefix);
|
|
4815
|
+
}
|
|
4729
4816
|
sendInitialTracking(this.config.licenseKey, this.getAnalyticsContext()).then(function() {
|
|
4730
4817
|
_this.heartbeatInterval = window.setInterval(function() {
|
|
4731
4818
|
_this.sendHeartbeatIfNeeded();
|
|
@@ -6405,6 +6492,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6405
6492
|
clearInterval(this.heartbeatInterval);
|
|
6406
6493
|
this.heartbeatInterval = void 0;
|
|
6407
6494
|
}
|
|
6495
|
+
if (this.config.mqttBrokerUrl) {
|
|
6496
|
+
disconnectMQTT();
|
|
6497
|
+
}
|
|
6408
6498
|
(_this_hls = this.hls) === null || _this_hls === void 0 ? void 0 : _this_hls.destroy();
|
|
6409
6499
|
(_this_adLayer = this.adLayer) === null || _this_adLayer === void 0 ? void 0 : _this_adLayer.destroy();
|
|
6410
6500
|
this.consecutiveFailures = 0;
|
|
@@ -6426,7 +6516,7 @@ var CRITICAL_PROPS = [
|
|
|
6426
6516
|
var CONTROLS_HIDE_DELAY = 3e3;
|
|
6427
6517
|
var DEFAULT_PLAYER_ASPECT_RATIO = 16 / 9;
|
|
6428
6518
|
var StormcloudVideoPlayerComponent = import_react.default.memo(function(props) {
|
|
6429
|
-
var src = props.src, autoplay = props.autoplay, muted = props.muted, lowLatencyMode = props.lowLatencyMode, allowNativeHls = props.allowNativeHls, driftToleranceMs = props.driftToleranceMs, immediateManifestAds = props.immediateManifestAds, debugAdTiming = props.debugAdTiming, showCustomControls = props.showCustomControls, hideLoadingIndicator = props.hideLoadingIndicator, onVolumeToggle = props.onVolumeToggle, onFullscreenToggle = props.onFullscreenToggle, onControlClick = props.onControlClick, onReady = props.onReady, wrapperClassName = props.wrapperClassName, wrapperStyle = props.wrapperStyle, className = props.className, style = props.style, controls = props.controls, playsInline = props.playsInline, preload = props.preload, poster = props.poster, children = props.children, licenseKey = props.licenseKey, minSegmentsBeforePlay = props.minSegmentsBeforePlay, disableAds = props.disableAds, disableFiller = props.disableFiller, restVideoAttrs = _object_without_properties(props, [
|
|
6519
|
+
var src = props.src, autoplay = props.autoplay, muted = props.muted, lowLatencyMode = props.lowLatencyMode, allowNativeHls = props.allowNativeHls, driftToleranceMs = props.driftToleranceMs, immediateManifestAds = props.immediateManifestAds, debugAdTiming = props.debugAdTiming, showCustomControls = props.showCustomControls, hideLoadingIndicator = props.hideLoadingIndicator, onVolumeToggle = props.onVolumeToggle, onFullscreenToggle = props.onFullscreenToggle, onControlClick = props.onControlClick, onReady = props.onReady, wrapperClassName = props.wrapperClassName, wrapperStyle = props.wrapperStyle, className = props.className, style = props.style, controls = props.controls, playsInline = props.playsInline, preload = props.preload, poster = props.poster, children = props.children, licenseKey = props.licenseKey, minSegmentsBeforePlay = props.minSegmentsBeforePlay, disableAds = props.disableAds, disableFiller = props.disableFiller, mqttBrokerUrl = props.mqttBrokerUrl, restVideoAttrs = _object_without_properties(props, [
|
|
6430
6520
|
"src",
|
|
6431
6521
|
"autoplay",
|
|
6432
6522
|
"muted",
|
|
@@ -6453,7 +6543,8 @@ var StormcloudVideoPlayerComponent = import_react.default.memo(function(props) {
|
|
|
6453
6543
|
"licenseKey",
|
|
6454
6544
|
"minSegmentsBeforePlay",
|
|
6455
6545
|
"disableAds",
|
|
6456
|
-
"disableFiller"
|
|
6546
|
+
"disableFiller",
|
|
6547
|
+
"mqttBrokerUrl"
|
|
6457
6548
|
]);
|
|
6458
6549
|
var videoRef = (0, import_react.useRef)(null);
|
|
6459
6550
|
var playerRef = (0, import_react.useRef)(null);
|
|
@@ -6613,6 +6704,7 @@ var StormcloudVideoPlayerComponent = import_react.default.memo(function(props) {
|
|
|
6613
6704
|
if (minSegmentsBeforePlay !== void 0) cfg.minSegmentsBeforePlay = minSegmentsBeforePlay;
|
|
6614
6705
|
if (disableAds !== void 0) cfg.disableAds = disableAds;
|
|
6615
6706
|
cfg.disableFiller = disableFiller !== null && disableFiller !== void 0 ? disableFiller : true;
|
|
6707
|
+
if (mqttBrokerUrl !== void 0) cfg.mqttBrokerUrl = mqttBrokerUrl;
|
|
6616
6708
|
var player = new StormcloudVideoPlayer(cfg);
|
|
6617
6709
|
playerRef.current = player;
|
|
6618
6710
|
player.load().then(function() {
|
|
@@ -8859,10 +8951,15 @@ var StormcloudPlayer_default = StormcloudPlayer;
|
|
|
8859
8951
|
createVastAdLayer: createVastAdLayer,
|
|
8860
8952
|
createVastManager: createVastManager,
|
|
8861
8953
|
detectBrowser: detectBrowser,
|
|
8954
|
+
disconnectMQTT: disconnectMQTT,
|
|
8862
8955
|
getBrowserConfigOverrides: getBrowserConfigOverrides,
|
|
8863
8956
|
getBrowserID: getBrowserID,
|
|
8864
8957
|
getClientInfo: getClientInfo,
|
|
8958
|
+
getMQTTStatus: getMQTTStatus,
|
|
8959
|
+
initMQTTClient: initMQTTClient,
|
|
8865
8960
|
initializePolyfills: initializePolyfills,
|
|
8961
|
+
isMQTTConfigured: isMQTTConfigured,
|
|
8962
|
+
isMQTTConnected: isMQTTConnected,
|
|
8866
8963
|
isMediaStream: isMediaStream,
|
|
8867
8964
|
lazy: lazy,
|
|
8868
8965
|
logBrowserInfo: logBrowserInfo,
|
|
@@ -8870,6 +8967,7 @@ var StormcloudPlayer_default = StormcloudPlayer;
|
|
|
8870
8967
|
omit: omit,
|
|
8871
8968
|
parseQuery: parseQuery,
|
|
8872
8969
|
players: players,
|
|
8970
|
+
publishMQTT: publishMQTT,
|
|
8873
8971
|
randomString: randomString,
|
|
8874
8972
|
sendHeartbeat: sendHeartbeat,
|
|
8875
8973
|
sendInitialTracking: sendInitialTracking,
|