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.
@@ -518,6 +518,56 @@ function createHlsAdPlayer(contentVideo, options) {
518
518
  var url = mediaFile.url.toLowerCase();
519
519
  return type.startsWith("video/") || url.endsWith(".mp4") || url.includes(".mp4?");
520
520
  }
521
+ function isAudioMediaFile(mediaFile) {
522
+ var type = mediaFile.type.toLowerCase();
523
+ var url = (mediaFile.url.toLowerCase().split("?")[0] || "").trim();
524
+ 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");
525
+ }
526
+ function collectVideoMediaFiles(scope, verbose) {
527
+ var mediaFileElements = scope.querySelectorAll("MediaFile");
528
+ var mediaFiles = [];
529
+ if (verbose) {
530
+ console.log("[HlsAdPlayer] Found ".concat(mediaFileElements.length, " MediaFile element(s) in VAST XML"));
531
+ }
532
+ mediaFileElements.forEach(function(mf, index) {
533
+ var _mf_textContent;
534
+ var type = mf.getAttribute("type") || "";
535
+ var url = ((_mf_textContent = mf.textContent) === null || _mf_textContent === void 0 ? void 0 : _mf_textContent.trim()) || "";
536
+ var width = mf.getAttribute("width") || "";
537
+ var height = mf.getAttribute("height") || "";
538
+ if (verbose) {
539
+ console.log("[HlsAdPlayer] MediaFile ".concat(index, ': type="').concat(type, '", url="').concat(url, '", width="').concat(width, '", height="').concat(height, '"'));
540
+ }
541
+ if (!url) {
542
+ if (verbose) {
543
+ console.warn("[HlsAdPlayer] MediaFile ".concat(index, " has empty URL"));
544
+ }
545
+ return;
546
+ }
547
+ var bitrateAttr = mf.getAttribute("bitrate");
548
+ var bitrateValue = bitrateAttr ? parseInt(bitrateAttr, 10) : void 0;
549
+ var mediaFile = {
550
+ url: url,
551
+ type: type,
552
+ width: parseInt(width || "1920", 10),
553
+ height: parseInt(height || "1080", 10),
554
+ bitrate: bitrateValue && bitrateValue > 0 ? bitrateValue : void 0
555
+ };
556
+ if (isAudioMediaFile(mediaFile)) {
557
+ console.warn("[HlsAdPlayer] MediaFile ".concat(index, ' skipped (audio-only, type="').concat(type, '") — audio ads are not played to avoid a black screen'));
558
+ return;
559
+ }
560
+ if (isHlsMediaFile(mediaFile) || isProgressiveMediaFile(mediaFile)) {
561
+ mediaFiles.push(mediaFile);
562
+ if (verbose) {
563
+ console.log("[HlsAdPlayer] Added ".concat(isHlsMediaFile(mediaFile) ? "HLS" : "progressive", " MediaFile: ").concat(url));
564
+ }
565
+ } else if (verbose) {
566
+ console.log("[HlsAdPlayer] MediaFile ".concat(index, ' ignored (type="').concat(type, '" is not supported)'));
567
+ }
568
+ });
569
+ return mediaFiles;
570
+ }
521
571
  function createEmptyTrackingUrls() {
522
572
  return {
523
573
  impression: [],
@@ -605,37 +655,7 @@ function createHlsAdPlayer(contentVideo, options) {
605
655
  var durationText = ((_xmlDoc_querySelector3 = xmlDoc.querySelector("Duration")) === null || _xmlDoc_querySelector3 === void 0 ? void 0 : _xmlDoc_querySelector3.textContent) || "00:00:30";
606
656
  var durationParts = durationText.split(":");
607
657
  var duration = parseInt(durationParts[0] || "0", 10) * 3600 + parseInt(durationParts[1] || "0", 10) * 60 + parseInt(durationParts[2] || "0", 10);
608
- var mediaFileElements = xmlDoc.querySelectorAll("MediaFile");
609
- var mediaFiles = [];
610
- console.log("[HlsAdPlayer] Found ".concat(mediaFileElements.length, " MediaFile element(s) in VAST XML"));
611
- mediaFileElements.forEach(function(mf, index) {
612
- var _mf_textContent;
613
- var type = mf.getAttribute("type") || "";
614
- var url = ((_mf_textContent = mf.textContent) === null || _mf_textContent === void 0 ? void 0 : _mf_textContent.trim()) || "";
615
- var width = mf.getAttribute("width") || "";
616
- var height = mf.getAttribute("height") || "";
617
- console.log("[HlsAdPlayer] MediaFile ".concat(index, ': type="').concat(type, '", url="').concat(url, '", width="').concat(width, '", height="').concat(height, '"'));
618
- var mediaFile = {
619
- url: url,
620
- type: type,
621
- width: parseInt(width || "1920", 10),
622
- height: parseInt(height || "1080", 10),
623
- bitrate: void 0
624
- };
625
- if (!url) {
626
- console.warn("[HlsAdPlayer] MediaFile ".concat(index, " has empty URL"));
627
- return;
628
- }
629
- var bitrateAttr = mf.getAttribute("bitrate");
630
- var bitrateValue = bitrateAttr ? parseInt(bitrateAttr, 10) : void 0;
631
- mediaFile.bitrate = bitrateValue && bitrateValue > 0 ? bitrateValue : void 0;
632
- if (isHlsMediaFile(mediaFile) || isProgressiveMediaFile(mediaFile)) {
633
- mediaFiles.push(mediaFile);
634
- console.log("[HlsAdPlayer] Added ".concat(isHlsMediaFile(mediaFile) ? "HLS" : "progressive", " MediaFile: ").concat(url));
635
- } else {
636
- console.log("[HlsAdPlayer] MediaFile ".concat(index, ' ignored (type="').concat(type, '" is not supported)'));
637
- }
638
- });
658
+ var mediaFiles = collectVideoMediaFiles(xmlDoc, true);
639
659
  if (mediaFiles.length === 0) {
640
660
  if (isNoAdAvailable) {
641
661
  console.warn("[HlsAdPlayer] No ads available (VAST response indicates no ads)");
@@ -683,28 +703,7 @@ function createHlsAdPlayer(contentVideo, options) {
683
703
  var durationText = ((_adElement_querySelector3 = adElement.querySelector("Duration")) === null || _adElement_querySelector3 === void 0 ? void 0 : _adElement_querySelector3.textContent) || "00:00:30";
684
704
  var durationParts = durationText.split(":");
685
705
  var duration = parseInt(durationParts[0] || "0", 10) * 3600 + parseInt(durationParts[1] || "0", 10) * 60 + parseInt(durationParts[2] || "0", 10);
686
- var mediaFileElements = adElement.querySelectorAll("MediaFile");
687
- var mediaFiles = [];
688
- mediaFileElements.forEach(function(mf) {
689
- var _mf_textContent;
690
- var type = mf.getAttribute("type") || "";
691
- var url = ((_mf_textContent = mf.textContent) === null || _mf_textContent === void 0 ? void 0 : _mf_textContent.trim()) || "";
692
- var width = mf.getAttribute("width") || "";
693
- var height = mf.getAttribute("height") || "";
694
- if (!url) return;
695
- var bitrateAttr = mf.getAttribute("bitrate");
696
- var bitrateValue = bitrateAttr ? parseInt(bitrateAttr, 10) : void 0;
697
- var mediaFile = {
698
- url: url,
699
- type: type,
700
- width: parseInt(width || "1920", 10),
701
- height: parseInt(height || "1080", 10),
702
- bitrate: bitrateValue && bitrateValue > 0 ? bitrateValue : void 0
703
- };
704
- if (isHlsMediaFile(mediaFile) || isProgressiveMediaFile(mediaFile)) {
705
- mediaFiles.push(mediaFile);
706
- }
707
- });
706
+ var mediaFiles = collectVideoMediaFiles(adElement, false);
708
707
  if (mediaFiles.length === 0) {
709
708
  if (isNoAdAvailable) {
710
709
  console.warn("[HlsAdPlayer] Pod <Ad> indicates no ad available");