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/players/index.cjs
CHANGED
|
@@ -326,6 +326,14 @@ function createImaController(video, options) {
|
|
|
326
326
|
function makeAdsRequest(google, vastTagUrl) {
|
|
327
327
|
const adsRequest = new google.ima.AdsRequest();
|
|
328
328
|
adsRequest.adTagUrl = vastTagUrl;
|
|
329
|
+
const videoWidth = video.offsetWidth || video.clientWidth || 640;
|
|
330
|
+
const videoHeight = video.offsetHeight || video.clientHeight || 360;
|
|
331
|
+
adsRequest.linearAdSlotWidth = videoWidth;
|
|
332
|
+
adsRequest.linearAdSlotHeight = videoHeight;
|
|
333
|
+
adsRequest.nonLinearAdSlotWidth = videoWidth;
|
|
334
|
+
adsRequest.nonLinearAdSlotHeight = videoHeight;
|
|
335
|
+
adsRequest.vastLoadTimeout = 5e3;
|
|
336
|
+
console.log(`[IMA] Ads request dimensions: ${videoWidth}x${videoHeight}`);
|
|
329
337
|
adsLoader.requestAds(adsRequest);
|
|
330
338
|
}
|
|
331
339
|
function destroyAdsManager() {
|
|
@@ -372,6 +380,18 @@ function createImaController(video, options) {
|
|
|
372
380
|
},
|
|
373
381
|
async requestAds(vastTagUrl) {
|
|
374
382
|
console.log("[IMA] Requesting ads:", vastTagUrl);
|
|
383
|
+
if (!vastTagUrl || vastTagUrl.trim() === "") {
|
|
384
|
+
const error = new Error("VAST tag URL is empty or undefined");
|
|
385
|
+
console.warn("[IMA]", error.message);
|
|
386
|
+
return Promise.reject(error);
|
|
387
|
+
}
|
|
388
|
+
try {
|
|
389
|
+
new URL(vastTagUrl);
|
|
390
|
+
} catch (e) {
|
|
391
|
+
const error = new Error(`Invalid VAST tag URL format: ${vastTagUrl}`);
|
|
392
|
+
console.warn("[IMA]", error.message);
|
|
393
|
+
return Promise.reject(error);
|
|
394
|
+
}
|
|
375
395
|
if (adPlaying) {
|
|
376
396
|
console.warn(
|
|
377
397
|
"[IMA] Cannot request new ads while an ad is playing. Call stop() first."
|
|
@@ -433,6 +453,18 @@ function createImaController(video, options) {
|
|
|
433
453
|
);
|
|
434
454
|
}
|
|
435
455
|
}
|
|
456
|
+
const videoWidth = video.offsetWidth || video.clientWidth;
|
|
457
|
+
const videoHeight = video.offsetHeight || video.clientHeight;
|
|
458
|
+
if (!videoWidth || !videoHeight || videoWidth === 0 || videoHeight === 0) {
|
|
459
|
+
const error = new Error(
|
|
460
|
+
`Invalid video dimensions: ${videoWidth}x${videoHeight}. Cannot initialize ads.`
|
|
461
|
+
);
|
|
462
|
+
console.warn("[IMA]", error.message);
|
|
463
|
+
currentReject == null ? void 0 : currentReject(error);
|
|
464
|
+
adsLoadedReject = void 0;
|
|
465
|
+
adsLoadedResolve = void 0;
|
|
466
|
+
return Promise.reject(error);
|
|
467
|
+
}
|
|
436
468
|
if (!adsLoader) {
|
|
437
469
|
console.log("[IMA] Creating ads loader");
|
|
438
470
|
const adsLoaderCls = new google.ima.AdsLoader(adDisplayContainer);
|
|
@@ -481,7 +513,9 @@ function createImaController(video, options) {
|
|
|
481
513
|
emit("ad_error");
|
|
482
514
|
if (!(options == null ? void 0 : options.continueLiveStreamDuringAds)) {
|
|
483
515
|
if (video.paused) {
|
|
484
|
-
console.log(
|
|
516
|
+
console.log(
|
|
517
|
+
"[IMA] Resuming paused video after ad error"
|
|
518
|
+
);
|
|
485
519
|
(_a = video.play()) == null ? void 0 : _a.catch(() => {
|
|
486
520
|
});
|
|
487
521
|
}
|
|
@@ -583,7 +617,9 @@ function createImaController(video, options) {
|
|
|
583
617
|
}
|
|
584
618
|
if (!(options == null ? void 0 : options.continueLiveStreamDuringAds)) {
|
|
585
619
|
if (video.paused) {
|
|
586
|
-
console.log(
|
|
620
|
+
console.log(
|
|
621
|
+
"[IMA] Resuming paused video after setup error"
|
|
622
|
+
);
|
|
587
623
|
video.play().catch(() => {
|
|
588
624
|
});
|
|
589
625
|
}
|