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/players/index.cjs
CHANGED
|
@@ -282,7 +282,9 @@ function createImaController(video, options) {
|
|
|
282
282
|
AdEvent.CONTENT_PAUSE_REQUESTED,
|
|
283
283
|
() => {
|
|
284
284
|
console.log("[IMA] Content pause requested");
|
|
285
|
-
|
|
285
|
+
if (!adPlaying) {
|
|
286
|
+
originalMutedState = video.muted;
|
|
287
|
+
}
|
|
286
288
|
video.muted = true;
|
|
287
289
|
if (!options?.continueLiveStreamDuringAds) {
|
|
288
290
|
video.pause();
|
|
@@ -404,14 +406,6 @@ function createImaController(video, options) {
|
|
|
404
406
|
const height = video.clientHeight || 360;
|
|
405
407
|
console.log(`[IMA] Initializing ads manager (${width}x${height})`);
|
|
406
408
|
adsManager.init(width, height, window.google.ima.ViewMode.NORMAL);
|
|
407
|
-
if (!options?.continueLiveStreamDuringAds) {
|
|
408
|
-
console.log("[IMA] Pausing video for ad playback (VOD mode)");
|
|
409
|
-
video.pause();
|
|
410
|
-
} else {
|
|
411
|
-
console.log(
|
|
412
|
-
"[IMA] Keeping video playing but muted for ad playback (Live mode)"
|
|
413
|
-
);
|
|
414
|
-
}
|
|
415
409
|
adPlaying = true;
|
|
416
410
|
console.log("[IMA] Starting ad playback");
|
|
417
411
|
adsManager.start();
|
|
@@ -510,6 +504,7 @@ function createImaController(video, options) {
|
|
|
510
504
|
}
|
|
511
505
|
|
|
512
506
|
// src/utils/tracking.ts
|
|
507
|
+
var cachedBrowserId = null;
|
|
513
508
|
function getClientInfo() {
|
|
514
509
|
const ua = navigator.userAgent;
|
|
515
510
|
const platform = navigator.platform;
|
|
@@ -652,6 +647,9 @@ function getClientInfo() {
|
|
|
652
647
|
};
|
|
653
648
|
}
|
|
654
649
|
async function getBrowserID(clientInfo) {
|
|
650
|
+
if (cachedBrowserId) {
|
|
651
|
+
return cachedBrowserId;
|
|
652
|
+
}
|
|
655
653
|
const fingerprintString = JSON.stringify(clientInfo);
|
|
656
654
|
if (typeof crypto !== "undefined" && crypto.subtle && crypto.subtle.digest) {
|
|
657
655
|
try {
|
|
@@ -662,6 +660,7 @@ async function getBrowserID(clientInfo) {
|
|
|
662
660
|
);
|
|
663
661
|
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
|
664
662
|
const hashHex = hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
663
|
+
cachedBrowserId = hashHex;
|
|
665
664
|
return hashHex;
|
|
666
665
|
} catch (error) {
|
|
667
666
|
console.warn(
|
|
@@ -678,7 +677,8 @@ async function getBrowserID(clientInfo) {
|
|
|
678
677
|
const fallbackHash = Math.abs(hash).toString(16).padStart(8, "0");
|
|
679
678
|
const timestamp = Date.now().toString(16).padStart(12, "0");
|
|
680
679
|
const random = Math.random().toString(16).substring(2, 14).padStart(12, "0");
|
|
681
|
-
|
|
680
|
+
cachedBrowserId = (fallbackHash + timestamp + random).padEnd(64, "0");
|
|
681
|
+
return cachedBrowserId;
|
|
682
682
|
}
|
|
683
683
|
async function sendInitialTracking(licenseKey) {
|
|
684
684
|
try {
|
|
@@ -1367,17 +1367,21 @@ var StormcloudVideoPlayer = class {
|
|
|
1367
1367
|
return void 0;
|
|
1368
1368
|
}
|
|
1369
1369
|
initializeTracking() {
|
|
1370
|
-
sendInitialTracking(this.config.licenseKey).
|
|
1370
|
+
sendInitialTracking(this.config.licenseKey).then(() => {
|
|
1371
|
+
this.heartbeatInterval = window.setInterval(() => {
|
|
1372
|
+
this.sendHeartbeatIfNeeded();
|
|
1373
|
+
}, 5e3);
|
|
1374
|
+
}).catch((error) => {
|
|
1371
1375
|
if (this.config.debugAdTiming) {
|
|
1372
1376
|
console.warn(
|
|
1373
1377
|
"[StormcloudVideoPlayer] Failed to send initial tracking:",
|
|
1374
1378
|
error
|
|
1375
1379
|
);
|
|
1376
1380
|
}
|
|
1381
|
+
this.heartbeatInterval = window.setInterval(() => {
|
|
1382
|
+
this.sendHeartbeatIfNeeded();
|
|
1383
|
+
}, 5e3);
|
|
1377
1384
|
});
|
|
1378
|
-
this.heartbeatInterval = window.setInterval(() => {
|
|
1379
|
-
this.sendHeartbeatIfNeeded();
|
|
1380
|
-
}, 5e3);
|
|
1381
1385
|
}
|
|
1382
1386
|
sendHeartbeatIfNeeded() {
|
|
1383
1387
|
const now = Date.now();
|
|
@@ -1612,6 +1616,18 @@ var StormcloudVideoPlayer = class {
|
|
|
1612
1616
|
if (this.config.debugAdTiming) {
|
|
1613
1617
|
console.log("[StormcloudVideoPlayer] Attempting to play ad:", vastTagUrl);
|
|
1614
1618
|
}
|
|
1619
|
+
this.ima.updateOriginalMutedState(this.video.muted);
|
|
1620
|
+
if (!this.shouldContinueLiveStreamDuringAds()) {
|
|
1621
|
+
if (this.config.debugAdTiming) {
|
|
1622
|
+
console.log("[StormcloudVideoPlayer] Pausing video immediately for ad (VOD mode)");
|
|
1623
|
+
}
|
|
1624
|
+
this.video.pause();
|
|
1625
|
+
} else {
|
|
1626
|
+
if (this.config.debugAdTiming) {
|
|
1627
|
+
console.log("[StormcloudVideoPlayer] Muting video for ad (Live mode)");
|
|
1628
|
+
}
|
|
1629
|
+
this.video.muted = true;
|
|
1630
|
+
}
|
|
1615
1631
|
this.startAdFailsafeTimer();
|
|
1616
1632
|
try {
|
|
1617
1633
|
await this.ima.requestAds(vastTagUrl);
|