@volcengine/veplayer 2.1.0 → 2.2.0-rc.0

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.
@@ -40,6 +40,41 @@ async function isRTMSupportCodec(codec = RTMCodec.H264) {
40
40
  return Rtm.isSupportedH264();
41
41
  return false;
42
42
  }
43
+ const appendSearchParams = (url, searchParams) => {
44
+ var _a, _b;
45
+ const urlObject = getUrlObject(url);
46
+ if (!url || !urlObject) {
47
+ return url ?? "";
48
+ }
49
+ const withoutProtocol = url.startsWith("//");
50
+ for (const key in searchParams) {
51
+ const value = searchParams[key];
52
+ if (urlObject == null ? void 0 : urlObject.searchParams.has(key)) {
53
+ (_a = urlObject == null ? void 0 : urlObject.searchParams) == null ? void 0 : _a.set(key, value);
54
+ } else {
55
+ (_b = urlObject == null ? void 0 : urlObject.searchParams) == null ? void 0 : _b.append(key, value);
56
+ }
57
+ }
58
+ url = urlObject.toString();
59
+ if (withoutProtocol) {
60
+ return url == null ? void 0 : url.replace(location.protocol, "");
61
+ }
62
+ return url;
63
+ };
64
+ const getUrlObject = (url) => {
65
+ if (!url) {
66
+ return;
67
+ }
68
+ const withoutProtocol = url.startsWith("//");
69
+ if (withoutProtocol) {
70
+ url = location.protocol + url;
71
+ }
72
+ try {
73
+ return new URL(url);
74
+ } catch (error2) {
75
+ return;
76
+ }
77
+ };
43
78
  const strategy$1 = window["VePlayer"].strategy;
44
79
  const util$3 = window["VePlayer"].util;
45
80
  const DynamicModule$1 = window["VePlayer"].DynamicModule;
@@ -61,7 +96,12 @@ const getRtmStrategy = async (options, player) => {
61
96
  var _a;
62
97
  let backupStrategy;
63
98
  const { url } = options;
64
- const { fallbackUrl, enableFallback = true, ...ret } = options.rtm || {};
99
+ const {
100
+ fallbackUrl,
101
+ enableFallback = true,
102
+ enableRTMAutoTranscode,
103
+ ...ret
104
+ } = options.rtm || {};
65
105
  const actualFallbackUrl = !enableFallback ? "" : !fallbackUrl && url ? generateFallbackUrl(url) : fallbackUrl;
66
106
  const backupType = actualFallbackUrl && util$3.getStreamType(actualFallbackUrl);
67
107
  if (backupType === "flv" && util$3.isMseSupported(Codec$1.H264)) {
@@ -104,6 +144,7 @@ const getRtmStrategy = async (options, player) => {
104
144
  return {
105
145
  options: {
106
146
  ...(backupStrategy == null ? void 0 : backupStrategy.options) || {},
147
+ url: enableRTMAutoTranscode ? appendSearchParams(url, { enableRTMAutoTranscode: "true" }) : void 0,
107
148
  _RTMdegrade: void 0,
108
149
  rts: {
109
150
  retryCount: 0,
@@ -2784,24 +2825,12 @@ const getUserId2 = () => {
2784
2825
  return userId;
2785
2826
  };
2786
2827
  const generateUrlWithSessionId = (url) => {
2787
- var _a, _b;
2788
- if (!url) {
2789
- return "";
2828
+ const urlObject = getUrlObject(url);
2829
+ if (!urlObject) {
2830
+ return url ?? "";
2790
2831
  }
2791
- const withoutProtocol = url.startsWith("//");
2792
- if (withoutProtocol) {
2793
- url = location.protocol + url;
2794
- }
2795
- try {
2796
- const urlObject = new URL(url);
2797
- if (!((_a = urlObject == null ? void 0 : urlObject.searchParams) == null ? void 0 : _a.get("_session_id"))) {
2798
- (_b = urlObject == null ? void 0 : urlObject.searchParams) == null ? void 0 : _b.append("_session_id", generateSessionId());
2799
- }
2800
- url = urlObject.toString();
2801
- } catch (error2) {
2802
- }
2803
- if (withoutProtocol) {
2804
- return url == null ? void 0 : url.replace(location.protocol, "");
2832
+ if (!(urlObject == null ? void 0 : urlObject.searchParams.get("_session_id"))) {
2833
+ return appendSearchParams(url, { _session_id: generateSessionId() });
2805
2834
  }
2806
2835
  return url;
2807
2836
  };
@@ -2903,7 +2932,7 @@ class Logger extends Plugin$2 {
2903
2932
  user_id: this._userId,
2904
2933
  device_id: this._deviceId,
2905
2934
  ext: {
2906
- veplayer_version: "2.1.0",
2935
+ veplayer_version: "2.2.0-rc.0",
2907
2936
  flv_version: "3.0.10-alpha.4",
2908
2937
  hls_version: "3.0.10-alpha.4",
2909
2938
  rts_version: "0.2.0-alpha.5"