stormcloud-video-player 0.2.7 → 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 +32 -16
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +32 -16
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +32 -16
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.cjs +32 -16
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/index.cjs +32 -16
- 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 +32 -16
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/utils/tracking.cjs +9 -3
- package/lib/utils/tracking.cjs.map +1 -1
- package/package.json +1 -1
|
@@ -243,7 +243,9 @@ function createImaController(video, options) {
|
|
|
243
243
|
AdEvent.CONTENT_PAUSE_REQUESTED,
|
|
244
244
|
() => {
|
|
245
245
|
console.log("[IMA] Content pause requested");
|
|
246
|
-
|
|
246
|
+
if (!adPlaying) {
|
|
247
|
+
originalMutedState = video.muted;
|
|
248
|
+
}
|
|
247
249
|
video.muted = true;
|
|
248
250
|
if (!options?.continueLiveStreamDuringAds) {
|
|
249
251
|
video.pause();
|
|
@@ -365,14 +367,6 @@ function createImaController(video, options) {
|
|
|
365
367
|
const height = video.clientHeight || 360;
|
|
366
368
|
console.log(`[IMA] Initializing ads manager (${width}x${height})`);
|
|
367
369
|
adsManager.init(width, height, window.google.ima.ViewMode.NORMAL);
|
|
368
|
-
if (!options?.continueLiveStreamDuringAds) {
|
|
369
|
-
console.log("[IMA] Pausing video for ad playback (VOD mode)");
|
|
370
|
-
video.pause();
|
|
371
|
-
} else {
|
|
372
|
-
console.log(
|
|
373
|
-
"[IMA] Keeping video playing but muted for ad playback (Live mode)"
|
|
374
|
-
);
|
|
375
|
-
}
|
|
376
370
|
adPlaying = true;
|
|
377
371
|
console.log("[IMA] Starting ad playback");
|
|
378
372
|
adsManager.start();
|
|
@@ -471,6 +465,7 @@ function createImaController(video, options) {
|
|
|
471
465
|
}
|
|
472
466
|
|
|
473
467
|
// src/utils/tracking.ts
|
|
468
|
+
var cachedBrowserId = null;
|
|
474
469
|
function getClientInfo() {
|
|
475
470
|
const ua = navigator.userAgent;
|
|
476
471
|
const platform = navigator.platform;
|
|
@@ -613,20 +608,24 @@ function getClientInfo() {
|
|
|
613
608
|
};
|
|
614
609
|
}
|
|
615
610
|
async function getBrowserID(clientInfo) {
|
|
611
|
+
if (cachedBrowserId) {
|
|
612
|
+
return cachedBrowserId;
|
|
613
|
+
}
|
|
616
614
|
const fingerprintString = JSON.stringify(clientInfo);
|
|
617
615
|
if (typeof crypto !== "undefined" && crypto.subtle && crypto.subtle.digest) {
|
|
618
616
|
try {
|
|
617
|
+
await crypto.subtle.digest("SHA-256", new Uint8Array([1, 2, 3]));
|
|
619
618
|
const hashBuffer = await crypto.subtle.digest(
|
|
620
619
|
"SHA-256",
|
|
621
620
|
new TextEncoder().encode(fingerprintString)
|
|
622
621
|
);
|
|
623
622
|
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
|
624
623
|
const hashHex = hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
624
|
+
cachedBrowserId = hashHex;
|
|
625
625
|
return hashHex;
|
|
626
626
|
} catch (error) {
|
|
627
627
|
console.warn(
|
|
628
|
-
"[StormcloudVideoPlayer] crypto.subtle.digest
|
|
629
|
-
error
|
|
628
|
+
"[StormcloudVideoPlayer] crypto.subtle.digest not supported, using fallback hash"
|
|
630
629
|
);
|
|
631
630
|
}
|
|
632
631
|
}
|
|
@@ -639,7 +638,8 @@ async function getBrowserID(clientInfo) {
|
|
|
639
638
|
const fallbackHash = Math.abs(hash).toString(16).padStart(8, "0");
|
|
640
639
|
const timestamp = Date.now().toString(16).padStart(12, "0");
|
|
641
640
|
const random = Math.random().toString(16).substring(2, 14).padStart(12, "0");
|
|
642
|
-
|
|
641
|
+
cachedBrowserId = (fallbackHash + timestamp + random).padEnd(64, "0");
|
|
642
|
+
return cachedBrowserId;
|
|
643
643
|
}
|
|
644
644
|
async function sendInitialTracking(licenseKey) {
|
|
645
645
|
try {
|
|
@@ -1328,17 +1328,21 @@ var StormcloudVideoPlayer = class {
|
|
|
1328
1328
|
return void 0;
|
|
1329
1329
|
}
|
|
1330
1330
|
initializeTracking() {
|
|
1331
|
-
sendInitialTracking(this.config.licenseKey).
|
|
1331
|
+
sendInitialTracking(this.config.licenseKey).then(() => {
|
|
1332
|
+
this.heartbeatInterval = window.setInterval(() => {
|
|
1333
|
+
this.sendHeartbeatIfNeeded();
|
|
1334
|
+
}, 5e3);
|
|
1335
|
+
}).catch((error) => {
|
|
1332
1336
|
if (this.config.debugAdTiming) {
|
|
1333
1337
|
console.warn(
|
|
1334
1338
|
"[StormcloudVideoPlayer] Failed to send initial tracking:",
|
|
1335
1339
|
error
|
|
1336
1340
|
);
|
|
1337
1341
|
}
|
|
1342
|
+
this.heartbeatInterval = window.setInterval(() => {
|
|
1343
|
+
this.sendHeartbeatIfNeeded();
|
|
1344
|
+
}, 5e3);
|
|
1338
1345
|
});
|
|
1339
|
-
this.heartbeatInterval = window.setInterval(() => {
|
|
1340
|
-
this.sendHeartbeatIfNeeded();
|
|
1341
|
-
}, 5e3);
|
|
1342
1346
|
}
|
|
1343
1347
|
sendHeartbeatIfNeeded() {
|
|
1344
1348
|
const now = Date.now();
|
|
@@ -1573,6 +1577,18 @@ var StormcloudVideoPlayer = class {
|
|
|
1573
1577
|
if (this.config.debugAdTiming) {
|
|
1574
1578
|
console.log("[StormcloudVideoPlayer] Attempting to play ad:", vastTagUrl);
|
|
1575
1579
|
}
|
|
1580
|
+
this.ima.updateOriginalMutedState(this.video.muted);
|
|
1581
|
+
if (!this.shouldContinueLiveStreamDuringAds()) {
|
|
1582
|
+
if (this.config.debugAdTiming) {
|
|
1583
|
+
console.log("[StormcloudVideoPlayer] Pausing video immediately for ad (VOD mode)");
|
|
1584
|
+
}
|
|
1585
|
+
this.video.pause();
|
|
1586
|
+
} else {
|
|
1587
|
+
if (this.config.debugAdTiming) {
|
|
1588
|
+
console.log("[StormcloudVideoPlayer] Muting video for ad (Live mode)");
|
|
1589
|
+
}
|
|
1590
|
+
this.video.muted = true;
|
|
1591
|
+
}
|
|
1576
1592
|
this.startAdFailsafeTimer();
|
|
1577
1593
|
try {
|
|
1578
1594
|
await this.ima.requestAds(vastTagUrl);
|