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.
@@ -555,6 +555,56 @@ function createHlsAdPlayer(contentVideo, options) {
555
555
  var url = mediaFile.url.toLowerCase();
556
556
  return type.startsWith("video/") || url.endsWith(".mp4") || url.includes(".mp4?");
557
557
  }
558
+ function isAudioMediaFile(mediaFile) {
559
+ var type = mediaFile.type.toLowerCase();
560
+ var url = (mediaFile.url.toLowerCase().split("?")[0] || "").trim();
561
+ 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");
562
+ }
563
+ function collectVideoMediaFiles(scope, verbose) {
564
+ var mediaFileElements = scope.querySelectorAll("MediaFile");
565
+ var mediaFiles = [];
566
+ if (verbose) {
567
+ console.log("[HlsAdPlayer] Found ".concat(mediaFileElements.length, " MediaFile element(s) in VAST XML"));
568
+ }
569
+ mediaFileElements.forEach(function(mf, index) {
570
+ var _mf_textContent;
571
+ var type = mf.getAttribute("type") || "";
572
+ var url = ((_mf_textContent = mf.textContent) === null || _mf_textContent === void 0 ? void 0 : _mf_textContent.trim()) || "";
573
+ var width = mf.getAttribute("width") || "";
574
+ var height = mf.getAttribute("height") || "";
575
+ if (verbose) {
576
+ console.log("[HlsAdPlayer] MediaFile ".concat(index, ': type="').concat(type, '", url="').concat(url, '", width="').concat(width, '", height="').concat(height, '"'));
577
+ }
578
+ if (!url) {
579
+ if (verbose) {
580
+ console.warn("[HlsAdPlayer] MediaFile ".concat(index, " has empty URL"));
581
+ }
582
+ return;
583
+ }
584
+ var bitrateAttr = mf.getAttribute("bitrate");
585
+ var bitrateValue = bitrateAttr ? parseInt(bitrateAttr, 10) : void 0;
586
+ var mediaFile = {
587
+ url: url,
588
+ type: type,
589
+ width: parseInt(width || "1920", 10),
590
+ height: parseInt(height || "1080", 10),
591
+ bitrate: bitrateValue && bitrateValue > 0 ? bitrateValue : void 0
592
+ };
593
+ if (isAudioMediaFile(mediaFile)) {
594
+ console.warn("[HlsAdPlayer] MediaFile ".concat(index, ' skipped (audio-only, type="').concat(type, '") — audio ads are not played to avoid a black screen'));
595
+ return;
596
+ }
597
+ if (isHlsMediaFile(mediaFile) || isProgressiveMediaFile(mediaFile)) {
598
+ mediaFiles.push(mediaFile);
599
+ if (verbose) {
600
+ console.log("[HlsAdPlayer] Added ".concat(isHlsMediaFile(mediaFile) ? "HLS" : "progressive", " MediaFile: ").concat(url));
601
+ }
602
+ } else if (verbose) {
603
+ console.log("[HlsAdPlayer] MediaFile ".concat(index, ' ignored (type="').concat(type, '" is not supported)'));
604
+ }
605
+ });
606
+ return mediaFiles;
607
+ }
558
608
  function createEmptyTrackingUrls() {
559
609
  return {
560
610
  impression: [],
@@ -642,37 +692,7 @@ function createHlsAdPlayer(contentVideo, options) {
642
692
  var durationText = ((_xmlDoc_querySelector3 = xmlDoc.querySelector("Duration")) === null || _xmlDoc_querySelector3 === void 0 ? void 0 : _xmlDoc_querySelector3.textContent) || "00:00:30";
643
693
  var durationParts = durationText.split(":");
644
694
  var duration = parseInt(durationParts[0] || "0", 10) * 3600 + parseInt(durationParts[1] || "0", 10) * 60 + parseInt(durationParts[2] || "0", 10);
645
- var mediaFileElements = xmlDoc.querySelectorAll("MediaFile");
646
- var mediaFiles = [];
647
- console.log("[HlsAdPlayer] Found ".concat(mediaFileElements.length, " MediaFile element(s) in VAST XML"));
648
- mediaFileElements.forEach(function(mf, index) {
649
- var _mf_textContent;
650
- var type = mf.getAttribute("type") || "";
651
- var url = ((_mf_textContent = mf.textContent) === null || _mf_textContent === void 0 ? void 0 : _mf_textContent.trim()) || "";
652
- var width = mf.getAttribute("width") || "";
653
- var height = mf.getAttribute("height") || "";
654
- console.log("[HlsAdPlayer] MediaFile ".concat(index, ': type="').concat(type, '", url="').concat(url, '", width="').concat(width, '", height="').concat(height, '"'));
655
- var mediaFile = {
656
- url: url,
657
- type: type,
658
- width: parseInt(width || "1920", 10),
659
- height: parseInt(height || "1080", 10),
660
- bitrate: void 0
661
- };
662
- if (!url) {
663
- console.warn("[HlsAdPlayer] MediaFile ".concat(index, " has empty URL"));
664
- return;
665
- }
666
- var bitrateAttr = mf.getAttribute("bitrate");
667
- var bitrateValue = bitrateAttr ? parseInt(bitrateAttr, 10) : void 0;
668
- mediaFile.bitrate = bitrateValue && bitrateValue > 0 ? bitrateValue : void 0;
669
- if (isHlsMediaFile(mediaFile) || isProgressiveMediaFile(mediaFile)) {
670
- mediaFiles.push(mediaFile);
671
- console.log("[HlsAdPlayer] Added ".concat(isHlsMediaFile(mediaFile) ? "HLS" : "progressive", " MediaFile: ").concat(url));
672
- } else {
673
- console.log("[HlsAdPlayer] MediaFile ".concat(index, ' ignored (type="').concat(type, '" is not supported)'));
674
- }
675
- });
695
+ var mediaFiles = collectVideoMediaFiles(xmlDoc, true);
676
696
  if (mediaFiles.length === 0) {
677
697
  if (isNoAdAvailable) {
678
698
  console.warn("[HlsAdPlayer] No ads available (VAST response indicates no ads)");
@@ -720,28 +740,7 @@ function createHlsAdPlayer(contentVideo, options) {
720
740
  var durationText = ((_adElement_querySelector3 = adElement.querySelector("Duration")) === null || _adElement_querySelector3 === void 0 ? void 0 : _adElement_querySelector3.textContent) || "00:00:30";
721
741
  var durationParts = durationText.split(":");
722
742
  var duration = parseInt(durationParts[0] || "0", 10) * 3600 + parseInt(durationParts[1] || "0", 10) * 60 + parseInt(durationParts[2] || "0", 10);
723
- var mediaFileElements = adElement.querySelectorAll("MediaFile");
724
- var mediaFiles = [];
725
- mediaFileElements.forEach(function(mf) {
726
- var _mf_textContent;
727
- var type = mf.getAttribute("type") || "";
728
- var url = ((_mf_textContent = mf.textContent) === null || _mf_textContent === void 0 ? void 0 : _mf_textContent.trim()) || "";
729
- var width = mf.getAttribute("width") || "";
730
- var height = mf.getAttribute("height") || "";
731
- if (!url) return;
732
- var bitrateAttr = mf.getAttribute("bitrate");
733
- var bitrateValue = bitrateAttr ? parseInt(bitrateAttr, 10) : void 0;
734
- var mediaFile = {
735
- url: url,
736
- type: type,
737
- width: parseInt(width || "1920", 10),
738
- height: parseInt(height || "1080", 10),
739
- bitrate: bitrateValue && bitrateValue > 0 ? bitrateValue : void 0
740
- };
741
- if (isHlsMediaFile(mediaFile) || isProgressiveMediaFile(mediaFile)) {
742
- mediaFiles.push(mediaFile);
743
- }
744
- });
743
+ var mediaFiles = collectVideoMediaFiles(adElement, false);
745
744
  if (mediaFiles.length === 0) {
746
745
  if (isNoAdAvailable) {
747
746
  console.warn("[HlsAdPlayer] Pod <Ad> indicates no ad available");