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.
- package/dist/stormcloud-vp.min.js +1 -1
- package/lib/index.cjs +46 -22
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +46 -22
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +46 -22
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.cjs +46 -22
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/index.cjs +46 -22
- package/lib/players/index.cjs.map +1 -1
- package/lib/sdk/hlsAdPlayer.cjs +46 -22
- package/lib/sdk/hlsAdPlayer.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +46 -22
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/package.json +1 -1
|
@@ -1761,6 +1761,16 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1761
1761
|
});
|
|
1762
1762
|
return bestMatch.file;
|
|
1763
1763
|
}
|
|
1764
|
+
function isHlsMediaFile(mediaFile) {
|
|
1765
|
+
var type = mediaFile.type.toLowerCase();
|
|
1766
|
+
var url = mediaFile.url.toLowerCase();
|
|
1767
|
+
return type === "application/x-mpegurl" || type === "application/vnd.apple.mpegurl" || type.includes("mpegurl") || url.includes(".m3u8");
|
|
1768
|
+
}
|
|
1769
|
+
function isProgressiveMediaFile(mediaFile) {
|
|
1770
|
+
var type = mediaFile.type.toLowerCase();
|
|
1771
|
+
var url = mediaFile.url.toLowerCase();
|
|
1772
|
+
return type.startsWith("video/") || url.endsWith(".mp4") || url.includes(".mp4?");
|
|
1773
|
+
}
|
|
1764
1774
|
function parseVastXml(xmlString) {
|
|
1765
1775
|
try {
|
|
1766
1776
|
var _xmlDoc_querySelector, _xmlDoc_querySelector1, _xmlDoc_querySelector_textContent, _xmlDoc_querySelector2;
|
|
@@ -1792,30 +1802,32 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1792
1802
|
var width = mf.getAttribute("width") || "";
|
|
1793
1803
|
var height = mf.getAttribute("height") || "";
|
|
1794
1804
|
console.log("[HlsAdPlayer] MediaFile ".concat(index, ': type="').concat(type, '", url="').concat(url, '", width="').concat(width, '", height="').concat(height, '"'));
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1805
|
+
var mediaFile = {
|
|
1806
|
+
url: url,
|
|
1807
|
+
type: type,
|
|
1808
|
+
width: parseInt(width || "1920", 10),
|
|
1809
|
+
height: parseInt(height || "1080", 10),
|
|
1810
|
+
bitrate: void 0
|
|
1811
|
+
};
|
|
1812
|
+
if (!url) {
|
|
1813
|
+
console.warn("[HlsAdPlayer] MediaFile ".concat(index, " has empty URL"));
|
|
1814
|
+
return;
|
|
1815
|
+
}
|
|
1816
|
+
var bitrateAttr = mf.getAttribute("bitrate");
|
|
1817
|
+
var bitrateValue = bitrateAttr ? parseInt(bitrateAttr, 10) : void 0;
|
|
1818
|
+
mediaFile.bitrate = bitrateValue && bitrateValue > 0 ? bitrateValue : void 0;
|
|
1819
|
+
if (isHlsMediaFile(mediaFile) || isProgressiveMediaFile(mediaFile)) {
|
|
1820
|
+
mediaFiles.push(mediaFile);
|
|
1821
|
+
console.log("[HlsAdPlayer] Added ".concat(isHlsMediaFile(mediaFile) ? "HLS" : "progressive", " MediaFile: ").concat(url));
|
|
1810
1822
|
} else {
|
|
1811
|
-
console.log("[HlsAdPlayer] MediaFile ".concat(index, ' ignored (type="').concat(type, '" is not
|
|
1823
|
+
console.log("[HlsAdPlayer] MediaFile ".concat(index, ' ignored (type="').concat(type, '" is not supported)'));
|
|
1812
1824
|
}
|
|
1813
1825
|
});
|
|
1814
1826
|
if (mediaFiles.length === 0) {
|
|
1815
1827
|
if (isNoAdAvailable) {
|
|
1816
1828
|
console.warn("[HlsAdPlayer] No ads available (VAST response indicates no ads)");
|
|
1817
1829
|
} else {
|
|
1818
|
-
console.warn("[HlsAdPlayer] No
|
|
1830
|
+
console.warn("[HlsAdPlayer] No supported media files found in VAST XML");
|
|
1819
1831
|
}
|
|
1820
1832
|
return null;
|
|
1821
1833
|
}
|
|
@@ -2112,7 +2124,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2112
2124
|
},
|
|
2113
2125
|
play: function play() {
|
|
2114
2126
|
return _async_to_generator(function() {
|
|
2115
|
-
var contentVolume, adVolume, mediaFile;
|
|
2127
|
+
var contentVolume, adVolume, mediaFile, isHlsAd;
|
|
2116
2128
|
return _ts_generator(this, function(_state) {
|
|
2117
2129
|
if (!currentAd) {
|
|
2118
2130
|
console.warn("[HlsAdPlayer] Cannot play: No ad loaded (no ads available)");
|
|
@@ -2164,8 +2176,9 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2164
2176
|
if (!mediaFile) {
|
|
2165
2177
|
throw new Error("No media file available for ad");
|
|
2166
2178
|
}
|
|
2167
|
-
|
|
2168
|
-
|
|
2179
|
+
isHlsAd = isHlsMediaFile(mediaFile);
|
|
2180
|
+
console.log("[HlsAdPlayer] Loading ".concat(isHlsAd ? "HLS" : "progressive", " ad from: ").concat(mediaFile.url));
|
|
2181
|
+
if (isHlsAd && import_hls.default.isSupported()) {
|
|
2169
2182
|
if (adHls) {
|
|
2170
2183
|
adHls.destroy();
|
|
2171
2184
|
}
|
|
@@ -2188,14 +2201,25 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2188
2201
|
handleAdError();
|
|
2189
2202
|
}
|
|
2190
2203
|
});
|
|
2191
|
-
} else if (adVideoElement.canPlayType("application/vnd.apple.mpegurl")) {
|
|
2204
|
+
} else if (isHlsAd && adVideoElement.canPlayType("application/vnd.apple.mpegurl")) {
|
|
2192
2205
|
adVideoElement.src = mediaFile.url;
|
|
2193
2206
|
adVideoElement.play().catch(function(error) {
|
|
2194
2207
|
console.error("[HlsAdPlayer] Error starting ad playback:", error);
|
|
2195
2208
|
handleAdError();
|
|
2196
2209
|
});
|
|
2210
|
+
} else if (!isHlsAd && isProgressiveMediaFile(mediaFile)) {
|
|
2211
|
+
if (adHls) {
|
|
2212
|
+
adHls.destroy();
|
|
2213
|
+
adHls = void 0;
|
|
2214
|
+
}
|
|
2215
|
+
adVideoElement.src = mediaFile.url;
|
|
2216
|
+
adVideoElement.load();
|
|
2217
|
+
adVideoElement.play().catch(function(error) {
|
|
2218
|
+
console.error("[HlsAdPlayer] Error starting progressive ad playback:", error);
|
|
2219
|
+
handleAdError();
|
|
2220
|
+
});
|
|
2197
2221
|
} else {
|
|
2198
|
-
throw new Error("
|
|
2222
|
+
throw new Error("Unsupported ad media file type: ".concat(mediaFile.type));
|
|
2199
2223
|
}
|
|
2200
2224
|
return [
|
|
2201
2225
|
2,
|