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.
@@ -605,6 +605,56 @@ function createHlsAdPlayer(contentVideo, options) {
605
605
  var url = mediaFile.url.toLowerCase();
606
606
  return type.startsWith("video/") || url.endsWith(".mp4") || url.includes(".mp4?");
607
607
  }
608
+ function isAudioMediaFile(mediaFile) {
609
+ var type = mediaFile.type.toLowerCase();
610
+ var url = (mediaFile.url.toLowerCase().split("?")[0] || "").trim();
611
+ 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");
612
+ }
613
+ function collectVideoMediaFiles(scope, verbose) {
614
+ var mediaFileElements = scope.querySelectorAll("MediaFile");
615
+ var mediaFiles = [];
616
+ if (verbose) {
617
+ console.log("[HlsAdPlayer] Found ".concat(mediaFileElements.length, " MediaFile element(s) in VAST XML"));
618
+ }
619
+ mediaFileElements.forEach(function(mf, index) {
620
+ var _mf_textContent;
621
+ var type = mf.getAttribute("type") || "";
622
+ var url = ((_mf_textContent = mf.textContent) === null || _mf_textContent === void 0 ? void 0 : _mf_textContent.trim()) || "";
623
+ var width = mf.getAttribute("width") || "";
624
+ var height = mf.getAttribute("height") || "";
625
+ if (verbose) {
626
+ console.log("[HlsAdPlayer] MediaFile ".concat(index, ': type="').concat(type, '", url="').concat(url, '", width="').concat(width, '", height="').concat(height, '"'));
627
+ }
628
+ if (!url) {
629
+ if (verbose) {
630
+ console.warn("[HlsAdPlayer] MediaFile ".concat(index, " has empty URL"));
631
+ }
632
+ return;
633
+ }
634
+ var bitrateAttr = mf.getAttribute("bitrate");
635
+ var bitrateValue = bitrateAttr ? parseInt(bitrateAttr, 10) : void 0;
636
+ var mediaFile = {
637
+ url: url,
638
+ type: type,
639
+ width: parseInt(width || "1920", 10),
640
+ height: parseInt(height || "1080", 10),
641
+ bitrate: bitrateValue && bitrateValue > 0 ? bitrateValue : void 0
642
+ };
643
+ if (isAudioMediaFile(mediaFile)) {
644
+ console.warn("[HlsAdPlayer] MediaFile ".concat(index, ' skipped (audio-only, type="').concat(type, '") — audio ads are not played to avoid a black screen'));
645
+ return;
646
+ }
647
+ if (isHlsMediaFile(mediaFile) || isProgressiveMediaFile(mediaFile)) {
648
+ mediaFiles.push(mediaFile);
649
+ if (verbose) {
650
+ console.log("[HlsAdPlayer] Added ".concat(isHlsMediaFile(mediaFile) ? "HLS" : "progressive", " MediaFile: ").concat(url));
651
+ }
652
+ } else if (verbose) {
653
+ console.log("[HlsAdPlayer] MediaFile ".concat(index, ' ignored (type="').concat(type, '" is not supported)'));
654
+ }
655
+ });
656
+ return mediaFiles;
657
+ }
608
658
  function createEmptyTrackingUrls() {
609
659
  return {
610
660
  impression: [],
@@ -692,37 +742,7 @@ function createHlsAdPlayer(contentVideo, options) {
692
742
  var durationText = ((_xmlDoc_querySelector3 = xmlDoc.querySelector("Duration")) === null || _xmlDoc_querySelector3 === void 0 ? void 0 : _xmlDoc_querySelector3.textContent) || "00:00:30";
693
743
  var durationParts = durationText.split(":");
694
744
  var duration = parseInt(durationParts[0] || "0", 10) * 3600 + parseInt(durationParts[1] || "0", 10) * 60 + parseInt(durationParts[2] || "0", 10);
695
- var mediaFileElements = xmlDoc.querySelectorAll("MediaFile");
696
- var mediaFiles = [];
697
- console.log("[HlsAdPlayer] Found ".concat(mediaFileElements.length, " MediaFile element(s) in VAST XML"));
698
- mediaFileElements.forEach(function(mf, index) {
699
- var _mf_textContent;
700
- var type = mf.getAttribute("type") || "";
701
- var url = ((_mf_textContent = mf.textContent) === null || _mf_textContent === void 0 ? void 0 : _mf_textContent.trim()) || "";
702
- var width = mf.getAttribute("width") || "";
703
- var height = mf.getAttribute("height") || "";
704
- console.log("[HlsAdPlayer] MediaFile ".concat(index, ': type="').concat(type, '", url="').concat(url, '", width="').concat(width, '", height="').concat(height, '"'));
705
- var mediaFile = {
706
- url: url,
707
- type: type,
708
- width: parseInt(width || "1920", 10),
709
- height: parseInt(height || "1080", 10),
710
- bitrate: void 0
711
- };
712
- if (!url) {
713
- console.warn("[HlsAdPlayer] MediaFile ".concat(index, " has empty URL"));
714
- return;
715
- }
716
- var bitrateAttr = mf.getAttribute("bitrate");
717
- var bitrateValue = bitrateAttr ? parseInt(bitrateAttr, 10) : void 0;
718
- mediaFile.bitrate = bitrateValue && bitrateValue > 0 ? bitrateValue : void 0;
719
- if (isHlsMediaFile(mediaFile) || isProgressiveMediaFile(mediaFile)) {
720
- mediaFiles.push(mediaFile);
721
- console.log("[HlsAdPlayer] Added ".concat(isHlsMediaFile(mediaFile) ? "HLS" : "progressive", " MediaFile: ").concat(url));
722
- } else {
723
- console.log("[HlsAdPlayer] MediaFile ".concat(index, ' ignored (type="').concat(type, '" is not supported)'));
724
- }
725
- });
745
+ var mediaFiles = collectVideoMediaFiles(xmlDoc, true);
726
746
  if (mediaFiles.length === 0) {
727
747
  if (isNoAdAvailable) {
728
748
  console.warn("[HlsAdPlayer] No ads available (VAST response indicates no ads)");
@@ -770,28 +790,7 @@ function createHlsAdPlayer(contentVideo, options) {
770
790
  var durationText = ((_adElement_querySelector3 = adElement.querySelector("Duration")) === null || _adElement_querySelector3 === void 0 ? void 0 : _adElement_querySelector3.textContent) || "00:00:30";
771
791
  var durationParts = durationText.split(":");
772
792
  var duration = parseInt(durationParts[0] || "0", 10) * 3600 + parseInt(durationParts[1] || "0", 10) * 60 + parseInt(durationParts[2] || "0", 10);
773
- var mediaFileElements = adElement.querySelectorAll("MediaFile");
774
- var mediaFiles = [];
775
- mediaFileElements.forEach(function(mf) {
776
- var _mf_textContent;
777
- var type = mf.getAttribute("type") || "";
778
- var url = ((_mf_textContent = mf.textContent) === null || _mf_textContent === void 0 ? void 0 : _mf_textContent.trim()) || "";
779
- var width = mf.getAttribute("width") || "";
780
- var height = mf.getAttribute("height") || "";
781
- if (!url) return;
782
- var bitrateAttr = mf.getAttribute("bitrate");
783
- var bitrateValue = bitrateAttr ? parseInt(bitrateAttr, 10) : void 0;
784
- var mediaFile = {
785
- url: url,
786
- type: type,
787
- width: parseInt(width || "1920", 10),
788
- height: parseInt(height || "1080", 10),
789
- bitrate: bitrateValue && bitrateValue > 0 ? bitrateValue : void 0
790
- };
791
- if (isHlsMediaFile(mediaFile) || isProgressiveMediaFile(mediaFile)) {
792
- mediaFiles.push(mediaFile);
793
- }
794
- });
793
+ var mediaFiles = collectVideoMediaFiles(adElement, false);
795
794
  if (mediaFiles.length === 0) {
796
795
  if (isNoAdAvailable) {
797
796
  console.warn("[HlsAdPlayer] Pod <Ad> indicates no ad available");