stormcloud-video-player 0.7.6 → 0.7.8

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.
@@ -146,6 +146,7 @@ declare class StormcloudVideoPlayer {
146
146
  width: number;
147
147
  height: number;
148
148
  } | null;
149
+ getCurrentHlsSegmentDurationMs(): number | null;
149
150
  get videoElement(): HTMLVideoElement;
150
151
  resize(): void;
151
152
  destroy(): void;
@@ -789,28 +789,9 @@ function createAdStormPlayer(contentVideo, options) {
789
789
  adVideoElement.removeAttribute("src");
790
790
  adVideoElement.load();
791
791
  }
792
- function buildVastUrl(durationSeconds, metadata) {
793
- var baseUrl = "https://adstorm.co/api-adstorm-dev/adstorm/vast/".concat(licenseKey, "/pod");
794
- var defaultMetadata = {
795
- video: {
796
- codec: "h264",
797
- width: contentVideo.videoWidth || 1280,
798
- height: contentVideo.videoHeight || 720,
799
- fps: 29.97,
800
- bitrate: 5e3,
801
- profile: "high",
802
- pix_fmt: "yuv420p",
803
- has_b_frames: 0
804
- },
805
- audio: {
806
- codec: "aac",
807
- sample_rate: 48e3,
808
- bitrate: 128
809
- }
810
- };
811
- var finalMetadata = metadata || defaultMetadata;
812
- var metadataStr = encodeURIComponent(JSON.stringify(finalMetadata));
813
- return "".concat(baseUrl, "?duration=").concat(Math.ceil(durationSeconds), "&metadata=").concat(metadataStr);
792
+ function buildVastUrl(durationSeconds) {
793
+ var baseUrl = "https://adstorm.co/api-adstorm-dev/adstorm/nab/vast/pod";
794
+ return "".concat(baseUrl, "?duration=").concat(Math.ceil(durationSeconds));
814
795
  }
815
796
  function parseVastXml(xmlString) {
816
797
  var ads = [];
@@ -5928,6 +5909,50 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5928
5909
  return min;
5929
5910
  }
5930
5911
  },
5912
+ {
5913
+ key: "getCurrentHlsSegmentDurationMs",
5914
+ value: function getCurrentHlsSegmentDurationMs() {
5915
+ var fallbackMs = 4e3;
5916
+ if (this.nativeHlsMode) {
5917
+ return fallbackMs;
5918
+ }
5919
+ var hls = this.hls;
5920
+ if (!hls) return null;
5921
+ var levelCandidates = [
5922
+ hls.currentLevel,
5923
+ hls.nextLoadLevel,
5924
+ hls.loadLevel
5925
+ ];
5926
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
5927
+ try {
5928
+ for(var _iterator = levelCandidates[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
5929
+ var levelIndex = _step.value;
5930
+ var _hls_levels_levelIndex, _hls_levels;
5931
+ if (typeof levelIndex !== "number" || levelIndex < 0) continue;
5932
+ var details = (_hls_levels = hls.levels) === null || _hls_levels === void 0 ? void 0 : (_hls_levels_levelIndex = _hls_levels[levelIndex]) === null || _hls_levels_levelIndex === void 0 ? void 0 : _hls_levels_levelIndex.details;
5933
+ if (!details) continue;
5934
+ var targetDurationSec = typeof details.partTarget === "number" && details.partTarget > 0 ? details.partTarget : typeof details.targetduration === "number" && details.targetduration > 0 ? details.targetduration : void 0;
5935
+ if (targetDurationSec !== void 0) {
5936
+ return Math.max(800, Math.floor(targetDurationSec * 1e3));
5937
+ }
5938
+ }
5939
+ } catch (err) {
5940
+ _didIteratorError = true;
5941
+ _iteratorError = err;
5942
+ } finally{
5943
+ try {
5944
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
5945
+ _iterator.return();
5946
+ }
5947
+ } finally{
5948
+ if (_didIteratorError) {
5949
+ throw _iteratorError;
5950
+ }
5951
+ }
5952
+ }
5953
+ return fallbackMs;
5954
+ }
5955
+ },
5931
5956
  {
5932
5957
  key: "videoElement",
5933
5958
  get: function get() {