@ray-js/ipc-player-integration 0.0.53-beta.1 → 0.0.53-beta.2

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.
@@ -1,9 +1,13 @@
1
1
  import { kit } from '@ray-js/panel-sdk';
2
2
  declare const Strings: kit.I18N<{
3
3
  en: {
4
+ ipc_player_resolution_SS: string;
4
5
  ipc_player_resolution_HD: string;
5
6
  ipc_player_resolution_SD: string;
7
+ ipc_player_resolution_UD: string;
8
+ ipc_player_resolution_SSP: string;
6
9
  ipc_player_resolution_AUTO: string;
10
+ ipc_player_resolution_AUDIO: string;
7
11
  ipc_player_current_resolution_is_equal: string;
8
12
  ipc_player_screenshot_success_tip: string;
9
13
  ipc_player_screenshot_multi_success_tip: string;
@@ -42,9 +46,13 @@ declare const Strings: kit.I18N<{
42
46
  ipc_player_low_phone_not_support: string;
43
47
  };
44
48
  zh: {
49
+ ipc_player_resolution_SS: string;
45
50
  ipc_player_resolution_HD: string;
46
51
  ipc_player_resolution_SD: string;
52
+ ipc_player_resolution_UD: string;
53
+ ipc_player_resolution_SSP: string;
47
54
  ipc_player_resolution_AUTO: string;
55
+ ipc_player_resolution_AUDIO: string;
48
56
  ipc_player_current_resolution_is_equal: string;
49
57
  ipc_player_screenshot_success_tip: string;
50
58
  ipc_player_screenshot_multi_success_tip: string;
@@ -83,9 +91,13 @@ declare const Strings: kit.I18N<{
83
91
  ipc_player_low_phone_not_support: string;
84
92
  };
85
93
  }, {
94
+ ipc_player_resolution_SS: string;
86
95
  ipc_player_resolution_HD: string;
87
96
  ipc_player_resolution_SD: string;
97
+ ipc_player_resolution_UD: string;
98
+ ipc_player_resolution_SSP: string;
88
99
  ipc_player_resolution_AUTO: string;
100
+ ipc_player_resolution_AUDIO: string;
89
101
  ipc_player_current_resolution_is_equal: string;
90
102
  ipc_player_screenshot_success_tip: string;
91
103
  ipc_player_screenshot_multi_success_tip: string;
@@ -123,9 +135,13 @@ declare const Strings: kit.I18N<{
123
135
  ipc_player_fetch_error: string;
124
136
  ipc_player_low_phone_not_support: string;
125
137
  } | {
138
+ ipc_player_resolution_SS: string;
126
139
  ipc_player_resolution_HD: string;
127
140
  ipc_player_resolution_SD: string;
141
+ ipc_player_resolution_UD: string;
142
+ ipc_player_resolution_SSP: string;
128
143
  ipc_player_resolution_AUTO: string;
144
+ ipc_player_resolution_AUDIO: string;
129
145
  ipc_player_current_resolution_is_equal: string;
130
146
  ipc_player_screenshot_success_tip: string;
131
147
  ipc_player_screenshot_multi_success_tip: string;
@@ -1,8 +1,12 @@
1
1
  declare const _default: {
2
2
  en: {
3
+ ipc_player_resolution_SS: string;
3
4
  ipc_player_resolution_HD: string;
4
5
  ipc_player_resolution_SD: string;
6
+ ipc_player_resolution_UD: string;
7
+ ipc_player_resolution_SSP: string;
5
8
  ipc_player_resolution_AUTO: string;
9
+ ipc_player_resolution_AUDIO: string;
6
10
  ipc_player_current_resolution_is_equal: string;
7
11
  ipc_player_screenshot_success_tip: string;
8
12
  ipc_player_screenshot_multi_success_tip: string;
@@ -41,9 +45,13 @@ declare const _default: {
41
45
  ipc_player_low_phone_not_support: string;
42
46
  };
43
47
  zh: {
48
+ ipc_player_resolution_SS: string;
44
49
  ipc_player_resolution_HD: string;
45
50
  ipc_player_resolution_SD: string;
51
+ ipc_player_resolution_UD: string;
52
+ ipc_player_resolution_SSP: string;
46
53
  ipc_player_resolution_AUTO: string;
54
+ ipc_player_resolution_AUDIO: string;
47
55
  ipc_player_current_resolution_is_equal: string;
48
56
  ipc_player_screenshot_success_tip: string;
49
57
  ipc_player_screenshot_multi_success_tip: string;
@@ -1,8 +1,12 @@
1
1
  export default {
2
2
  en: {
3
+ ipc_player_resolution_SS: 'Data Saver',
3
4
  ipc_player_resolution_HD: 'HD',
4
5
  ipc_player_resolution_SD: 'SD',
6
+ ipc_player_resolution_UD: 'Ultra HD',
7
+ ipc_player_resolution_SSP: 'Super Ultra HD',
5
8
  ipc_player_resolution_AUTO: 'Auto',
9
+ ipc_player_resolution_AUDIO: 'Audio Mode',
6
10
  ipc_player_current_resolution_is_equal: 'Already at current clarity',
7
11
  ipc_player_screenshot_success_tip: 'Screenshot saved to album',
8
12
  ipc_player_screenshot_multi_success_tip: 'Screenshots saved to album',
@@ -41,9 +45,13 @@ export default {
41
45
  ipc_player_low_phone_not_support: 'This feature is not supported on this device'
42
46
  },
43
47
  zh: {
48
+ ipc_player_resolution_SS: '省流量',
44
49
  ipc_player_resolution_HD: '高清',
45
50
  ipc_player_resolution_SD: '标清',
51
+ ipc_player_resolution_UD: '超清',
52
+ ipc_player_resolution_SSP: '超超清',
46
53
  ipc_player_resolution_AUTO: '自动',
54
+ ipc_player_resolution_AUDIO: '音频模式',
47
55
  ipc_player_current_resolution_is_equal: '已是当前清晰度',
48
56
  ipc_player_screenshot_success_tip: '截图已保存在APP相册',
49
57
  ipc_player_screenshot_multi_success_tip: '图片已保存至相册',
@@ -62,7 +62,7 @@ export declare const bottomLeftContentResize = "bottomLeftContentResize";
62
62
  export declare const zoomLevelChange = "zoomLevelChange";
63
63
  /**
64
64
  * 自动清晰度状态变化事件:Resolution 控件检测到清晰度进入/退出自动模式或收到
65
- * clarityChanged 回调结果时触发,携带 { enabled, clarity }(clarity 为 'HD' | 'SD' | null)。
65
+ * onClarityChanged 事件时触发,携带 { enabled, clarity }(clarity 为 ClarityType | null)。
66
66
  * VideoBitKBP 监听此事件,在码率前展示当前高清/标清文案。
67
67
  */
68
68
  export declare const autoClarityChange = "autoClarityChange";
@@ -66,7 +66,7 @@ export const zoomLevelChange = 'zoomLevelChange';
66
66
 
67
67
  /**
68
68
  * 自动清晰度状态变化事件:Resolution 控件检测到清晰度进入/退出自动模式或收到
69
- * clarityChanged 回调结果时触发,携带 { enabled, clarity }(clarity 为 'HD' | 'SD' | null)。
69
+ * onClarityChanged 事件时触发,携带 { enabled, clarity }(clarity 为 ClarityType | null)。
70
70
  * VideoBitKBP 监听此事件,在码率前展示当前高清/标清文案。
71
71
  */
72
72
  export const autoClarityChange = 'autoClarityChange';
@@ -1,3 +1,4 @@
1
+ import { ClarityType } from '@ray-js/ray-ipc-utils/lib/interface';
1
2
  export type SmartImageQualityResult = {
2
3
  isPurchase: boolean;
3
4
  buttonState: number;
@@ -48,6 +49,17 @@ export declare function notifyOfflineShown(deviceId: string): boolean;
48
49
  export declare function getNgRawData(): Promise<unknown>;
49
50
  export declare function isClarityChangedSupported(): boolean;
50
51
  export type ClarityChangedResult = {
51
- clarity: 'HD' | 'SD';
52
+ deviceId?: string;
53
+ clarity: ClarityType;
52
54
  };
53
- export declare function clarityChanged(devId: string): Promise<ClarityChangedResult | null>;
55
+ export type ClarityChangedHandler = (result: ClarityChangedResult) => void;
56
+ type ClarityChangedListener = (payload: ClarityChangedResult) => void;
57
+ export declare function offClarityChanged(listener: ClarityChangedListener): void;
58
+ /**
59
+ * 监听自动清晰度变化,返回取消监听函数。
60
+ *
61
+ * onClarityChanged / offClarityChanged 均使用同一个 listener 引用,
62
+ * 否则宿主无法正确移除监听。
63
+ */
64
+ export declare function subscribeClarityChanged(devId: string, handler: ClarityChangedHandler): () => void;
65
+ export {};
package/lib/utils/ttt.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
+ import { ClarityType } from '@ray-js/ray-ipc-utils/lib/interface';
2
3
  export function getSmartImageQualityState(devId) {
3
4
  return new Promise(resolve => {
4
5
  var _ty$ipc;
@@ -165,35 +166,63 @@ export function getNgRawData() {
165
166
  });
166
167
  }
167
168
 
168
- // 是否支持自动清晰度(ttt 方法 clarityChanged 存在即支持)
169
+ // 是否支持自动清晰度(ttt 方法 onClarityChanged 存在即支持)
169
170
  export function isClarityChangedSupported() {
170
- var _ty$ipc6;
171
- return typeof ((_ty$ipc6 = ty.ipc) === null || _ty$ipc6 === void 0 ? void 0 : _ty$ipc6.clarityChanged) === 'function';
171
+ var _ty5;
172
+ return typeof ty !== 'undefined' && typeof ((_ty5 = ty) === null || _ty5 === void 0 || (_ty5 = _ty5.ipc) === null || _ty5 === void 0 ? void 0 : _ty5.onClarityChanged) === 'function';
172
173
  }
173
- export function clarityChanged(devId) {
174
- return new Promise(resolve => {
175
- var _ty$ipc7;
176
- if (typeof ((_ty$ipc7 = ty.ipc) === null || _ty$ipc7 === void 0 ? void 0 : _ty$ipc7.clarityChanged) !== 'function') {
177
- resolve(null);
174
+ export function offClarityChanged(listener) {
175
+ var _ty6;
176
+ const ipc = typeof ty !== 'undefined' ? (_ty6 = ty) === null || _ty6 === void 0 ? void 0 : _ty6.ipc : undefined;
177
+ if (!ipc || typeof ipc.offClarityChanged !== 'function') {
178
+ return;
179
+ }
180
+ try {
181
+ ipc.offClarityChanged(listener);
182
+ } catch (error) {
183
+ console.warn('res===offClarityChanged fail', error);
184
+ }
185
+ }
186
+
187
+ /**
188
+ * 监听自动清晰度变化,返回取消监听函数。
189
+ *
190
+ * onClarityChanged / offClarityChanged 均使用同一个 listener 引用,
191
+ * 否则宿主无法正确移除监听。
192
+ */
193
+ export function subscribeClarityChanged(devId, handler) {
194
+ var _ty7;
195
+ const ipc = typeof ty !== 'undefined' ? (_ty7 = ty) === null || _ty7 === void 0 ? void 0 : _ty7.ipc : undefined;
196
+ if (!ipc || typeof ipc.onClarityChanged !== 'function') {
197
+ return () => undefined;
198
+ }
199
+ const listener = payload => {
200
+ console.log('[resolution] onClarityChanged 事件到达', JSON.stringify(payload !== null && payload !== void 0 ? payload : null));
201
+ const {
202
+ deviceId,
203
+ clarity
204
+ } = payload || {};
205
+ if (!Object.values(ClarityType).includes(clarity)) {
206
+ console.warn('[resolution] onClarityChanged 缺少 clarity');
178
207
  return;
179
208
  }
180
- if (!isClarityChangedSupported()) {
181
- resolve(null);
209
+ // 一页多设备时只认自己的;宿主没带 deviceId 就不过滤
210
+ if (deviceId && deviceId !== devId) {
211
+ console.warn('[resolution] onClarityChanged 非本设备,已忽略', `${deviceId} != ${devId}`);
182
212
  return;
183
213
  }
184
- try {
185
- ty.ipc.clarityChanged({
186
- devId,
187
- success: res => {
188
- resolve(res !== null && res !== void 0 ? res : null);
189
- },
190
- fail: e => {
191
- console.warn('res===clarityChanged fail', e);
192
- resolve(null);
193
- }
194
- });
195
- } catch (e) {
196
- resolve(null);
197
- }
198
- });
214
+ handler({
215
+ deviceId,
216
+ clarity
217
+ });
218
+ };
219
+ try {
220
+ ipc.onClarityChanged(listener);
221
+ } catch (error) {
222
+ console.warn('res===onClarityChanged fail', error);
223
+ return () => undefined;
224
+ }
225
+ return () => {
226
+ offClarityChanged(listener);
227
+ };
199
228
  }
@@ -9,7 +9,7 @@ import { FullResolutionControl } from './fullResolutionControl';
9
9
  import { fullResolutionId, pauseTimeToHideAllComponent, hideAllComponent, widgetLabs, widgetClick, autoClarityChange } from '../../ui/constant';
10
10
  import { UIEventContext } from '../../ui/context';
11
11
  import { useStore } from '../../ctx/store';
12
- import { clarityChanged } from '../../utils/ttt';
12
+ import { subscribeClarityChanged } from '../../utils/ttt';
13
13
  import './resolution.less';
14
14
  export const Resolution = props => {
15
15
  const {
@@ -33,7 +33,7 @@ export const Resolution = props => {
33
33
  } = useContext(UIEventContext);
34
34
 
35
35
  // 广播自动清晰度状态给 VideoBitKBP 等监听方;
36
- // 自动模式下读取一次当前实际清晰度,仅用于码率区域展示。
36
+ // 自动模式下监听当前实际清晰度,仅用于码率区域展示。
37
37
  useEffect(() => {
38
38
  const emitClarity = (enabled, clarity) => {
39
39
  event.emit(autoClarityChange, {
@@ -43,18 +43,14 @@ export const Resolution = props => {
43
43
  };
44
44
  if (resolution !== ClarityType.AUTO) {
45
45
  emitClarity(false, null);
46
- return;
46
+ return undefined;
47
47
  }
48
48
  emitClarity(true, null);
49
- if (devId) {
50
- clarityChanged(devId).then(res => {
51
- if (res !== null && res !== void 0 && res.clarity) {
52
- emitClarity(true, res.clarity);
53
- }
54
- });
55
- }
56
- // eslint-disable-next-line react-hooks/exhaustive-deps
57
- }, [devId, resolution]);
49
+ if (!devId) return undefined;
50
+ return subscribeClarityChanged(devId, res => {
51
+ emitClarity(true, res.clarity);
52
+ });
53
+ }, [devId, event, resolution]);
58
54
  const onResolution = useMemoizedFn(() => {
59
55
  event.emit(widgetClick, {
60
56
  widgetId: widgetLabs.RESOLUTION
@@ -29,7 +29,6 @@ export const VideoBitKBP = props => {
29
29
  event
30
30
  } = useContext(UIEventContext);
31
31
  const timerRef = useRef();
32
-
33
32
  // 监听 Resolution 控件广播的自动清晰度状态
34
33
  useEffect(() => {
35
34
  const onAutoClarityChange = payload => {
@@ -103,7 +102,26 @@ export const VideoBitKBP = props => {
103
102
  className: "ipc-player-plugin-videoBitKBP-kbps"
104
103
  }, autoClarity && /*#__PURE__*/React.createElement(Text, {
105
104
  className: "ipc-player-plugin-videoBitKBP-clarity"
106
- }, autoClarity === 'HD' ? Strings.getLang('ipc_player_resolution_HD') : Strings.getLang('ipc_player_resolution_SD')), /*#__PURE__*/React.createElement(Text, null, bitKBP), /*#__PURE__*/React.createElement(Text, {
105
+ }, (clarity => {
106
+ switch (clarity) {
107
+ case ClarityType.SS:
108
+ return Strings.getLang('ipc_player_resolution_SS');
109
+ case ClarityType.SD:
110
+ return Strings.getLang('ipc_player_resolution_SD');
111
+ case ClarityType.HD:
112
+ return Strings.getLang('ipc_player_resolution_HD');
113
+ case ClarityType.UD:
114
+ return Strings.getLang('ipc_player_resolution_UD');
115
+ case ClarityType.SSP:
116
+ return Strings.getLang('ipc_player_resolution_SSP');
117
+ case ClarityType.AUTO:
118
+ return Strings.getLang('ipc_player_resolution_AUTO');
119
+ case ClarityType.AUDIO:
120
+ return Strings.getLang('ipc_player_resolution_AUDIO');
121
+ default:
122
+ return clarity;
123
+ }
124
+ })(autoClarity)), /*#__PURE__*/React.createElement(Text, null, bitKBP), /*#__PURE__*/React.createElement(Text, {
107
125
  className: "ipc-player-plugin-videoBitKBP-unit-kbs"
108
126
  }, "KB/S"))));
109
127
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/ipc-player-integration",
3
- "version": "0.0.53-beta.1",
3
+ "version": "0.0.53-beta.2",
4
4
  "description": "IPC 融合播放器",
5
5
  "main": "lib/index",
6
6
  "files": [