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