stormcloud-video-player 0.6.11 → 0.6.13
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/README.md +33 -294
- package/dist/stormcloud-vp.min.js +3 -1
- package/lib/index.cjs +265 -191
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +29 -1
- package/lib/index.d.ts +29 -1
- package/lib/index.js +210 -192
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +193 -191
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.cjs +193 -191
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/index.cjs +193 -191
- package/lib/players/index.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +193 -191
- 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 +136 -0
- package/lib/utils/mqttConfig.cjs.map +1 -0
- package/lib/utils/mqttConfig.d.cts +19 -0
- package/lib/utils/tracking.cjs +193 -191
- package/lib/utils/tracking.cjs.map +1 -1
- package/package.json +3 -3
package/lib/index.js
CHANGED
|
@@ -2030,6 +2030,122 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
2030
2030
|
}
|
|
2031
2031
|
};
|
|
2032
2032
|
}
|
|
2033
|
+
// src/utils/mqttConfig.ts
|
|
2034
|
+
var DEFAULT_MQTT_CONFIG = {
|
|
2035
|
+
enabled: true,
|
|
2036
|
+
brokerAddress: "vecbae77.ala.us-east-1.emqxsl.com",
|
|
2037
|
+
brokerPort: 8883,
|
|
2038
|
+
wsPort: 8084,
|
|
2039
|
+
username: "for-sonifi",
|
|
2040
|
+
password: "sonifi-mqtt",
|
|
2041
|
+
topicPrefix: "adstorm/players",
|
|
2042
|
+
qos: 1
|
|
2043
|
+
};
|
|
2044
|
+
var mqttConfig = _object_spread({}, DEFAULT_MQTT_CONFIG);
|
|
2045
|
+
function applyMQTTConfig(overrides) {
|
|
2046
|
+
Object.assign(mqttConfig, overrides);
|
|
2047
|
+
}
|
|
2048
|
+
function isMQTTEnabled() {
|
|
2049
|
+
return mqttConfig.enabled;
|
|
2050
|
+
}
|
|
2051
|
+
function buildMQTTBrokerUrl() {
|
|
2052
|
+
if (mqttConfig.brokerUrl) return mqttConfig.brokerUrl;
|
|
2053
|
+
return "wss://".concat(mqttConfig.brokerAddress, ":").concat(mqttConfig.wsPort, "/mqtt");
|
|
2054
|
+
}
|
|
2055
|
+
function buildPlayerTopic(licenseKey, channel) {
|
|
2056
|
+
return "".concat(mqttConfig.topicPrefix, "/").concat(licenseKey, "/").concat(channel);
|
|
2057
|
+
}
|
|
2058
|
+
// src/utils/mqttClient.ts
|
|
2059
|
+
import mqtt from "mqtt";
|
|
2060
|
+
var LOG2 = "[StormcloudVideoPlayer][MQTT]";
|
|
2061
|
+
var client = null;
|
|
2062
|
+
var status = "disconnected";
|
|
2063
|
+
function getMQTTStatus() {
|
|
2064
|
+
return status;
|
|
2065
|
+
}
|
|
2066
|
+
function isMQTTConnected() {
|
|
2067
|
+
return status === "connected" && client !== null && client.connected;
|
|
2068
|
+
}
|
|
2069
|
+
function isMQTTConfigured() {
|
|
2070
|
+
return isMQTTEnabled();
|
|
2071
|
+
}
|
|
2072
|
+
function configureMQTT(overrides) {
|
|
2073
|
+
applyMQTTConfig(overrides);
|
|
2074
|
+
disconnectMQTT();
|
|
2075
|
+
}
|
|
2076
|
+
function initMQTTClient() {
|
|
2077
|
+
if (client || !isMQTTEnabled()) return;
|
|
2078
|
+
var url = buildMQTTBrokerUrl();
|
|
2079
|
+
status = "connecting";
|
|
2080
|
+
var clientId = "stormcloud-vp-".concat(Math.random().toString(36).slice(2, 9));
|
|
2081
|
+
try {
|
|
2082
|
+
client = mqtt.connect(url, {
|
|
2083
|
+
clientId: clientId,
|
|
2084
|
+
username: mqttConfig.username,
|
|
2085
|
+
password: mqttConfig.password,
|
|
2086
|
+
keepalive: 60,
|
|
2087
|
+
clean: true,
|
|
2088
|
+
reconnectPeriod: 5e3,
|
|
2089
|
+
connectTimeout: 1e4,
|
|
2090
|
+
queueQoSZero: false
|
|
2091
|
+
});
|
|
2092
|
+
} catch (err) {
|
|
2093
|
+
status = "error";
|
|
2094
|
+
console.warn("".concat(LOG2, " connect() threw:"), err);
|
|
2095
|
+
return;
|
|
2096
|
+
}
|
|
2097
|
+
client.on("connect", function() {
|
|
2098
|
+
status = "connected";
|
|
2099
|
+
console.info("".concat(LOG2, " connected to ").concat(url));
|
|
2100
|
+
});
|
|
2101
|
+
client.on("reconnect", function() {
|
|
2102
|
+
status = "connecting";
|
|
2103
|
+
console.info("".concat(LOG2, " reconnecting…"));
|
|
2104
|
+
});
|
|
2105
|
+
client.on("offline", function() {
|
|
2106
|
+
status = "disconnected";
|
|
2107
|
+
console.warn("".concat(LOG2, " offline"));
|
|
2108
|
+
});
|
|
2109
|
+
client.on("error", function(err) {
|
|
2110
|
+
status = "error";
|
|
2111
|
+
console.warn("".concat(LOG2, " error:"), err.message);
|
|
2112
|
+
});
|
|
2113
|
+
client.on("close", function() {
|
|
2114
|
+
if (status === "connected") {
|
|
2115
|
+
status = "disconnected";
|
|
2116
|
+
}
|
|
2117
|
+
});
|
|
2118
|
+
}
|
|
2119
|
+
function ensureMQTTClient() {
|
|
2120
|
+
if (isMQTTEnabled() && !client) {
|
|
2121
|
+
initMQTTClient();
|
|
2122
|
+
}
|
|
2123
|
+
}
|
|
2124
|
+
function publishMQTT(topic, payload) {
|
|
2125
|
+
if (!isMQTTEnabled()) {
|
|
2126
|
+
return false;
|
|
2127
|
+
}
|
|
2128
|
+
ensureMQTTClient();
|
|
2129
|
+
if (!client) {
|
|
2130
|
+
return false;
|
|
2131
|
+
}
|
|
2132
|
+
try {
|
|
2133
|
+
client.publish(topic, JSON.stringify(payload), {
|
|
2134
|
+
qos: mqttConfig.qos
|
|
2135
|
+
});
|
|
2136
|
+
return true;
|
|
2137
|
+
} catch (err) {
|
|
2138
|
+
console.warn("".concat(LOG2, " publish failed on ").concat(topic, ":"), err);
|
|
2139
|
+
return false;
|
|
2140
|
+
}
|
|
2141
|
+
}
|
|
2142
|
+
function disconnectMQTT() {
|
|
2143
|
+
if (client) {
|
|
2144
|
+
client.end(true);
|
|
2145
|
+
client = null;
|
|
2146
|
+
status = "disconnected";
|
|
2147
|
+
}
|
|
2148
|
+
}
|
|
2033
2149
|
// src/utils/tracking.ts
|
|
2034
2150
|
var cachedBrowserId = null;
|
|
2035
2151
|
function getClientInfo() {
|
|
@@ -2061,8 +2177,8 @@ function getClientInfo() {
|
|
|
2061
2177
|
os = "webOS";
|
|
2062
2178
|
isSmartTV = true;
|
|
2063
2179
|
deviceType = "tv";
|
|
2064
|
-
var
|
|
2065
|
-
model =
|
|
2180
|
+
var m = ua.match(/Web0S\/([^\s]+)/);
|
|
2181
|
+
model = m ? "webOS ".concat(m[1]) : "webOS TV";
|
|
2066
2182
|
} else if (ua.includes("Tizen")) {
|
|
2067
2183
|
brand = "Samsung";
|
|
2068
2184
|
os = "Tizen";
|
|
@@ -2106,23 +2222,19 @@ function getClientInfo() {
|
|
|
2106
2222
|
isAndroid = true;
|
|
2107
2223
|
os = "Android";
|
|
2108
2224
|
deviceType = /Mobile/.test(ua) ? "mobile" : "tablet";
|
|
2109
|
-
if (
|
|
2225
|
+
if (maxTouchPoints === 0 || ua.includes("Google TV") || ua.includes("XiaoMi")) {
|
|
2110
2226
|
deviceType = "tv";
|
|
2111
2227
|
isSmartTV = true;
|
|
2112
2228
|
brand = brand === "Unknown" ? "Android TV" : brand;
|
|
2113
2229
|
}
|
|
2114
2230
|
var androidModelMatch = ua.match(/\(([^)]*Android[^)]*)\)/);
|
|
2115
|
-
if (androidModelMatch
|
|
2116
|
-
model = androidModelMatch[1];
|
|
2117
|
-
}
|
|
2231
|
+
if (androidModelMatch === null || androidModelMatch === void 0 ? void 0 : androidModelMatch[1]) model = androidModelMatch[1];
|
|
2118
2232
|
}
|
|
2119
2233
|
if (/iPad|iPhone|iPod/.test(ua)) {
|
|
2120
2234
|
os = "iOS";
|
|
2121
2235
|
deviceType = "mobile";
|
|
2122
2236
|
brand = "Apple";
|
|
2123
|
-
if (navigator.maxTouchPoints > 1 && /iPad/.test(ua))
|
|
2124
|
-
deviceType = "tablet";
|
|
2125
|
-
}
|
|
2237
|
+
if (navigator.maxTouchPoints > 1 && /iPad/.test(ua)) deviceType = "tablet";
|
|
2126
2238
|
}
|
|
2127
2239
|
if (!isAndroid && !isSmartTV && !/Mobile/.test(ua)) {
|
|
2128
2240
|
if (ua.includes("Windows")) {
|
|
@@ -2143,9 +2255,7 @@ function getClientInfo() {
|
|
|
2143
2255
|
if (vendor.includes("Samsung") || ua.includes("SM-")) brand = "Samsung";
|
|
2144
2256
|
}
|
|
2145
2257
|
isWebView = /wv|WebView|Linux; U;/.test(ua);
|
|
2146
|
-
if (((_window = window) === null || _window === void 0 ? void 0 : _window.outerHeight) === 0 && ((_window1 = window) === null || _window1 === void 0 ? void 0 : _window1.outerWidth) === 0)
|
|
2147
|
-
isWebView = true;
|
|
2148
|
-
}
|
|
2258
|
+
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;
|
|
2149
2259
|
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;
|
|
2150
2260
|
return {
|
|
2151
2261
|
brand: brand,
|
|
@@ -2176,18 +2286,16 @@ function getClientInfo() {
|
|
|
2176
2286
|
}
|
|
2177
2287
|
function getBrowserID(clientInfo) {
|
|
2178
2288
|
return _async_to_generator(function() {
|
|
2179
|
-
var fingerprintString, encodedData, utf8, buffer, i, hashBuffer,
|
|
2289
|
+
var _crypto_subtle, fingerprintString, encodedData, utf8, buffer, i, hashBuffer, hashHex, unused, hash, i1, char, fallbackHash, timestamp, random;
|
|
2180
2290
|
return _ts_generator(this, function(_state) {
|
|
2181
2291
|
switch(_state.label){
|
|
2182
2292
|
case 0:
|
|
2183
|
-
if (cachedBrowserId)
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
];
|
|
2188
|
-
}
|
|
2293
|
+
if (cachedBrowserId) return [
|
|
2294
|
+
2,
|
|
2295
|
+
cachedBrowserId
|
|
2296
|
+
];
|
|
2189
2297
|
fingerprintString = JSON.stringify(clientInfo);
|
|
2190
|
-
if (!(typeof crypto !== "undefined" && crypto.subtle
|
|
2298
|
+
if (!(typeof crypto !== "undefined" && ((_crypto_subtle = crypto.subtle) === null || _crypto_subtle === void 0 ? void 0 : _crypto_subtle.digest))) return [
|
|
2191
2299
|
3,
|
|
2192
2300
|
5
|
|
2193
2301
|
];
|
|
@@ -2214,9 +2322,7 @@ function getBrowserID(clientInfo) {
|
|
|
2214
2322
|
} else {
|
|
2215
2323
|
utf8 = unescape(encodeURIComponent(fingerprintString));
|
|
2216
2324
|
buffer = new Uint8Array(utf8.length);
|
|
2217
|
-
for(i = 0; i < utf8.length; i++)
|
|
2218
|
-
buffer[i] = utf8.charCodeAt(i);
|
|
2219
|
-
}
|
|
2325
|
+
for(i = 0; i < utf8.length; i++)buffer[i] = utf8.charCodeAt(i);
|
|
2220
2326
|
encodedData = buffer;
|
|
2221
2327
|
}
|
|
2222
2328
|
return [
|
|
@@ -2225,8 +2331,7 @@ function getBrowserID(clientInfo) {
|
|
|
2225
2331
|
];
|
|
2226
2332
|
case 3:
|
|
2227
2333
|
hashBuffer = _state.sent();
|
|
2228
|
-
|
|
2229
|
-
hashHex = hashArray.map(function(b) {
|
|
2334
|
+
hashHex = Array.from(new Uint8Array(hashBuffer)).map(function(b) {
|
|
2230
2335
|
return b.toString(16).padStart(2, "0");
|
|
2231
2336
|
}).join("");
|
|
2232
2337
|
cachedBrowserId = hashHex;
|
|
@@ -2235,8 +2340,8 @@ function getBrowserID(clientInfo) {
|
|
|
2235
2340
|
hashHex
|
|
2236
2341
|
];
|
|
2237
2342
|
case 4:
|
|
2238
|
-
|
|
2239
|
-
console.warn("[StormcloudVideoPlayer] crypto.subtle
|
|
2343
|
+
unused = _state.sent();
|
|
2344
|
+
console.warn("[StormcloudVideoPlayer] crypto.subtle not supported, using fallback hash");
|
|
2240
2345
|
return [
|
|
2241
2346
|
3,
|
|
2242
2347
|
5
|
|
@@ -2260,177 +2365,91 @@ function getBrowserID(clientInfo) {
|
|
|
2260
2365
|
});
|
|
2261
2366
|
})();
|
|
2262
2367
|
}
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
var HEARTBEAT_URL = "".concat(PLAYER_TRACKING_BASE_URL, "/heartbeat");
|
|
2266
|
-
var IMPRESSIONS_URL = "".concat(PLAYER_TRACKING_BASE_URL, "/impressions/ingest");
|
|
2267
|
-
function buildHeaders(licenseKey) {
|
|
2268
|
-
var headers = {
|
|
2269
|
-
"Content-Type": "application/json"
|
|
2270
|
-
};
|
|
2271
|
-
if (licenseKey) {
|
|
2272
|
-
headers["Authorization"] = "Bearer ".concat(licenseKey);
|
|
2273
|
-
}
|
|
2274
|
-
return headers;
|
|
2275
|
-
}
|
|
2276
|
-
function sendTrackRequest(licenseKey, body) {
|
|
2277
|
-
return _async_to_generator(function() {
|
|
2278
|
-
var response;
|
|
2279
|
-
return _ts_generator(this, function(_state) {
|
|
2280
|
-
switch(_state.label){
|
|
2281
|
-
case 0:
|
|
2282
|
-
return [
|
|
2283
|
-
4,
|
|
2284
|
-
fetch(TRACK_URL, {
|
|
2285
|
-
method: "POST",
|
|
2286
|
-
headers: buildHeaders(licenseKey),
|
|
2287
|
-
body: JSON.stringify(body)
|
|
2288
|
-
})
|
|
2289
|
-
];
|
|
2290
|
-
case 1:
|
|
2291
|
-
response = _state.sent();
|
|
2292
|
-
if (!response.ok) {
|
|
2293
|
-
throw new Error("HTTP error! status: ".concat(response.status));
|
|
2294
|
-
}
|
|
2295
|
-
return [
|
|
2296
|
-
4,
|
|
2297
|
-
response.json()
|
|
2298
|
-
];
|
|
2299
|
-
case 2:
|
|
2300
|
-
_state.sent();
|
|
2301
|
-
return [
|
|
2302
|
-
2
|
|
2303
|
-
];
|
|
2304
|
-
}
|
|
2305
|
-
});
|
|
2306
|
-
})();
|
|
2368
|
+
function canPublish(licenseKey) {
|
|
2369
|
+
return Boolean(isMQTTEnabled() && licenseKey);
|
|
2307
2370
|
}
|
|
2308
|
-
function
|
|
2371
|
+
function buildPlayerMetricEvent() {
|
|
2309
2372
|
return _async_to_generator(function() {
|
|
2310
|
-
var
|
|
2311
|
-
return _ts_generator(this, function(_state) {
|
|
2312
|
-
switch(_state.label){
|
|
2313
|
-
case 0:
|
|
2314
|
-
return [
|
|
2315
|
-
4,
|
|
2316
|
-
fetch(url, {
|
|
2317
|
-
method: "POST",
|
|
2318
|
-
headers: buildHeaders(licenseKey),
|
|
2319
|
-
body: JSON.stringify(body)
|
|
2320
|
-
})
|
|
2321
|
-
];
|
|
2322
|
-
case 1:
|
|
2323
|
-
response = _state.sent();
|
|
2324
|
-
if (!response.ok) {
|
|
2325
|
-
throw new Error("HTTP error! status: ".concat(response.status));
|
|
2326
|
-
}
|
|
2327
|
-
return [
|
|
2328
|
-
4,
|
|
2329
|
-
response.json()
|
|
2330
|
-
];
|
|
2331
|
-
case 2:
|
|
2332
|
-
_state.sent();
|
|
2333
|
-
return [
|
|
2334
|
-
2
|
|
2335
|
-
];
|
|
2336
|
-
}
|
|
2337
|
-
});
|
|
2338
|
-
})();
|
|
2339
|
-
}
|
|
2340
|
-
function buildPlayerMetricEvent(_0) {
|
|
2341
|
-
return _async_to_generator(function(licenseKey) {
|
|
2342
|
-
var context, flags, _flags_captureAt, clientInfo, browserId, captureAt;
|
|
2373
|
+
var context, flags, _flags_captureAt, _flags_adLoaded, _flags_adDetect, clientInfo, playerId, captureAt;
|
|
2343
2374
|
var _arguments = arguments;
|
|
2344
2375
|
return _ts_generator(this, function(_state) {
|
|
2345
2376
|
switch(_state.label){
|
|
2346
2377
|
case 0:
|
|
2347
|
-
context = _arguments.length >
|
|
2378
|
+
context = _arguments.length > 0 && _arguments[0] !== void 0 ? _arguments[0] : {}, flags = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {};
|
|
2348
2379
|
clientInfo = getClientInfo();
|
|
2349
2380
|
return [
|
|
2350
2381
|
4,
|
|
2351
2382
|
getBrowserID(clientInfo)
|
|
2352
2383
|
];
|
|
2353
2384
|
case 1:
|
|
2354
|
-
|
|
2385
|
+
playerId = _state.sent();
|
|
2355
2386
|
captureAt = (_flags_captureAt = flags.captureAt) !== null && _flags_captureAt !== void 0 ? _flags_captureAt : /* @__PURE__ */ new Date().toISOString();
|
|
2356
2387
|
return [
|
|
2357
2388
|
2,
|
|
2358
|
-
{
|
|
2359
|
-
player_id:
|
|
2360
|
-
browserId: browserId,
|
|
2389
|
+
_object_spread({
|
|
2390
|
+
player_id: playerId,
|
|
2361
2391
|
device_type: clientInfo.deviceType,
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
timestamp: captureAt
|
|
2370
|
-
}
|
|
2392
|
+
os: clientInfo.os.toLowerCase(),
|
|
2393
|
+
ad_loaded: (_flags_adLoaded = flags.adLoaded) !== null && _flags_adLoaded !== void 0 ? _flags_adLoaded : false,
|
|
2394
|
+
ad_detect: (_flags_adDetect = flags.adDetect) !== null && _flags_adDetect !== void 0 ? _flags_adDetect : false,
|
|
2395
|
+
capture_at: captureAt
|
|
2396
|
+
}, context.inputStreamType ? {
|
|
2397
|
+
input_stream_type: context.inputStreamType
|
|
2398
|
+
} : {})
|
|
2371
2399
|
];
|
|
2372
2400
|
}
|
|
2373
2401
|
});
|
|
2374
2402
|
}).apply(this, arguments);
|
|
2375
2403
|
}
|
|
2404
|
+
function publishTracking(licenseKey, channel, body) {
|
|
2405
|
+
ensureMQTTClient();
|
|
2406
|
+
publishMQTT(buildPlayerTopic(licenseKey, channel), body);
|
|
2407
|
+
}
|
|
2376
2408
|
function sendInitialTracking(_0) {
|
|
2377
2409
|
return _async_to_generator(function(licenseKey) {
|
|
2378
|
-
var context,
|
|
2410
|
+
var context, metricEvent, error;
|
|
2379
2411
|
var _arguments = arguments;
|
|
2380
2412
|
return _ts_generator(this, function(_state) {
|
|
2381
2413
|
switch(_state.label){
|
|
2382
2414
|
case 0:
|
|
2383
2415
|
context = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {};
|
|
2416
|
+
if (!canPublish(licenseKey)) return [
|
|
2417
|
+
2
|
|
2418
|
+
];
|
|
2384
2419
|
_state.label = 1;
|
|
2385
2420
|
case 1:
|
|
2386
2421
|
_state.trys.push([
|
|
2387
2422
|
1,
|
|
2388
|
-
|
|
2423
|
+
3,
|
|
2389
2424
|
,
|
|
2390
|
-
|
|
2425
|
+
4
|
|
2391
2426
|
]);
|
|
2392
|
-
clientInfo = getClientInfo();
|
|
2393
|
-
return [
|
|
2394
|
-
4,
|
|
2395
|
-
getBrowserID(clientInfo)
|
|
2396
|
-
];
|
|
2397
|
-
case 2:
|
|
2398
|
-
browserId = _state.sent();
|
|
2399
|
-
trackingData = _object_spread({
|
|
2400
|
-
browserId: browserId
|
|
2401
|
-
}, clientInfo);
|
|
2402
2427
|
return [
|
|
2403
2428
|
4,
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
player_id: browserId,
|
|
2408
|
-
device_type: clientInfo.deviceType,
|
|
2409
|
-
input_stream_type: context.inputStreamType,
|
|
2410
|
-
os: clientInfo.os,
|
|
2411
|
-
ad_loaded: false,
|
|
2412
|
-
ad_detect: false,
|
|
2413
|
-
license_key: licenseKey,
|
|
2414
|
-
capture_at: /* @__PURE__ */ new Date().toISOString()
|
|
2415
|
-
}
|
|
2416
|
-
],
|
|
2417
|
-
trackingData: trackingData
|
|
2429
|
+
buildPlayerMetricEvent(context, {
|
|
2430
|
+
adLoaded: false,
|
|
2431
|
+
adDetect: false
|
|
2418
2432
|
})
|
|
2419
2433
|
];
|
|
2420
|
-
case
|
|
2421
|
-
_state.sent();
|
|
2434
|
+
case 2:
|
|
2435
|
+
metricEvent = _state.sent();
|
|
2436
|
+
publishTracking(licenseKey, "metrics", {
|
|
2437
|
+
events: [
|
|
2438
|
+
metricEvent
|
|
2439
|
+
]
|
|
2440
|
+
});
|
|
2422
2441
|
return [
|
|
2423
2442
|
3,
|
|
2424
|
-
|
|
2443
|
+
4
|
|
2425
2444
|
];
|
|
2426
|
-
case
|
|
2445
|
+
case 3:
|
|
2427
2446
|
error = _state.sent();
|
|
2428
2447
|
console.error("[StormcloudVideoPlayer] Error sending initial tracking data:", error);
|
|
2429
2448
|
return [
|
|
2430
2449
|
3,
|
|
2431
|
-
|
|
2450
|
+
4
|
|
2432
2451
|
];
|
|
2433
|
-
case
|
|
2452
|
+
case 4:
|
|
2434
2453
|
return [
|
|
2435
2454
|
2
|
|
2436
2455
|
];
|
|
@@ -2534,53 +2553,48 @@ function sendAdImpressionTracking(_0, _1) {
|
|
|
2534
2553
|
switch(_state.label){
|
|
2535
2554
|
case 0:
|
|
2536
2555
|
context = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : {};
|
|
2556
|
+
if (!canPublish(licenseKey)) return [
|
|
2557
|
+
2
|
|
2558
|
+
];
|
|
2537
2559
|
_state.label = 1;
|
|
2538
2560
|
case 1:
|
|
2539
2561
|
_state.trys.push([
|
|
2540
2562
|
1,
|
|
2541
|
-
|
|
2563
|
+
3,
|
|
2542
2564
|
,
|
|
2543
|
-
|
|
2565
|
+
4
|
|
2544
2566
|
]);
|
|
2545
2567
|
return [
|
|
2546
2568
|
4,
|
|
2547
|
-
buildPlayerMetricEvent(
|
|
2569
|
+
buildPlayerMetricEvent(context, {
|
|
2548
2570
|
captureAt: adImpressionInfo.timestamp
|
|
2549
2571
|
})
|
|
2550
2572
|
];
|
|
2551
2573
|
case 2:
|
|
2552
2574
|
metricEvent = _state.sent();
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
capture_at: adImpressionInfo.timestamp
|
|
2565
|
-
}
|
|
2566
|
-
]
|
|
2567
|
-
})
|
|
2568
|
-
])
|
|
2569
|
-
];
|
|
2570
|
-
case 3:
|
|
2571
|
-
_state.sent();
|
|
2575
|
+
publishTracking(licenseKey, "heartbeat", metricEvent);
|
|
2576
|
+
publishTracking(licenseKey, "impressions", {
|
|
2577
|
+
events: [
|
|
2578
|
+
{
|
|
2579
|
+
player_id: metricEvent.player_id,
|
|
2580
|
+
ad_played_count: 1,
|
|
2581
|
+
ad_url: adImpressionInfo.adUrl,
|
|
2582
|
+
capture_at: adImpressionInfo.timestamp
|
|
2583
|
+
}
|
|
2584
|
+
]
|
|
2585
|
+
});
|
|
2572
2586
|
return [
|
|
2573
2587
|
3,
|
|
2574
|
-
|
|
2588
|
+
4
|
|
2575
2589
|
];
|
|
2576
|
-
case
|
|
2590
|
+
case 3:
|
|
2577
2591
|
error = _state.sent();
|
|
2578
2592
|
console.error("[StormcloudVideoPlayer] Error sending ad impression tracking:", error);
|
|
2579
2593
|
return [
|
|
2580
2594
|
3,
|
|
2581
|
-
|
|
2595
|
+
4
|
|
2582
2596
|
];
|
|
2583
|
-
case
|
|
2597
|
+
case 4:
|
|
2584
2598
|
return [
|
|
2585
2599
|
2
|
|
2586
2600
|
];
|
|
@@ -2596,38 +2610,36 @@ function sendHeartbeat(_0) {
|
|
|
2596
2610
|
switch(_state.label){
|
|
2597
2611
|
case 0:
|
|
2598
2612
|
context = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {}, flags = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : {};
|
|
2613
|
+
if (!canPublish(licenseKey)) return [
|
|
2614
|
+
2
|
|
2615
|
+
];
|
|
2599
2616
|
_state.label = 1;
|
|
2600
2617
|
case 1:
|
|
2601
2618
|
_state.trys.push([
|
|
2602
2619
|
1,
|
|
2603
|
-
|
|
2620
|
+
3,
|
|
2604
2621
|
,
|
|
2605
|
-
|
|
2622
|
+
4
|
|
2606
2623
|
]);
|
|
2607
2624
|
return [
|
|
2608
2625
|
4,
|
|
2609
|
-
buildPlayerMetricEvent(
|
|
2626
|
+
buildPlayerMetricEvent(context, flags)
|
|
2610
2627
|
];
|
|
2611
2628
|
case 2:
|
|
2612
2629
|
heartbeatData = _state.sent();
|
|
2613
|
-
|
|
2614
|
-
4,
|
|
2615
|
-
postJson(HEARTBEAT_URL, licenseKey, heartbeatData)
|
|
2616
|
-
];
|
|
2617
|
-
case 3:
|
|
2618
|
-
_state.sent();
|
|
2630
|
+
publishTracking(licenseKey, "heartbeat", heartbeatData);
|
|
2619
2631
|
return [
|
|
2620
2632
|
3,
|
|
2621
|
-
|
|
2633
|
+
4
|
|
2622
2634
|
];
|
|
2623
|
-
case
|
|
2635
|
+
case 3:
|
|
2624
2636
|
error = _state.sent();
|
|
2625
2637
|
console.error("[StormcloudVideoPlayer] Error sending heartbeat:", error);
|
|
2626
2638
|
return [
|
|
2627
2639
|
3,
|
|
2628
|
-
|
|
2640
|
+
4
|
|
2629
2641
|
];
|
|
2630
|
-
case
|
|
2642
|
+
case 4:
|
|
2631
2643
|
return [
|
|
2632
2644
|
2
|
|
2633
2645
|
];
|
|
@@ -4569,6 +4581,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4569
4581
|
key: "initializeTracking",
|
|
4570
4582
|
value: function initializeTracking() {
|
|
4571
4583
|
var _this = this;
|
|
4584
|
+
if (isMQTTEnabled()) {
|
|
4585
|
+
initMQTTClient();
|
|
4586
|
+
}
|
|
4572
4587
|
sendInitialTracking(this.config.licenseKey, this.getAnalyticsContext()).then(function() {
|
|
4573
4588
|
_this.heartbeatInterval = window.setInterval(function() {
|
|
4574
4589
|
_this.sendHeartbeatIfNeeded();
|
|
@@ -6248,6 +6263,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6248
6263
|
clearInterval(this.heartbeatInterval);
|
|
6249
6264
|
this.heartbeatInterval = void 0;
|
|
6250
6265
|
}
|
|
6266
|
+
if (isMQTTEnabled()) {
|
|
6267
|
+
disconnectMQTT();
|
|
6268
|
+
}
|
|
6251
6269
|
(_this_hls = this.hls) === null || _this_hls === void 0 ? void 0 : _this_hls.destroy();
|
|
6252
6270
|
(_this_adLayer = this.adLayer) === null || _this_adLayer === void 0 ? void 0 : _this_adLayer.destroy();
|
|
6253
6271
|
this.consecutiveFailures = 0;
|
|
@@ -8690,5 +8708,5 @@ var createStormcloudPlayer = function createStormcloudPlayer(playerList, fallbac
|
|
|
8690
8708
|
};
|
|
8691
8709
|
var StormcloudPlayer = createStormcloudPlayer(players_default, players_default[players_default.length - 1]);
|
|
8692
8710
|
var StormcloudPlayer_default = StormcloudPlayer;
|
|
8693
|
-
export { IS_BROWSER, IS_GLOBAL, IS_IOS, IS_SAFARI, SUPPORTS_DASH, SUPPORTS_HLS, StormcloudPlayer_default as StormcloudPlayer, StormcloudVideoPlayer, StormcloudVideoPlayerComponent, canPlay, createStormcloudPlayer, createVastAdLayer, createVastManager, StormcloudVideoPlayerComponent as default, detectBrowser, getBrowserConfigOverrides, getBrowserID, getClientInfo, initializePolyfills, isMediaStream, lazy, logBrowserInfo, merge, omit, parseQuery, players_default as players, randomString, sendHeartbeat, sendInitialTracking, supportsFeature, supportsModernJS, supportsWebKitPresentationMode };
|
|
8711
|
+
export { DEFAULT_MQTT_CONFIG, IS_BROWSER, IS_GLOBAL, IS_IOS, IS_SAFARI, SUPPORTS_DASH, SUPPORTS_HLS, StormcloudPlayer_default as StormcloudPlayer, StormcloudVideoPlayer, StormcloudVideoPlayerComponent, applyMQTTConfig, buildMQTTBrokerUrl, buildPlayerTopic, canPlay, configureMQTT, createStormcloudPlayer, createVastAdLayer, createVastManager, StormcloudVideoPlayerComponent as default, detectBrowser, disconnectMQTT, ensureMQTTClient, getBrowserConfigOverrides, getBrowserID, getClientInfo, getMQTTStatus, initMQTTClient, initializePolyfills, isMQTTConfigured, isMQTTConnected, isMQTTEnabled, isMediaStream, lazy, logBrowserInfo, merge, mqttConfig, omit, parseQuery, players_default as players, publishMQTT, randomString, sendHeartbeat, sendInitialTracking, supportsFeature, supportsModernJS, supportsWebKitPresentationMode };
|
|
8694
8712
|
//# sourceMappingURL=index.js.map
|