stormcloud-video-player 0.2.16 → 0.2.17
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 +38 -2
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +38 -2
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +38 -2
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.cjs +38 -2
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/index.cjs +38 -2
- package/lib/players/index.cjs.map +1 -1
- package/lib/sdk/ima.cjs +38 -2
- package/lib/sdk/ima.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +38 -2
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/package.json +1 -1
package/lib/index.cjs
CHANGED
|
@@ -351,6 +351,14 @@ function createImaController(video, options) {
|
|
|
351
351
|
function makeAdsRequest(google, vastTagUrl) {
|
|
352
352
|
const adsRequest = new google.ima.AdsRequest();
|
|
353
353
|
adsRequest.adTagUrl = vastTagUrl;
|
|
354
|
+
const videoWidth = video.offsetWidth || video.clientWidth || 640;
|
|
355
|
+
const videoHeight = video.offsetHeight || video.clientHeight || 360;
|
|
356
|
+
adsRequest.linearAdSlotWidth = videoWidth;
|
|
357
|
+
adsRequest.linearAdSlotHeight = videoHeight;
|
|
358
|
+
adsRequest.nonLinearAdSlotWidth = videoWidth;
|
|
359
|
+
adsRequest.nonLinearAdSlotHeight = videoHeight;
|
|
360
|
+
adsRequest.vastLoadTimeout = 5e3;
|
|
361
|
+
console.log(`[IMA] Ads request dimensions: ${videoWidth}x${videoHeight}`);
|
|
354
362
|
adsLoader.requestAds(adsRequest);
|
|
355
363
|
}
|
|
356
364
|
function destroyAdsManager() {
|
|
@@ -397,6 +405,18 @@ function createImaController(video, options) {
|
|
|
397
405
|
},
|
|
398
406
|
async requestAds(vastTagUrl) {
|
|
399
407
|
console.log("[IMA] Requesting ads:", vastTagUrl);
|
|
408
|
+
if (!vastTagUrl || vastTagUrl.trim() === "") {
|
|
409
|
+
const error = new Error("VAST tag URL is empty or undefined");
|
|
410
|
+
console.warn("[IMA]", error.message);
|
|
411
|
+
return Promise.reject(error);
|
|
412
|
+
}
|
|
413
|
+
try {
|
|
414
|
+
new URL(vastTagUrl);
|
|
415
|
+
} catch (e) {
|
|
416
|
+
const error = new Error(`Invalid VAST tag URL format: ${vastTagUrl}`);
|
|
417
|
+
console.warn("[IMA]", error.message);
|
|
418
|
+
return Promise.reject(error);
|
|
419
|
+
}
|
|
400
420
|
if (adPlaying) {
|
|
401
421
|
console.warn(
|
|
402
422
|
"[IMA] Cannot request new ads while an ad is playing. Call stop() first."
|
|
@@ -458,6 +478,18 @@ function createImaController(video, options) {
|
|
|
458
478
|
);
|
|
459
479
|
}
|
|
460
480
|
}
|
|
481
|
+
const videoWidth = video.offsetWidth || video.clientWidth;
|
|
482
|
+
const videoHeight = video.offsetHeight || video.clientHeight;
|
|
483
|
+
if (!videoWidth || !videoHeight || videoWidth === 0 || videoHeight === 0) {
|
|
484
|
+
const error = new Error(
|
|
485
|
+
`Invalid video dimensions: ${videoWidth}x${videoHeight}. Cannot initialize ads.`
|
|
486
|
+
);
|
|
487
|
+
console.warn("[IMA]", error.message);
|
|
488
|
+
currentReject == null ? void 0 : currentReject(error);
|
|
489
|
+
adsLoadedReject = void 0;
|
|
490
|
+
adsLoadedResolve = void 0;
|
|
491
|
+
return Promise.reject(error);
|
|
492
|
+
}
|
|
461
493
|
if (!adsLoader) {
|
|
462
494
|
console.log("[IMA] Creating ads loader");
|
|
463
495
|
const adsLoaderCls = new google.ima.AdsLoader(adDisplayContainer);
|
|
@@ -506,7 +538,9 @@ function createImaController(video, options) {
|
|
|
506
538
|
emit("ad_error");
|
|
507
539
|
if (!(options == null ? void 0 : options.continueLiveStreamDuringAds)) {
|
|
508
540
|
if (video.paused) {
|
|
509
|
-
console.log(
|
|
541
|
+
console.log(
|
|
542
|
+
"[IMA] Resuming paused video after ad error"
|
|
543
|
+
);
|
|
510
544
|
(_a = video.play()) == null ? void 0 : _a.catch(() => {
|
|
511
545
|
});
|
|
512
546
|
}
|
|
@@ -608,7 +642,9 @@ function createImaController(video, options) {
|
|
|
608
642
|
}
|
|
609
643
|
if (!(options == null ? void 0 : options.continueLiveStreamDuringAds)) {
|
|
610
644
|
if (video.paused) {
|
|
611
|
-
console.log(
|
|
645
|
+
console.log(
|
|
646
|
+
"[IMA] Resuming paused video after setup error"
|
|
647
|
+
);
|
|
612
648
|
video.play().catch(() => {
|
|
613
649
|
});
|
|
614
650
|
}
|