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.
- package/dist/stormcloud-vp.min.js +1 -1
- package/lib/index.cjs +52 -53
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +52 -53
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +52 -53
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.cjs +52 -53
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/index.cjs +52 -53
- package/lib/players/index.cjs.map +1 -1
- package/lib/sdk/hlsAdPlayer.cjs +52 -53
- package/lib/sdk/hlsAdPlayer.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +52 -53
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/package.json +1 -1
package/lib/index.cjs
CHANGED
|
@@ -759,6 +759,56 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
759
759
|
var url = mediaFile.url.toLowerCase();
|
|
760
760
|
return type.startsWith("video/") || url.endsWith(".mp4") || url.includes(".mp4?");
|
|
761
761
|
}
|
|
762
|
+
function isAudioMediaFile(mediaFile) {
|
|
763
|
+
var type = mediaFile.type.toLowerCase();
|
|
764
|
+
var url = (mediaFile.url.toLowerCase().split("?")[0] || "").trim();
|
|
765
|
+
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");
|
|
766
|
+
}
|
|
767
|
+
function collectVideoMediaFiles(scope, verbose) {
|
|
768
|
+
var mediaFileElements = scope.querySelectorAll("MediaFile");
|
|
769
|
+
var mediaFiles = [];
|
|
770
|
+
if (verbose) {
|
|
771
|
+
console.log("[HlsAdPlayer] Found ".concat(mediaFileElements.length, " MediaFile element(s) in VAST XML"));
|
|
772
|
+
}
|
|
773
|
+
mediaFileElements.forEach(function(mf, index) {
|
|
774
|
+
var _mf_textContent;
|
|
775
|
+
var type = mf.getAttribute("type") || "";
|
|
776
|
+
var url = ((_mf_textContent = mf.textContent) === null || _mf_textContent === void 0 ? void 0 : _mf_textContent.trim()) || "";
|
|
777
|
+
var width = mf.getAttribute("width") || "";
|
|
778
|
+
var height = mf.getAttribute("height") || "";
|
|
779
|
+
if (verbose) {
|
|
780
|
+
console.log("[HlsAdPlayer] MediaFile ".concat(index, ': type="').concat(type, '", url="').concat(url, '", width="').concat(width, '", height="').concat(height, '"'));
|
|
781
|
+
}
|
|
782
|
+
if (!url) {
|
|
783
|
+
if (verbose) {
|
|
784
|
+
console.warn("[HlsAdPlayer] MediaFile ".concat(index, " has empty URL"));
|
|
785
|
+
}
|
|
786
|
+
return;
|
|
787
|
+
}
|
|
788
|
+
var bitrateAttr = mf.getAttribute("bitrate");
|
|
789
|
+
var bitrateValue = bitrateAttr ? parseInt(bitrateAttr, 10) : void 0;
|
|
790
|
+
var mediaFile = {
|
|
791
|
+
url: url,
|
|
792
|
+
type: type,
|
|
793
|
+
width: parseInt(width || "1920", 10),
|
|
794
|
+
height: parseInt(height || "1080", 10),
|
|
795
|
+
bitrate: bitrateValue && bitrateValue > 0 ? bitrateValue : void 0
|
|
796
|
+
};
|
|
797
|
+
if (isAudioMediaFile(mediaFile)) {
|
|
798
|
+
console.warn("[HlsAdPlayer] MediaFile ".concat(index, ' skipped (audio-only, type="').concat(type, '") — audio ads are not played to avoid a black screen'));
|
|
799
|
+
return;
|
|
800
|
+
}
|
|
801
|
+
if (isHlsMediaFile(mediaFile) || isProgressiveMediaFile(mediaFile)) {
|
|
802
|
+
mediaFiles.push(mediaFile);
|
|
803
|
+
if (verbose) {
|
|
804
|
+
console.log("[HlsAdPlayer] Added ".concat(isHlsMediaFile(mediaFile) ? "HLS" : "progressive", " MediaFile: ").concat(url));
|
|
805
|
+
}
|
|
806
|
+
} else if (verbose) {
|
|
807
|
+
console.log("[HlsAdPlayer] MediaFile ".concat(index, ' ignored (type="').concat(type, '" is not supported)'));
|
|
808
|
+
}
|
|
809
|
+
});
|
|
810
|
+
return mediaFiles;
|
|
811
|
+
}
|
|
762
812
|
function createEmptyTrackingUrls() {
|
|
763
813
|
return {
|
|
764
814
|
impression: [],
|
|
@@ -846,37 +896,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
846
896
|
var durationText = ((_xmlDoc_querySelector3 = xmlDoc.querySelector("Duration")) === null || _xmlDoc_querySelector3 === void 0 ? void 0 : _xmlDoc_querySelector3.textContent) || "00:00:30";
|
|
847
897
|
var durationParts = durationText.split(":");
|
|
848
898
|
var duration = parseInt(durationParts[0] || "0", 10) * 3600 + parseInt(durationParts[1] || "0", 10) * 60 + parseInt(durationParts[2] || "0", 10);
|
|
849
|
-
var
|
|
850
|
-
var mediaFiles = [];
|
|
851
|
-
console.log("[HlsAdPlayer] Found ".concat(mediaFileElements.length, " MediaFile element(s) in VAST XML"));
|
|
852
|
-
mediaFileElements.forEach(function(mf, index) {
|
|
853
|
-
var _mf_textContent;
|
|
854
|
-
var type = mf.getAttribute("type") || "";
|
|
855
|
-
var url = ((_mf_textContent = mf.textContent) === null || _mf_textContent === void 0 ? void 0 : _mf_textContent.trim()) || "";
|
|
856
|
-
var width = mf.getAttribute("width") || "";
|
|
857
|
-
var height = mf.getAttribute("height") || "";
|
|
858
|
-
console.log("[HlsAdPlayer] MediaFile ".concat(index, ': type="').concat(type, '", url="').concat(url, '", width="').concat(width, '", height="').concat(height, '"'));
|
|
859
|
-
var mediaFile = {
|
|
860
|
-
url: url,
|
|
861
|
-
type: type,
|
|
862
|
-
width: parseInt(width || "1920", 10),
|
|
863
|
-
height: parseInt(height || "1080", 10),
|
|
864
|
-
bitrate: void 0
|
|
865
|
-
};
|
|
866
|
-
if (!url) {
|
|
867
|
-
console.warn("[HlsAdPlayer] MediaFile ".concat(index, " has empty URL"));
|
|
868
|
-
return;
|
|
869
|
-
}
|
|
870
|
-
var bitrateAttr = mf.getAttribute("bitrate");
|
|
871
|
-
var bitrateValue = bitrateAttr ? parseInt(bitrateAttr, 10) : void 0;
|
|
872
|
-
mediaFile.bitrate = bitrateValue && bitrateValue > 0 ? bitrateValue : void 0;
|
|
873
|
-
if (isHlsMediaFile(mediaFile) || isProgressiveMediaFile(mediaFile)) {
|
|
874
|
-
mediaFiles.push(mediaFile);
|
|
875
|
-
console.log("[HlsAdPlayer] Added ".concat(isHlsMediaFile(mediaFile) ? "HLS" : "progressive", " MediaFile: ").concat(url));
|
|
876
|
-
} else {
|
|
877
|
-
console.log("[HlsAdPlayer] MediaFile ".concat(index, ' ignored (type="').concat(type, '" is not supported)'));
|
|
878
|
-
}
|
|
879
|
-
});
|
|
899
|
+
var mediaFiles = collectVideoMediaFiles(xmlDoc, true);
|
|
880
900
|
if (mediaFiles.length === 0) {
|
|
881
901
|
if (isNoAdAvailable) {
|
|
882
902
|
console.warn("[HlsAdPlayer] No ads available (VAST response indicates no ads)");
|
|
@@ -924,28 +944,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
924
944
|
var durationText = ((_adElement_querySelector3 = adElement.querySelector("Duration")) === null || _adElement_querySelector3 === void 0 ? void 0 : _adElement_querySelector3.textContent) || "00:00:30";
|
|
925
945
|
var durationParts = durationText.split(":");
|
|
926
946
|
var duration = parseInt(durationParts[0] || "0", 10) * 3600 + parseInt(durationParts[1] || "0", 10) * 60 + parseInt(durationParts[2] || "0", 10);
|
|
927
|
-
var
|
|
928
|
-
var mediaFiles = [];
|
|
929
|
-
mediaFileElements.forEach(function(mf) {
|
|
930
|
-
var _mf_textContent;
|
|
931
|
-
var type = mf.getAttribute("type") || "";
|
|
932
|
-
var url = ((_mf_textContent = mf.textContent) === null || _mf_textContent === void 0 ? void 0 : _mf_textContent.trim()) || "";
|
|
933
|
-
var width = mf.getAttribute("width") || "";
|
|
934
|
-
var height = mf.getAttribute("height") || "";
|
|
935
|
-
if (!url) return;
|
|
936
|
-
var bitrateAttr = mf.getAttribute("bitrate");
|
|
937
|
-
var bitrateValue = bitrateAttr ? parseInt(bitrateAttr, 10) : void 0;
|
|
938
|
-
var mediaFile = {
|
|
939
|
-
url: url,
|
|
940
|
-
type: type,
|
|
941
|
-
width: parseInt(width || "1920", 10),
|
|
942
|
-
height: parseInt(height || "1080", 10),
|
|
943
|
-
bitrate: bitrateValue && bitrateValue > 0 ? bitrateValue : void 0
|
|
944
|
-
};
|
|
945
|
-
if (isHlsMediaFile(mediaFile) || isProgressiveMediaFile(mediaFile)) {
|
|
946
|
-
mediaFiles.push(mediaFile);
|
|
947
|
-
}
|
|
948
|
-
});
|
|
947
|
+
var mediaFiles = collectVideoMediaFiles(adElement, false);
|
|
949
948
|
if (mediaFiles.length === 0) {
|
|
950
949
|
if (isNoAdAvailable) {
|
|
951
950
|
console.warn("[HlsAdPlayer] Pod <Ad> indicates no ad available");
|