stormcloud-video-player 0.2.25 → 0.2.26
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 +2 -2
- package/lib/index.cjs +49 -13
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +2 -1
- package/lib/index.d.ts +2 -1
- package/lib/index.js +49 -13
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +49 -13
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/player/StormcloudVideoPlayer.d.cts +1 -1
- package/lib/players/HlsPlayer.cjs +49 -13
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.d.cts +1 -1
- package/lib/players/index.cjs +49 -13
- package/lib/players/index.cjs.map +1 -1
- package/lib/sdk/hlsAdPlayer.cjs +15 -3
- package/lib/sdk/hlsAdPlayer.cjs.map +1 -1
- package/lib/sdk/hlsAdPlayer.d.cts +1 -1
- package/lib/sdk/ima.cjs +26 -3
- package/lib/sdk/ima.cjs.map +1 -1
- package/lib/sdk/ima.d.cts +1 -1
- package/lib/{types-9_2sbHCg.d.cts → types-t9jEJXZy.d.cts} +2 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +49 -13
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.d.cts +1 -1
- package/lib/utils/tracking.d.cts +1 -1
- package/package.json +1 -1
|
@@ -199,6 +199,7 @@ function getBrowserConfigOverrides() {
|
|
|
199
199
|
function createImaController(video, options) {
|
|
200
200
|
let adPlaying = false;
|
|
201
201
|
let originalMutedState = false;
|
|
202
|
+
let originalVolume = typeof video.volume === "number" && !Number.isNaN(video.volume) ? Math.max(0, Math.min(1, video.volume)) : 1;
|
|
202
203
|
const listeners = /* @__PURE__ */ new Map();
|
|
203
204
|
const preloadedVast = /* @__PURE__ */ new Map();
|
|
204
205
|
const preloadingVast = /* @__PURE__ */ new Map();
|
|
@@ -307,6 +308,22 @@ function createImaController(video, options) {
|
|
|
307
308
|
adsRequest.linearAdSlotHeight = videoHeight;
|
|
308
309
|
adsRequest.nonLinearAdSlotWidth = videoWidth;
|
|
309
310
|
adsRequest.nonLinearAdSlotHeight = videoHeight;
|
|
311
|
+
if (typeof adsRequest.setAdWillAutoPlay === "function") {
|
|
312
|
+
try {
|
|
313
|
+
const willAutoPlay = !video.paused || video.autoplay;
|
|
314
|
+
adsRequest.setAdWillAutoPlay(willAutoPlay);
|
|
315
|
+
} catch (error) {
|
|
316
|
+
console.warn("[IMA] Failed to call setAdWillAutoPlay:", error);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
if (typeof adsRequest.setAdWillPlayMuted === "function") {
|
|
320
|
+
try {
|
|
321
|
+
const willPlayMuted = video.muted || video.volume === 0;
|
|
322
|
+
adsRequest.setAdWillPlayMuted(willPlayMuted);
|
|
323
|
+
} catch (error) {
|
|
324
|
+
console.warn("[IMA] Failed to call setAdWillPlayMuted:", error);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
310
327
|
adsRequest.vastLoadTimeout = 5e3;
|
|
311
328
|
console.log(`[IMA] Ads request dimensions: ${videoWidth}x${videoHeight}`);
|
|
312
329
|
adsLoader.requestAds(adsRequest);
|
|
@@ -712,7 +729,7 @@ function createImaController(video, options) {
|
|
|
712
729
|
console.log(`[IMA] Initializing ads manager (${width}x${height})`);
|
|
713
730
|
adsManager.init(width, height, window.google.ima.ViewMode.NORMAL);
|
|
714
731
|
adPlaying = true;
|
|
715
|
-
const adVolume = originalMutedState ? 0 :
|
|
732
|
+
const adVolume = originalMutedState ? 0 : originalVolume;
|
|
716
733
|
try {
|
|
717
734
|
adsManager.setVolume(adVolume);
|
|
718
735
|
console.log(`[IMA] Set ad volume to ${adVolume}`);
|
|
@@ -754,6 +771,7 @@ function createImaController(video, options) {
|
|
|
754
771
|
destroyAdsManager();
|
|
755
772
|
adPlaying = false;
|
|
756
773
|
video.muted = originalMutedState;
|
|
774
|
+
video.volume = originalVolume;
|
|
757
775
|
setAdPlayingFlag(false);
|
|
758
776
|
if (adContainerEl) {
|
|
759
777
|
adContainerEl.style.pointerEvents = "none";
|
|
@@ -798,15 +816,20 @@ function createImaController(video, options) {
|
|
|
798
816
|
var _a;
|
|
799
817
|
(_a = listeners.get(event)) == null ? void 0 : _a.delete(listener);
|
|
800
818
|
},
|
|
801
|
-
updateOriginalMutedState(muted) {
|
|
819
|
+
updateOriginalMutedState(muted, volume) {
|
|
820
|
+
const nextVolume = typeof volume === "number" && !Number.isNaN(volume) ? Math.max(0, Math.min(1, volume)) : originalVolume;
|
|
802
821
|
console.log(
|
|
803
|
-
`[IMA] updateOriginalMutedState called: ${originalMutedState} -> ${muted}`
|
|
822
|
+
`[IMA] updateOriginalMutedState called: { muted: ${originalMutedState} -> ${muted}, volume: ${originalVolume} -> ${nextVolume} }`
|
|
804
823
|
);
|
|
805
824
|
originalMutedState = muted;
|
|
825
|
+
originalVolume = nextVolume;
|
|
806
826
|
},
|
|
807
827
|
getOriginalMutedState() {
|
|
808
828
|
return originalMutedState;
|
|
809
829
|
},
|
|
830
|
+
getOriginalVolume() {
|
|
831
|
+
return originalVolume;
|
|
832
|
+
},
|
|
810
833
|
setAdVolume(volume) {
|
|
811
834
|
if (adsManager && adPlaying) {
|
|
812
835
|
try {
|
|
@@ -848,6 +871,7 @@ var import_hls = __toESM(require("hls.js"), 1);
|
|
|
848
871
|
function createHlsAdPlayer(contentVideo, options) {
|
|
849
872
|
let adPlaying = false;
|
|
850
873
|
let originalMutedState = false;
|
|
874
|
+
let originalVolume = Math.max(0, Math.min(1, contentVideo.volume || 1));
|
|
851
875
|
const listeners = /* @__PURE__ */ new Map();
|
|
852
876
|
const licenseKey = options == null ? void 0 : options.licenseKey;
|
|
853
877
|
const mainHlsInstance = options == null ? void 0 : options.mainHlsInstance;
|
|
@@ -1205,6 +1229,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1205
1229
|
setAdPlayingFlag(false);
|
|
1206
1230
|
const previousMutedState = contentVideo.muted;
|
|
1207
1231
|
contentVideo.muted = originalMutedState;
|
|
1232
|
+
contentVideo.volume = originalMutedState ? 0 : originalVolume;
|
|
1208
1233
|
console.log(
|
|
1209
1234
|
`[HlsAdPlayer] Restored mute state: ${previousMutedState} -> ${originalMutedState}`
|
|
1210
1235
|
);
|
|
@@ -1334,6 +1359,10 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1334
1359
|
complete: false
|
|
1335
1360
|
};
|
|
1336
1361
|
const contentVolume = contentVideo.volume;
|
|
1362
|
+
originalVolume = Math.max(
|
|
1363
|
+
0,
|
|
1364
|
+
Math.min(1, contentVolume || originalVolume)
|
|
1365
|
+
);
|
|
1337
1366
|
if (!(options == null ? void 0 : options.continueLiveStreamDuringAds)) {
|
|
1338
1367
|
contentVideo.pause();
|
|
1339
1368
|
console.log("[HlsAdPlayer] Content paused (VOD mode)");
|
|
@@ -1346,7 +1375,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1346
1375
|
adPlaying = true;
|
|
1347
1376
|
setAdPlayingFlag(true);
|
|
1348
1377
|
if (adVideoElement) {
|
|
1349
|
-
const adVolume = originalMutedState ? 0 :
|
|
1378
|
+
const adVolume = originalMutedState ? 0 : originalVolume;
|
|
1350
1379
|
adVideoElement.volume = Math.max(0, Math.min(1, adVolume));
|
|
1351
1380
|
adVideoElement.muted = false;
|
|
1352
1381
|
console.log(
|
|
@@ -1425,6 +1454,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1425
1454
|
adPlaying = false;
|
|
1426
1455
|
setAdPlayingFlag(false);
|
|
1427
1456
|
contentVideo.muted = originalMutedState;
|
|
1457
|
+
contentVideo.volume = originalMutedState ? 0 : originalVolume;
|
|
1428
1458
|
if (adHls) {
|
|
1429
1459
|
adHls.destroy();
|
|
1430
1460
|
adHls = void 0;
|
|
@@ -1466,15 +1496,20 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1466
1496
|
var _a;
|
|
1467
1497
|
(_a = listeners.get(event)) == null ? void 0 : _a.delete(listener);
|
|
1468
1498
|
},
|
|
1469
|
-
updateOriginalMutedState(muted) {
|
|
1499
|
+
updateOriginalMutedState(muted, volume) {
|
|
1500
|
+
const nextVolume = typeof volume === "number" && !Number.isNaN(volume) ? Math.max(0, Math.min(1, volume)) : originalVolume;
|
|
1470
1501
|
console.log(
|
|
1471
|
-
`[HlsAdPlayer] updateOriginalMutedState called: ${originalMutedState} -> ${muted}`
|
|
1502
|
+
`[HlsAdPlayer] updateOriginalMutedState called: { muted: ${originalMutedState} -> ${muted}, volume: ${originalVolume} -> ${nextVolume} }`
|
|
1472
1503
|
);
|
|
1473
1504
|
originalMutedState = muted;
|
|
1505
|
+
originalVolume = nextVolume;
|
|
1474
1506
|
},
|
|
1475
1507
|
getOriginalMutedState() {
|
|
1476
1508
|
return originalMutedState;
|
|
1477
1509
|
},
|
|
1510
|
+
getOriginalVolume() {
|
|
1511
|
+
return originalVolume;
|
|
1512
|
+
},
|
|
1478
1513
|
setAdVolume(volume) {
|
|
1479
1514
|
if (adVideoElement && adPlaying) {
|
|
1480
1515
|
adVideoElement.volume = Math.max(0, Math.min(1, volume));
|
|
@@ -2255,7 +2290,7 @@ var StormcloudVideoPlayer = class {
|
|
|
2255
2290
|
this.video.autoplay = !!this.config.autoplay;
|
|
2256
2291
|
this.video.muted = !!this.config.muted;
|
|
2257
2292
|
this.ima.initialize();
|
|
2258
|
-
this.ima.updateOriginalMutedState(this.video.muted);
|
|
2293
|
+
this.ima.updateOriginalMutedState(this.video.muted, this.video.volume);
|
|
2259
2294
|
this.ima.on("all_ads_completed", () => {
|
|
2260
2295
|
if (this.config.debugAdTiming) {
|
|
2261
2296
|
console.log(
|
|
@@ -3144,7 +3179,7 @@ var StormcloudVideoPlayer = class {
|
|
|
3144
3179
|
}
|
|
3145
3180
|
);
|
|
3146
3181
|
}
|
|
3147
|
-
this.ima.updateOriginalMutedState(this.video.muted);
|
|
3182
|
+
this.ima.updateOriginalMutedState(this.video.muted, this.video.volume);
|
|
3148
3183
|
} else if (this.config.debugAdTiming) {
|
|
3149
3184
|
console.log(
|
|
3150
3185
|
`[StormcloudVideoPlayer] Keeping existing original mute state (currently showing ads)`
|
|
@@ -3206,8 +3241,9 @@ var StormcloudVideoPlayer = class {
|
|
|
3206
3241
|
this.ima.stop().catch(() => {
|
|
3207
3242
|
});
|
|
3208
3243
|
const originalMutedState = this.ima.getOriginalMutedState();
|
|
3244
|
+
const originalVolume = typeof this.ima.getOriginalVolume === "function" ? this.ima.getOriginalVolume() : this.video.volume;
|
|
3209
3245
|
this.video.muted = originalMutedState;
|
|
3210
|
-
this.video.volume =
|
|
3246
|
+
this.video.volume = originalVolume;
|
|
3211
3247
|
if (this.config.debugAdTiming) {
|
|
3212
3248
|
console.log(
|
|
3213
3249
|
`[StormcloudVideoPlayer] Restored main video - muted: ${originalMutedState}, volume: ${this.video.volume}`
|
|
@@ -3358,7 +3394,7 @@ var StormcloudVideoPlayer = class {
|
|
|
3358
3394
|
if (this.ima.isAdPlaying()) {
|
|
3359
3395
|
const currentPerceptualState = this.isMuted();
|
|
3360
3396
|
const newMutedState = !currentPerceptualState;
|
|
3361
|
-
this.ima.updateOriginalMutedState(newMutedState);
|
|
3397
|
+
this.ima.updateOriginalMutedState(newMutedState, this.video.volume);
|
|
3362
3398
|
this.ima.setAdVolume(newMutedState ? 0 : 1);
|
|
3363
3399
|
if (this.config.debugAdTiming) {
|
|
3364
3400
|
console.log(
|
|
@@ -3368,7 +3404,7 @@ var StormcloudVideoPlayer = class {
|
|
|
3368
3404
|
}
|
|
3369
3405
|
} else {
|
|
3370
3406
|
this.video.muted = !this.video.muted;
|
|
3371
|
-
this.ima.updateOriginalMutedState(this.video.muted);
|
|
3407
|
+
this.ima.updateOriginalMutedState(this.video.muted, this.video.volume);
|
|
3372
3408
|
if (this.config.debugAdTiming) {
|
|
3373
3409
|
console.log("[StormcloudVideoPlayer] Muted:", this.video.muted);
|
|
3374
3410
|
}
|
|
@@ -3440,7 +3476,7 @@ var StormcloudVideoPlayer = class {
|
|
|
3440
3476
|
}
|
|
3441
3477
|
this.video.muted = muted;
|
|
3442
3478
|
if (adPlaying) {
|
|
3443
|
-
this.ima.updateOriginalMutedState(muted);
|
|
3479
|
+
this.ima.updateOriginalMutedState(muted, this.video.volume);
|
|
3444
3480
|
this.ima.setAdVolume(muted ? 0 : 1);
|
|
3445
3481
|
if (this.config.debugAdTiming) {
|
|
3446
3482
|
console.log("[StormcloudVideoPlayer] setMuted applied during ad", {
|
|
@@ -3449,7 +3485,7 @@ var StormcloudVideoPlayer = class {
|
|
|
3449
3485
|
}
|
|
3450
3486
|
return;
|
|
3451
3487
|
}
|
|
3452
|
-
this.ima.updateOriginalMutedState(muted);
|
|
3488
|
+
this.ima.updateOriginalMutedState(muted, this.video.volume);
|
|
3453
3489
|
if (this.config.debugAdTiming) {
|
|
3454
3490
|
console.log("[StormcloudVideoPlayer] setMuted called:", muted);
|
|
3455
3491
|
}
|