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.
@@ -569,6 +569,56 @@ function createHlsAdPlayer(contentVideo, options) {
569
569
  var url = mediaFile.url.toLowerCase();
570
570
  return type.startsWith("video/") || url.endsWith(".mp4") || url.includes(".mp4?");
571
571
  }
572
+ function isAudioMediaFile(mediaFile) {
573
+ var type = mediaFile.type.toLowerCase();
574
+ var url = (mediaFile.url.toLowerCase().split("?")[0] || "").trim();
575
+ 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");
576
+ }
577
+ function collectVideoMediaFiles(scope, verbose) {
578
+ var mediaFileElements = scope.querySelectorAll("MediaFile");
579
+ var mediaFiles = [];
580
+ if (verbose) {
581
+ console.log("[HlsAdPlayer] Found ".concat(mediaFileElements.length, " MediaFile element(s) in VAST XML"));
582
+ }
583
+ mediaFileElements.forEach(function(mf, index) {
584
+ var _mf_textContent;
585
+ var type = mf.getAttribute("type") || "";
586
+ var url = ((_mf_textContent = mf.textContent) === null || _mf_textContent === void 0 ? void 0 : _mf_textContent.trim()) || "";
587
+ var width = mf.getAttribute("width") || "";
588
+ var height = mf.getAttribute("height") || "";
589
+ if (verbose) {
590
+ console.log("[HlsAdPlayer] MediaFile ".concat(index, ': type="').concat(type, '", url="').concat(url, '", width="').concat(width, '", height="').concat(height, '"'));
591
+ }
592
+ if (!url) {
593
+ if (verbose) {
594
+ console.warn("[HlsAdPlayer] MediaFile ".concat(index, " has empty URL"));
595
+ }
596
+ return;
597
+ }
598
+ var bitrateAttr = mf.getAttribute("bitrate");
599
+ var bitrateValue = bitrateAttr ? parseInt(bitrateAttr, 10) : void 0;
600
+ var mediaFile = {
601
+ url: url,
602
+ type: type,
603
+ width: parseInt(width || "1920", 10),
604
+ height: parseInt(height || "1080", 10),
605
+ bitrate: bitrateValue && bitrateValue > 0 ? bitrateValue : void 0
606
+ };
607
+ if (isAudioMediaFile(mediaFile)) {
608
+ console.warn("[HlsAdPlayer] MediaFile ".concat(index, ' skipped (audio-only, type="').concat(type, '") — audio ads are not played to avoid a black screen'));
609
+ return;
610
+ }
611
+ if (isHlsMediaFile(mediaFile) || isProgressiveMediaFile(mediaFile)) {
612
+ mediaFiles.push(mediaFile);
613
+ if (verbose) {
614
+ console.log("[HlsAdPlayer] Added ".concat(isHlsMediaFile(mediaFile) ? "HLS" : "progressive", " MediaFile: ").concat(url));
615
+ }
616
+ } else if (verbose) {
617
+ console.log("[HlsAdPlayer] MediaFile ".concat(index, ' ignored (type="').concat(type, '" is not supported)'));
618
+ }
619
+ });
620
+ return mediaFiles;
621
+ }
572
622
  function createEmptyTrackingUrls() {
573
623
  return {
574
624
  impression: [],
@@ -656,37 +706,7 @@ function createHlsAdPlayer(contentVideo, options) {
656
706
  var durationText = ((_xmlDoc_querySelector3 = xmlDoc.querySelector("Duration")) === null || _xmlDoc_querySelector3 === void 0 ? void 0 : _xmlDoc_querySelector3.textContent) || "00:00:30";
657
707
  var durationParts = durationText.split(":");
658
708
  var duration = parseInt(durationParts[0] || "0", 10) * 3600 + parseInt(durationParts[1] || "0", 10) * 60 + parseInt(durationParts[2] || "0", 10);
659
- var mediaFileElements = xmlDoc.querySelectorAll("MediaFile");
660
- var mediaFiles = [];
661
- console.log("[HlsAdPlayer] Found ".concat(mediaFileElements.length, " MediaFile element(s) in VAST XML"));
662
- mediaFileElements.forEach(function(mf, index) {
663
- var _mf_textContent;
664
- var type = mf.getAttribute("type") || "";
665
- var url = ((_mf_textContent = mf.textContent) === null || _mf_textContent === void 0 ? void 0 : _mf_textContent.trim()) || "";
666
- var width = mf.getAttribute("width") || "";
667
- var height = mf.getAttribute("height") || "";
668
- console.log("[HlsAdPlayer] MediaFile ".concat(index, ': type="').concat(type, '", url="').concat(url, '", width="').concat(width, '", height="').concat(height, '"'));
669
- var mediaFile = {
670
- url: url,
671
- type: type,
672
- width: parseInt(width || "1920", 10),
673
- height: parseInt(height || "1080", 10),
674
- bitrate: void 0
675
- };
676
- if (!url) {
677
- console.warn("[HlsAdPlayer] MediaFile ".concat(index, " has empty URL"));
678
- return;
679
- }
680
- var bitrateAttr = mf.getAttribute("bitrate");
681
- var bitrateValue = bitrateAttr ? parseInt(bitrateAttr, 10) : void 0;
682
- mediaFile.bitrate = bitrateValue && bitrateValue > 0 ? bitrateValue : void 0;
683
- if (isHlsMediaFile(mediaFile) || isProgressiveMediaFile(mediaFile)) {
684
- mediaFiles.push(mediaFile);
685
- console.log("[HlsAdPlayer] Added ".concat(isHlsMediaFile(mediaFile) ? "HLS" : "progressive", " MediaFile: ").concat(url));
686
- } else {
687
- console.log("[HlsAdPlayer] MediaFile ".concat(index, ' ignored (type="').concat(type, '" is not supported)'));
688
- }
689
- });
709
+ var mediaFiles = collectVideoMediaFiles(xmlDoc, true);
690
710
  if (mediaFiles.length === 0) {
691
711
  if (isNoAdAvailable) {
692
712
  console.warn("[HlsAdPlayer] No ads available (VAST response indicates no ads)");
@@ -734,28 +754,7 @@ function createHlsAdPlayer(contentVideo, options) {
734
754
  var durationText = ((_adElement_querySelector3 = adElement.querySelector("Duration")) === null || _adElement_querySelector3 === void 0 ? void 0 : _adElement_querySelector3.textContent) || "00:00:30";
735
755
  var durationParts = durationText.split(":");
736
756
  var duration = parseInt(durationParts[0] || "0", 10) * 3600 + parseInt(durationParts[1] || "0", 10) * 60 + parseInt(durationParts[2] || "0", 10);
737
- var mediaFileElements = adElement.querySelectorAll("MediaFile");
738
- var mediaFiles = [];
739
- mediaFileElements.forEach(function(mf) {
740
- var _mf_textContent;
741
- var type = mf.getAttribute("type") || "";
742
- var url = ((_mf_textContent = mf.textContent) === null || _mf_textContent === void 0 ? void 0 : _mf_textContent.trim()) || "";
743
- var width = mf.getAttribute("width") || "";
744
- var height = mf.getAttribute("height") || "";
745
- if (!url) return;
746
- var bitrateAttr = mf.getAttribute("bitrate");
747
- var bitrateValue = bitrateAttr ? parseInt(bitrateAttr, 10) : void 0;
748
- var mediaFile = {
749
- url: url,
750
- type: type,
751
- width: parseInt(width || "1920", 10),
752
- height: parseInt(height || "1080", 10),
753
- bitrate: bitrateValue && bitrateValue > 0 ? bitrateValue : void 0
754
- };
755
- if (isHlsMediaFile(mediaFile) || isProgressiveMediaFile(mediaFile)) {
756
- mediaFiles.push(mediaFile);
757
- }
758
- });
757
+ var mediaFiles = collectVideoMediaFiles(adElement, false);
759
758
  if (mediaFiles.length === 0) {
760
759
  if (isNoAdAvailable) {
761
760
  console.warn("[HlsAdPlayer] Pod <Ad> indicates no ad available");