stormcloud-video-player 0.3.59 → 0.3.60

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.
@@ -1747,6 +1747,16 @@ function createHlsAdPlayer(contentVideo, options) {
1747
1747
  });
1748
1748
  return bestMatch.file;
1749
1749
  }
1750
+ function isHlsMediaFile(mediaFile) {
1751
+ var type = mediaFile.type.toLowerCase();
1752
+ var url = mediaFile.url.toLowerCase();
1753
+ return type === "application/x-mpegurl" || type === "application/vnd.apple.mpegurl" || type.includes("mpegurl") || url.includes(".m3u8");
1754
+ }
1755
+ function isProgressiveMediaFile(mediaFile) {
1756
+ var type = mediaFile.type.toLowerCase();
1757
+ var url = mediaFile.url.toLowerCase();
1758
+ return type.startsWith("video/") || url.endsWith(".mp4") || url.includes(".mp4?");
1759
+ }
1750
1760
  function parseVastXml(xmlString) {
1751
1761
  try {
1752
1762
  var _xmlDoc_querySelector, _xmlDoc_querySelector1, _xmlDoc_querySelector_textContent, _xmlDoc_querySelector2;
@@ -1778,30 +1788,32 @@ function createHlsAdPlayer(contentVideo, options) {
1778
1788
  var width = mf.getAttribute("width") || "";
1779
1789
  var height = mf.getAttribute("height") || "";
1780
1790
  console.log("[HlsAdPlayer] MediaFile ".concat(index, ': type="').concat(type, '", url="').concat(url, '", width="').concat(width, '", height="').concat(height, '"'));
1781
- if (type === "application/x-mpegURL" || type.includes("m3u8")) {
1782
- if (!url) {
1783
- console.warn("[HlsAdPlayer] MediaFile ".concat(index, " has HLS type but empty URL"));
1784
- return;
1785
- }
1786
- var bitrateAttr = mf.getAttribute("bitrate");
1787
- var bitrateValue = bitrateAttr ? parseInt(bitrateAttr, 10) : void 0;
1788
- mediaFiles.push({
1789
- url: url,
1790
- type: type,
1791
- width: parseInt(width || "1920", 10),
1792
- height: parseInt(height || "1080", 10),
1793
- bitrate: bitrateValue && bitrateValue > 0 ? bitrateValue : void 0
1794
- });
1795
- console.log("[HlsAdPlayer] Added HLS MediaFile: ".concat(url));
1791
+ var mediaFile = {
1792
+ url: url,
1793
+ type: type,
1794
+ width: parseInt(width || "1920", 10),
1795
+ height: parseInt(height || "1080", 10),
1796
+ bitrate: void 0
1797
+ };
1798
+ if (!url) {
1799
+ console.warn("[HlsAdPlayer] MediaFile ".concat(index, " has empty URL"));
1800
+ return;
1801
+ }
1802
+ var bitrateAttr = mf.getAttribute("bitrate");
1803
+ var bitrateValue = bitrateAttr ? parseInt(bitrateAttr, 10) : void 0;
1804
+ mediaFile.bitrate = bitrateValue && bitrateValue > 0 ? bitrateValue : void 0;
1805
+ if (isHlsMediaFile(mediaFile) || isProgressiveMediaFile(mediaFile)) {
1806
+ mediaFiles.push(mediaFile);
1807
+ console.log("[HlsAdPlayer] Added ".concat(isHlsMediaFile(mediaFile) ? "HLS" : "progressive", " MediaFile: ").concat(url));
1796
1808
  } else {
1797
- console.log("[HlsAdPlayer] MediaFile ".concat(index, ' ignored (type="').concat(type, '" is not HLS)'));
1809
+ console.log("[HlsAdPlayer] MediaFile ".concat(index, ' ignored (type="').concat(type, '" is not supported)'));
1798
1810
  }
1799
1811
  });
1800
1812
  if (mediaFiles.length === 0) {
1801
1813
  if (isNoAdAvailable) {
1802
1814
  console.warn("[HlsAdPlayer] No ads available (VAST response indicates no ads)");
1803
1815
  } else {
1804
- console.warn("[HlsAdPlayer] No HLS media files found in VAST XML");
1816
+ console.warn("[HlsAdPlayer] No supported media files found in VAST XML");
1805
1817
  }
1806
1818
  return null;
1807
1819
  }
@@ -2098,7 +2110,7 @@ function createHlsAdPlayer(contentVideo, options) {
2098
2110
  },
2099
2111
  play: function play() {
2100
2112
  return _async_to_generator(function() {
2101
- var contentVolume, adVolume, mediaFile;
2113
+ var contentVolume, adVolume, mediaFile, isHlsAd;
2102
2114
  return _ts_generator(this, function(_state) {
2103
2115
  if (!currentAd) {
2104
2116
  console.warn("[HlsAdPlayer] Cannot play: No ad loaded (no ads available)");
@@ -2150,8 +2162,9 @@ function createHlsAdPlayer(contentVideo, options) {
2150
2162
  if (!mediaFile) {
2151
2163
  throw new Error("No media file available for ad");
2152
2164
  }
2153
- console.log("[HlsAdPlayer] Loading ad from: ".concat(mediaFile.url));
2154
- if (import_hls.default.isSupported()) {
2165
+ isHlsAd = isHlsMediaFile(mediaFile);
2166
+ console.log("[HlsAdPlayer] Loading ".concat(isHlsAd ? "HLS" : "progressive", " ad from: ").concat(mediaFile.url));
2167
+ if (isHlsAd && import_hls.default.isSupported()) {
2155
2168
  if (adHls) {
2156
2169
  adHls.destroy();
2157
2170
  }
@@ -2174,14 +2187,25 @@ function createHlsAdPlayer(contentVideo, options) {
2174
2187
  handleAdError();
2175
2188
  }
2176
2189
  });
2177
- } else if (adVideoElement.canPlayType("application/vnd.apple.mpegurl")) {
2190
+ } else if (isHlsAd && adVideoElement.canPlayType("application/vnd.apple.mpegurl")) {
2178
2191
  adVideoElement.src = mediaFile.url;
2179
2192
  adVideoElement.play().catch(function(error) {
2180
2193
  console.error("[HlsAdPlayer] Error starting ad playback:", error);
2181
2194
  handleAdError();
2182
2195
  });
2196
+ } else if (!isHlsAd && isProgressiveMediaFile(mediaFile)) {
2197
+ if (adHls) {
2198
+ adHls.destroy();
2199
+ adHls = void 0;
2200
+ }
2201
+ adVideoElement.src = mediaFile.url;
2202
+ adVideoElement.load();
2203
+ adVideoElement.play().catch(function(error) {
2204
+ console.error("[HlsAdPlayer] Error starting progressive ad playback:", error);
2205
+ handleAdError();
2206
+ });
2183
2207
  } else {
2184
- throw new Error("HLS not supported");
2208
+ throw new Error("Unsupported ad media file type: ".concat(mediaFile.type));
2185
2209
  }
2186
2210
  return [
2187
2211
  2,