stormcloud-video-player 0.2.8 → 0.2.9
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 +1 -1
- package/lib/index.cjs +30 -14
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +30 -14
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +30 -14
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.cjs +30 -14
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/index.cjs +30 -14
- package/lib/players/index.cjs.map +1 -1
- package/lib/sdk/ima.cjs +3 -9
- package/lib/sdk/ima.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +30 -14
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/utils/tracking.cjs +7 -1
- package/lib/utils/tracking.cjs.map +1 -1
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -209,7 +209,9 @@ function createImaController(video, options) {
|
|
|
209
209
|
AdEvent.CONTENT_PAUSE_REQUESTED,
|
|
210
210
|
() => {
|
|
211
211
|
console.log("[IMA] Content pause requested");
|
|
212
|
-
|
|
212
|
+
if (!adPlaying) {
|
|
213
|
+
originalMutedState = video.muted;
|
|
214
|
+
}
|
|
213
215
|
video.muted = true;
|
|
214
216
|
if (!options?.continueLiveStreamDuringAds) {
|
|
215
217
|
video.pause();
|
|
@@ -331,14 +333,6 @@ function createImaController(video, options) {
|
|
|
331
333
|
const height = video.clientHeight || 360;
|
|
332
334
|
console.log(`[IMA] Initializing ads manager (${width}x${height})`);
|
|
333
335
|
adsManager.init(width, height, window.google.ima.ViewMode.NORMAL);
|
|
334
|
-
if (!options?.continueLiveStreamDuringAds) {
|
|
335
|
-
console.log("[IMA] Pausing video for ad playback (VOD mode)");
|
|
336
|
-
video.pause();
|
|
337
|
-
} else {
|
|
338
|
-
console.log(
|
|
339
|
-
"[IMA] Keeping video playing but muted for ad playback (Live mode)"
|
|
340
|
-
);
|
|
341
|
-
}
|
|
342
336
|
adPlaying = true;
|
|
343
337
|
console.log("[IMA] Starting ad playback");
|
|
344
338
|
adsManager.start();
|
|
@@ -437,6 +431,7 @@ function createImaController(video, options) {
|
|
|
437
431
|
}
|
|
438
432
|
|
|
439
433
|
// src/utils/tracking.ts
|
|
434
|
+
var cachedBrowserId = null;
|
|
440
435
|
function getClientInfo() {
|
|
441
436
|
const ua = navigator.userAgent;
|
|
442
437
|
const platform = navigator.platform;
|
|
@@ -579,6 +574,9 @@ function getClientInfo() {
|
|
|
579
574
|
};
|
|
580
575
|
}
|
|
581
576
|
async function getBrowserID(clientInfo) {
|
|
577
|
+
if (cachedBrowserId) {
|
|
578
|
+
return cachedBrowserId;
|
|
579
|
+
}
|
|
582
580
|
const fingerprintString = JSON.stringify(clientInfo);
|
|
583
581
|
if (typeof crypto !== "undefined" && crypto.subtle && crypto.subtle.digest) {
|
|
584
582
|
try {
|
|
@@ -589,6 +587,7 @@ async function getBrowserID(clientInfo) {
|
|
|
589
587
|
);
|
|
590
588
|
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
|
591
589
|
const hashHex = hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
590
|
+
cachedBrowserId = hashHex;
|
|
592
591
|
return hashHex;
|
|
593
592
|
} catch (error) {
|
|
594
593
|
console.warn(
|
|
@@ -605,7 +604,8 @@ async function getBrowserID(clientInfo) {
|
|
|
605
604
|
const fallbackHash = Math.abs(hash).toString(16).padStart(8, "0");
|
|
606
605
|
const timestamp = Date.now().toString(16).padStart(12, "0");
|
|
607
606
|
const random = Math.random().toString(16).substring(2, 14).padStart(12, "0");
|
|
608
|
-
|
|
607
|
+
cachedBrowserId = (fallbackHash + timestamp + random).padEnd(64, "0");
|
|
608
|
+
return cachedBrowserId;
|
|
609
609
|
}
|
|
610
610
|
async function sendInitialTracking(licenseKey) {
|
|
611
611
|
try {
|
|
@@ -1294,17 +1294,21 @@ var StormcloudVideoPlayer = class {
|
|
|
1294
1294
|
return void 0;
|
|
1295
1295
|
}
|
|
1296
1296
|
initializeTracking() {
|
|
1297
|
-
sendInitialTracking(this.config.licenseKey).
|
|
1297
|
+
sendInitialTracking(this.config.licenseKey).then(() => {
|
|
1298
|
+
this.heartbeatInterval = window.setInterval(() => {
|
|
1299
|
+
this.sendHeartbeatIfNeeded();
|
|
1300
|
+
}, 5e3);
|
|
1301
|
+
}).catch((error) => {
|
|
1298
1302
|
if (this.config.debugAdTiming) {
|
|
1299
1303
|
console.warn(
|
|
1300
1304
|
"[StormcloudVideoPlayer] Failed to send initial tracking:",
|
|
1301
1305
|
error
|
|
1302
1306
|
);
|
|
1303
1307
|
}
|
|
1308
|
+
this.heartbeatInterval = window.setInterval(() => {
|
|
1309
|
+
this.sendHeartbeatIfNeeded();
|
|
1310
|
+
}, 5e3);
|
|
1304
1311
|
});
|
|
1305
|
-
this.heartbeatInterval = window.setInterval(() => {
|
|
1306
|
-
this.sendHeartbeatIfNeeded();
|
|
1307
|
-
}, 5e3);
|
|
1308
1312
|
}
|
|
1309
1313
|
sendHeartbeatIfNeeded() {
|
|
1310
1314
|
const now = Date.now();
|
|
@@ -1539,6 +1543,18 @@ var StormcloudVideoPlayer = class {
|
|
|
1539
1543
|
if (this.config.debugAdTiming) {
|
|
1540
1544
|
console.log("[StormcloudVideoPlayer] Attempting to play ad:", vastTagUrl);
|
|
1541
1545
|
}
|
|
1546
|
+
this.ima.updateOriginalMutedState(this.video.muted);
|
|
1547
|
+
if (!this.shouldContinueLiveStreamDuringAds()) {
|
|
1548
|
+
if (this.config.debugAdTiming) {
|
|
1549
|
+
console.log("[StormcloudVideoPlayer] Pausing video immediately for ad (VOD mode)");
|
|
1550
|
+
}
|
|
1551
|
+
this.video.pause();
|
|
1552
|
+
} else {
|
|
1553
|
+
if (this.config.debugAdTiming) {
|
|
1554
|
+
console.log("[StormcloudVideoPlayer] Muting video for ad (Live mode)");
|
|
1555
|
+
}
|
|
1556
|
+
this.video.muted = true;
|
|
1557
|
+
}
|
|
1542
1558
|
this.startAdFailsafeTimer();
|
|
1543
1559
|
try {
|
|
1544
1560
|
await this.ima.requestAds(vastTagUrl);
|