stormcloud-video-player 0.8.47 → 0.8.48
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 +52 -53
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +52 -53
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +52 -53
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.cjs +52 -53
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/index.cjs +52 -53
- package/lib/players/index.cjs.map +1 -1
- package/lib/sdk/hlsAdPlayer.cjs +52 -53
- package/lib/sdk/hlsAdPlayer.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +52 -53
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/package.json +1 -1
package/lib/sdk/hlsAdPlayer.cjs
CHANGED
|
@@ -367,6 +367,56 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
367
367
|
var url = mediaFile.url.toLowerCase();
|
|
368
368
|
return type.startsWith("video/") || url.endsWith(".mp4") || url.includes(".mp4?");
|
|
369
369
|
}
|
|
370
|
+
function isAudioMediaFile(mediaFile) {
|
|
371
|
+
var type = mediaFile.type.toLowerCase();
|
|
372
|
+
var url = (mediaFile.url.toLowerCase().split("?")[0] || "").trim();
|
|
373
|
+
return type.startsWith("audio/") || url.endsWith(".mp3") || url.endsWith(".aac") || url.endsWith(".m4a") || url.endsWith(".ogg") || url.endsWith(".oga") || url.endsWith(".opus") || url.endsWith(".wav") || url.endsWith(".weba");
|
|
374
|
+
}
|
|
375
|
+
function collectVideoMediaFiles(scope, verbose) {
|
|
376
|
+
var mediaFileElements = scope.querySelectorAll("MediaFile");
|
|
377
|
+
var mediaFiles = [];
|
|
378
|
+
if (verbose) {
|
|
379
|
+
console.log("[HlsAdPlayer] Found ".concat(mediaFileElements.length, " MediaFile element(s) in VAST XML"));
|
|
380
|
+
}
|
|
381
|
+
mediaFileElements.forEach(function(mf, index) {
|
|
382
|
+
var _mf_textContent;
|
|
383
|
+
var type = mf.getAttribute("type") || "";
|
|
384
|
+
var url = ((_mf_textContent = mf.textContent) === null || _mf_textContent === void 0 ? void 0 : _mf_textContent.trim()) || "";
|
|
385
|
+
var width = mf.getAttribute("width") || "";
|
|
386
|
+
var height = mf.getAttribute("height") || "";
|
|
387
|
+
if (verbose) {
|
|
388
|
+
console.log("[HlsAdPlayer] MediaFile ".concat(index, ': type="').concat(type, '", url="').concat(url, '", width="').concat(width, '", height="').concat(height, '"'));
|
|
389
|
+
}
|
|
390
|
+
if (!url) {
|
|
391
|
+
if (verbose) {
|
|
392
|
+
console.warn("[HlsAdPlayer] MediaFile ".concat(index, " has empty URL"));
|
|
393
|
+
}
|
|
394
|
+
return;
|
|
395
|
+
}
|
|
396
|
+
var bitrateAttr = mf.getAttribute("bitrate");
|
|
397
|
+
var bitrateValue = bitrateAttr ? parseInt(bitrateAttr, 10) : void 0;
|
|
398
|
+
var mediaFile = {
|
|
399
|
+
url: url,
|
|
400
|
+
type: type,
|
|
401
|
+
width: parseInt(width || "1920", 10),
|
|
402
|
+
height: parseInt(height || "1080", 10),
|
|
403
|
+
bitrate: bitrateValue && bitrateValue > 0 ? bitrateValue : void 0
|
|
404
|
+
};
|
|
405
|
+
if (isAudioMediaFile(mediaFile)) {
|
|
406
|
+
console.warn("[HlsAdPlayer] MediaFile ".concat(index, ' skipped (audio-only, type="').concat(type, '") — audio ads are not played to avoid a black screen'));
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
409
|
+
if (isHlsMediaFile(mediaFile) || isProgressiveMediaFile(mediaFile)) {
|
|
410
|
+
mediaFiles.push(mediaFile);
|
|
411
|
+
if (verbose) {
|
|
412
|
+
console.log("[HlsAdPlayer] Added ".concat(isHlsMediaFile(mediaFile) ? "HLS" : "progressive", " MediaFile: ").concat(url));
|
|
413
|
+
}
|
|
414
|
+
} else if (verbose) {
|
|
415
|
+
console.log("[HlsAdPlayer] MediaFile ".concat(index, ' ignored (type="').concat(type, '" is not supported)'));
|
|
416
|
+
}
|
|
417
|
+
});
|
|
418
|
+
return mediaFiles;
|
|
419
|
+
}
|
|
370
420
|
function createEmptyTrackingUrls() {
|
|
371
421
|
return {
|
|
372
422
|
impression: [],
|
|
@@ -454,37 +504,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
454
504
|
var durationText = ((_xmlDoc_querySelector3 = xmlDoc.querySelector("Duration")) === null || _xmlDoc_querySelector3 === void 0 ? void 0 : _xmlDoc_querySelector3.textContent) || "00:00:30";
|
|
455
505
|
var durationParts = durationText.split(":");
|
|
456
506
|
var duration = parseInt(durationParts[0] || "0", 10) * 3600 + parseInt(durationParts[1] || "0", 10) * 60 + parseInt(durationParts[2] || "0", 10);
|
|
457
|
-
var
|
|
458
|
-
var mediaFiles = [];
|
|
459
|
-
console.log("[HlsAdPlayer] Found ".concat(mediaFileElements.length, " MediaFile element(s) in VAST XML"));
|
|
460
|
-
mediaFileElements.forEach(function(mf, index) {
|
|
461
|
-
var _mf_textContent;
|
|
462
|
-
var type = mf.getAttribute("type") || "";
|
|
463
|
-
var url = ((_mf_textContent = mf.textContent) === null || _mf_textContent === void 0 ? void 0 : _mf_textContent.trim()) || "";
|
|
464
|
-
var width = mf.getAttribute("width") || "";
|
|
465
|
-
var height = mf.getAttribute("height") || "";
|
|
466
|
-
console.log("[HlsAdPlayer] MediaFile ".concat(index, ': type="').concat(type, '", url="').concat(url, '", width="').concat(width, '", height="').concat(height, '"'));
|
|
467
|
-
var mediaFile = {
|
|
468
|
-
url: url,
|
|
469
|
-
type: type,
|
|
470
|
-
width: parseInt(width || "1920", 10),
|
|
471
|
-
height: parseInt(height || "1080", 10),
|
|
472
|
-
bitrate: void 0
|
|
473
|
-
};
|
|
474
|
-
if (!url) {
|
|
475
|
-
console.warn("[HlsAdPlayer] MediaFile ".concat(index, " has empty URL"));
|
|
476
|
-
return;
|
|
477
|
-
}
|
|
478
|
-
var bitrateAttr = mf.getAttribute("bitrate");
|
|
479
|
-
var bitrateValue = bitrateAttr ? parseInt(bitrateAttr, 10) : void 0;
|
|
480
|
-
mediaFile.bitrate = bitrateValue && bitrateValue > 0 ? bitrateValue : void 0;
|
|
481
|
-
if (isHlsMediaFile(mediaFile) || isProgressiveMediaFile(mediaFile)) {
|
|
482
|
-
mediaFiles.push(mediaFile);
|
|
483
|
-
console.log("[HlsAdPlayer] Added ".concat(isHlsMediaFile(mediaFile) ? "HLS" : "progressive", " MediaFile: ").concat(url));
|
|
484
|
-
} else {
|
|
485
|
-
console.log("[HlsAdPlayer] MediaFile ".concat(index, ' ignored (type="').concat(type, '" is not supported)'));
|
|
486
|
-
}
|
|
487
|
-
});
|
|
507
|
+
var mediaFiles = collectVideoMediaFiles(xmlDoc, true);
|
|
488
508
|
if (mediaFiles.length === 0) {
|
|
489
509
|
if (isNoAdAvailable) {
|
|
490
510
|
console.warn("[HlsAdPlayer] No ads available (VAST response indicates no ads)");
|
|
@@ -532,28 +552,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
532
552
|
var durationText = ((_adElement_querySelector3 = adElement.querySelector("Duration")) === null || _adElement_querySelector3 === void 0 ? void 0 : _adElement_querySelector3.textContent) || "00:00:30";
|
|
533
553
|
var durationParts = durationText.split(":");
|
|
534
554
|
var duration = parseInt(durationParts[0] || "0", 10) * 3600 + parseInt(durationParts[1] || "0", 10) * 60 + parseInt(durationParts[2] || "0", 10);
|
|
535
|
-
var
|
|
536
|
-
var mediaFiles = [];
|
|
537
|
-
mediaFileElements.forEach(function(mf) {
|
|
538
|
-
var _mf_textContent;
|
|
539
|
-
var type = mf.getAttribute("type") || "";
|
|
540
|
-
var url = ((_mf_textContent = mf.textContent) === null || _mf_textContent === void 0 ? void 0 : _mf_textContent.trim()) || "";
|
|
541
|
-
var width = mf.getAttribute("width") || "";
|
|
542
|
-
var height = mf.getAttribute("height") || "";
|
|
543
|
-
if (!url) return;
|
|
544
|
-
var bitrateAttr = mf.getAttribute("bitrate");
|
|
545
|
-
var bitrateValue = bitrateAttr ? parseInt(bitrateAttr, 10) : void 0;
|
|
546
|
-
var mediaFile = {
|
|
547
|
-
url: url,
|
|
548
|
-
type: type,
|
|
549
|
-
width: parseInt(width || "1920", 10),
|
|
550
|
-
height: parseInt(height || "1080", 10),
|
|
551
|
-
bitrate: bitrateValue && bitrateValue > 0 ? bitrateValue : void 0
|
|
552
|
-
};
|
|
553
|
-
if (isHlsMediaFile(mediaFile) || isProgressiveMediaFile(mediaFile)) {
|
|
554
|
-
mediaFiles.push(mediaFile);
|
|
555
|
-
}
|
|
556
|
-
});
|
|
555
|
+
var mediaFiles = collectVideoMediaFiles(adElement, false);
|
|
557
556
|
if (mediaFiles.length === 0) {
|
|
558
557
|
if (isNoAdAvailable) {
|
|
559
558
|
console.warn("[HlsAdPlayer] Pod <Ad> indicates no ad available");
|