@ray-js/ipc-player-integration 0.0.29 → 0.0.31-beta.1

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.
@@ -5,6 +5,356 @@
5
5
  "css_prefix_text": "icon-panel-",
6
6
  "description": "IPC 小程序公版",
7
7
  "glyphs": [
8
+ {
9
+ "icon_id": "47215545",
10
+ "name": "nightvision-mode-black-color",
11
+ "font_class": "nightvision-mode-black-color",
12
+ "unicode": "e6a2",
13
+ "unicode_decimal": 59042
14
+ },
15
+ {
16
+ "icon_id": "47215544",
17
+ "name": "nightvision-mode-true-color",
18
+ "font_class": "nightvision-mode-true-color",
19
+ "unicode": "e6a3",
20
+ "unicode_decimal": 59043
21
+ },
22
+ {
23
+ "icon_id": "47215543",
24
+ "name": "nightvision-mode-color",
25
+ "font_class": "nightvision-mode-color",
26
+ "unicode": "e6bc",
27
+ "unicode_decimal": 59068
28
+ },
29
+ {
30
+ "icon_id": "47214631",
31
+ "name": "wi-Fi",
32
+ "font_class": "wi-Fi",
33
+ "unicode": "e6bb",
34
+ "unicode_decimal": 59067
35
+ },
36
+ {
37
+ "icon_id": "47214513",
38
+ "name": "motion-tracking",
39
+ "font_class": "motion-tracking",
40
+ "unicode": "e6ba",
41
+ "unicode_decimal": 59066
42
+ },
43
+ {
44
+ "icon_id": "47214487",
45
+ "name": "optical-zoom",
46
+ "font_class": "optical-zoom",
47
+ "unicode": "e6b8",
48
+ "unicode_decimal": 59064
49
+ },
50
+ {
51
+ "icon_id": "47214486",
52
+ "name": "pip-mode",
53
+ "font_class": "pip-mode",
54
+ "unicode": "e6b9",
55
+ "unicode_decimal": 59065
56
+ },
57
+ {
58
+ "icon_id": "47214463",
59
+ "name": "basic-shimmer",
60
+ "font_class": "basic-shimmer",
61
+ "unicode": "e6b5",
62
+ "unicode_decimal": 59061
63
+ },
64
+ {
65
+ "icon_id": "47214464",
66
+ "name": "basic-nightvision-close",
67
+ "font_class": "basic-nightvision-close",
68
+ "unicode": "e6b6",
69
+ "unicode_decimal": 59062
70
+ },
71
+ {
72
+ "icon_id": "47214462",
73
+ "name": "basic-nightvision-open",
74
+ "font_class": "basic-nightvision-open",
75
+ "unicode": "e6b7",
76
+ "unicode_decimal": 59063
77
+ },
78
+ {
79
+ "icon_id": "47214467",
80
+ "name": "nightvision-mode-ir",
81
+ "font_class": "nightvision-mode-ir",
82
+ "unicode": "e6b3",
83
+ "unicode_decimal": 59059
84
+ },
85
+ {
86
+ "icon_id": "47214466",
87
+ "name": "nightvision-mode-auto",
88
+ "font_class": "nightvision-mode-auto",
89
+ "unicode": "e6b4",
90
+ "unicode_decimal": 59060
91
+ },
92
+ {
93
+ "icon_id": "47188073",
94
+ "name": "锁",
95
+ "font_class": "suo",
96
+ "unicode": "e6b2",
97
+ "unicode_decimal": 59058
98
+ },
99
+ {
100
+ "icon_id": "47188035",
101
+ "name": "警笛",
102
+ "font_class": "jingdi",
103
+ "unicode": "e6b0",
104
+ "unicode_decimal": 59056
105
+ },
106
+ {
107
+ "icon_id": "47188034",
108
+ "name": "灯",
109
+ "font_class": "deng",
110
+ "unicode": "e6b1",
111
+ "unicode_decimal": 59057
112
+ },
113
+ {
114
+ "icon_id": "47187999",
115
+ "name": "下载",
116
+ "font_class": "xiazai",
117
+ "unicode": "e6ae",
118
+ "unicode_decimal": 59054
119
+ },
120
+ {
121
+ "icon_id": "47187998",
122
+ "name": "分享",
123
+ "font_class": "fenxiang",
124
+ "unicode": "e6af",
125
+ "unicode_decimal": 59055
126
+ },
127
+ {
128
+ "icon_id": "47187589",
129
+ "name": "收藏",
130
+ "font_class": "a-zu1032",
131
+ "unicode": "e6ad",
132
+ "unicode_decimal": 59053
133
+ },
134
+ {
135
+ "icon_id": "47187573",
136
+ "name": "记录",
137
+ "font_class": "jilu",
138
+ "unicode": "e6ac",
139
+ "unicode_decimal": 59052
140
+ },
141
+ {
142
+ "icon_id": "47187414",
143
+ "name": "定位(小)",
144
+ "font_class": "a-dingweixiao",
145
+ "unicode": "e6ab",
146
+ "unicode_decimal": 59051
147
+ },
148
+ {
149
+ "icon_id": "47187136",
150
+ "name": "足迹分享",
151
+ "font_class": "zujifenxiang",
152
+ "unicode": "e6aa",
153
+ "unicode_decimal": 59050
154
+ },
155
+ {
156
+ "icon_id": "47186554",
157
+ "name": "足迹",
158
+ "font_class": "zuji",
159
+ "unicode": "e6a7",
160
+ "unicode_decimal": 59047
161
+ },
162
+ {
163
+ "icon_id": "47186548",
164
+ "name": "宠物档案",
165
+ "font_class": "chongwudangan",
166
+ "unicode": "e6a8",
167
+ "unicode_decimal": 59048
168
+ },
169
+ {
170
+ "icon_id": "47186450",
171
+ "name": "遛宠",
172
+ "font_class": "liuchong",
173
+ "unicode": "e6a6",
174
+ "unicode_decimal": 59046
175
+ },
176
+ {
177
+ "icon_id": "47186340",
178
+ "name": "围栏",
179
+ "font_class": "weilan",
180
+ "unicode": "e6a9",
181
+ "unicode_decimal": 59049
182
+ },
183
+ {
184
+ "icon_id": "47131812",
185
+ "name": "WER",
186
+ "font_class": "WER",
187
+ "unicode": "e6a5",
188
+ "unicode_decimal": 59045
189
+ },
190
+ {
191
+ "icon_id": "47131735",
192
+ "name": "infrared-night-vision",
193
+ "font_class": "infrared-night-vision",
194
+ "unicode": "e6a4",
195
+ "unicode_decimal": 59044
196
+ },
197
+ {
198
+ "icon_id": "47131298",
199
+ "name": "night-vision",
200
+ "font_class": "night-vision",
201
+ "unicode": "e6a1",
202
+ "unicode_decimal": 59041
203
+ },
204
+ {
205
+ "icon_id": "47073070",
206
+ "name": "Access-Key-Password",
207
+ "font_class": "Access-Key-Password",
208
+ "unicode": "e643",
209
+ "unicode_decimal": 58947
210
+ },
211
+ {
212
+ "icon_id": "47073029",
213
+ "name": "Access-Mobile",
214
+ "font_class": "Access-Mobile1",
215
+ "unicode": "e638",
216
+ "unicode_decimal": 58936
217
+ },
218
+ {
219
+ "icon_id": "47072934",
220
+ "name": "Access-QuickReply",
221
+ "font_class": "Access-QuickReply",
222
+ "unicode": "e631",
223
+ "unicode_decimal": 58929
224
+ },
225
+ {
226
+ "icon_id": "47072914",
227
+ "name": "Access-Key-FaceID",
228
+ "font_class": "Access-Key-FaceID2",
229
+ "unicode": "e633",
230
+ "unicode_decimal": 58931
231
+ },
232
+ {
233
+ "icon_id": "47072572",
234
+ "name": "Access-NoBlock",
235
+ "font_class": "Access-NoBlock",
236
+ "unicode": "e632",
237
+ "unicode_decimal": 58930
238
+ },
239
+ {
240
+ "icon_id": "47072558",
241
+ "name": "Access-Password-View",
242
+ "font_class": "Access-Password-View",
243
+ "unicode": "e61d",
244
+ "unicode_decimal": 58909
245
+ },
246
+ {
247
+ "icon_id": "47072205",
248
+ "name": "Access-Door",
249
+ "font_class": "Access-Door",
250
+ "unicode": "e69e",
251
+ "unicode_decimal": 59038
252
+ },
253
+ {
254
+ "icon_id": "47071738",
255
+ "name": "Access-Camera",
256
+ "font_class": "Access-Camera",
257
+ "unicode": "e69a",
258
+ "unicode_decimal": 59034
259
+ },
260
+ {
261
+ "icon_id": "47071730",
262
+ "name": "Access-Member",
263
+ "font_class": "Access-Member",
264
+ "unicode": "e69c",
265
+ "unicode_decimal": 59036
266
+ },
267
+ {
268
+ "icon_id": "47071754",
269
+ "name": "Access-Password-Hide",
270
+ "font_class": "Access-Password-Hide",
271
+ "unicode": "e619",
272
+ "unicode_decimal": 58905
273
+ },
274
+ {
275
+ "icon_id": "47071752",
276
+ "name": "Access-AI Guardian",
277
+ "font_class": "a-Access-AIGuardian",
278
+ "unicode": "e61b",
279
+ "unicode_decimal": 58907
280
+ },
281
+ {
282
+ "icon_id": "47071749",
283
+ "name": "Access-Key-Fingerprint",
284
+ "font_class": "Access-Key-Fingerprint",
285
+ "unicode": "e622",
286
+ "unicode_decimal": 58914
287
+ },
288
+ {
289
+ "icon_id": "47071747",
290
+ "name": "Access-Send",
291
+ "font_class": "Access-Send",
292
+ "unicode": "e634",
293
+ "unicode_decimal": 58932
294
+ },
295
+ {
296
+ "icon_id": "47071744",
297
+ "name": "Access-Password-Clear",
298
+ "font_class": "Access-Password-Clear",
299
+ "unicode": "e63d",
300
+ "unicode_decimal": 58941
301
+ },
302
+ {
303
+ "icon_id": "47071743",
304
+ "name": "Access-Notification-large",
305
+ "font_class": "Access-Notification-large",
306
+ "unicode": "e63e",
307
+ "unicode_decimal": 58942
308
+ },
309
+ {
310
+ "icon_id": "47071742",
311
+ "name": "Access-Intercom-large",
312
+ "font_class": "Access-Intercom-large",
313
+ "unicode": "e63f",
314
+ "unicode_decimal": 58943
315
+ },
316
+ {
317
+ "icon_id": "47071737",
318
+ "name": "Access-Brightness",
319
+ "font_class": "Access-Brightness",
320
+ "unicode": "e640",
321
+ "unicode_decimal": 58944
322
+ },
323
+ {
324
+ "icon_id": "47071741",
325
+ "name": "Access-TempAccess-large",
326
+ "font_class": "Access-TempAccess-large",
327
+ "unicode": "e641",
328
+ "unicode_decimal": 58945
329
+ },
330
+ {
331
+ "icon_id": "47071740",
332
+ "name": "Access-Undo",
333
+ "font_class": "Access-Undo",
334
+ "unicode": "e699",
335
+ "unicode_decimal": 59033
336
+ },
337
+ {
338
+ "icon_id": "47071756",
339
+ "name": "Access-Key-Card",
340
+ "font_class": "Access-Key-Card",
341
+ "unicode": "e615",
342
+ "unicode_decimal": 58901
343
+ },
344
+ {
345
+ "icon_id": "47071755",
346
+ "name": "Access-Replay",
347
+ "font_class": "Access-Replay",
348
+ "unicode": "e616",
349
+ "unicode_decimal": 58902
350
+ },
351
+ {
352
+ "icon_id": "47034105",
353
+ "name": "Access-Copy",
354
+ "font_class": "Access-Copy",
355
+ "unicode": "e613",
356
+ "unicode_decimal": 58899
357
+ },
8
358
  {
9
359
  "icon_id": "46981006",
10
360
  "name": "tip-right-arrow",
@@ -43,7 +393,7 @@
43
393
  {
44
394
  "icon_id": "46763588",
45
395
  "name": "door-close-small",
46
- "font_class": "door-close-small",
396
+ "font_class": "Access-door-close-small",
47
397
  "unicode": "e6671",
48
398
  "unicode_decimal": 943729
49
399
  },
Binary file
Binary file
Binary file
@@ -61,6 +61,7 @@ export type UseCtx = (options: {
61
61
  intercom: RetAtom<boolean>;
62
62
  intercomMode: RetAtom<IntercomMode>;
63
63
  intercomSupported: RetAtom<boolean>;
64
+ maxZoomSettings: RetAtom<number>;
64
65
  resolution: RetAtom<string>;
65
66
  resolutionList: RetAtom<string[]>;
66
67
  playState: RetAtom<PlayState>;
@@ -39,6 +39,8 @@ export declare const widgetLabs: {
39
39
  readonly FULL_SCREEN: "FullScreen";
40
40
  readonly VERTICAL_SCREEN: "VerticalScreen";
41
41
  };
42
+ export declare const zoomLevelChange = "zoomLevelChange";
43
+ export declare const setScaleMultipleEvent = "setScaleMultipleEvent";
42
44
  export declare const decodeClarityDic: {
43
45
  SS: string;
44
46
  SD: string;
@@ -40,6 +40,8 @@ export const widgetLabs = {
40
40
  FULL_SCREEN: 'FullScreen',
41
41
  VERTICAL_SCREEN: 'VerticalScreen'
42
42
  };
43
+ export const zoomLevelChange = 'zoomLevelChange';
44
+ export const setScaleMultipleEvent = 'setScaleMultipleEvent';
43
45
  export const decodeClarityDic = {
44
46
  SS: 'ss',
45
47
  // 省流量
package/lib/ui/ui.js CHANGED
@@ -11,7 +11,7 @@ import { PlayState, PlayerStreamStatus, MultiCameraScreenMode } from '../interfa
11
11
  import { useCtx } from '../ctx/ctx.composition';
12
12
  import { useStore, updateAtom } from '../ctx/store';
13
13
  import { UIEventContext } from './context';
14
- import { showAllComponent, hideAllComponent, playerTap, startTimeToHideAllComponent, pauseTimeToHideAllComponent, decodeClarityDic, changeIgnoreHideStopPreview, moveablePtzControlId, tileActionsId, tileTipId, landscapeTipId, multiPtzId, ptzMoveableTipId, showFlowLowTipId } from './constant';
14
+ import { showAllComponent, hideAllComponent, playerTap, startTimeToHideAllComponent, pauseTimeToHideAllComponent, decodeClarityDic, changeIgnoreHideStopPreview, moveablePtzControlId, tileActionsId, tileTipId, landscapeTipId, multiPtzId, ptzMoveableTipId, showFlowLowTipId, zoomLevelChange, setScaleMultipleEvent } from './constant';
15
15
  import BottomLeftContent from './bottomLeftContent';
16
16
  import BottomRightContent from './bottomRightContent';
17
17
  import TopLeftContent from './topLeftContent';
@@ -410,7 +410,7 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
410
410
  eventRef.current.emit('disablePlayerTap', false);
411
411
  showComponents();
412
412
  }
413
- }, [isVerticalFullLayout, screenType, playerFit, instance]);
413
+ }, [isVerticalFullLayout, screenType, playerFit]);
414
414
  useEffect(() => {
415
415
  if (createCtx) {
416
416
  setScaleMultiple(playerFit === 'contain' ? 1 : -2);
@@ -659,6 +659,8 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
659
659
  instance.changeStreamStatus(code);
660
660
  });
661
661
  const disablePlayerTap = useRef(false);
662
+ // 标记正在执行隐藏,防止 playerTap 子组件监听触发 showAllComponent 干扰隐藏
663
+ const isHidingByTapRef = useRef(false);
662
664
  const hasInitializedLandscapeMultiRef = useRef(false);
663
665
  const multiTapTimerRef = useRef(null);
664
666
  const prevSelectedIndexRef = useRef(selectedLenInfo.index);
@@ -693,14 +695,15 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
693
695
  eventRef.current.emit(type);
694
696
  };
695
697
  const listenStart = useMemoizedFn(() => {
696
- timer.current && clearTimeout(timer.current);
697
- // 重新开始计时
698
- if (!timer.current) {
699
- // @ts-ignore
700
- timer.current = setTimeout(() => {
701
- triggerEvent(hideAllComponent);
702
- }, HIDE_COMPONENT_TIME);
698
+ if (timer.current) {
699
+ clearTimeout(timer.current);
700
+ timer.current = null;
703
701
  }
702
+ // 重新开始计时
703
+ // @ts-ignore
704
+ timer.current = setTimeout(() => {
705
+ triggerEvent(hideAllComponent);
706
+ }, HIDE_COMPONENT_TIME);
704
707
  });
705
708
  const listenPause = useMemoizedFn(() => {
706
709
  timer.current && clearTimeout(timer.current);
@@ -710,11 +713,15 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
710
713
  setComponentHideState(true);
711
714
  });
712
715
  const listenShowEvent = useMemoizedFn(() => {
716
+ if (isHidingByTapRef.current) return;
713
717
  setComponentHideState(false);
714
718
  });
715
719
  const onChangeIgnoreHideStopPreview = state => {
716
720
  setIgnoreStopOnHide(state);
717
721
  };
722
+ const onSetScaleMultiple = value => {
723
+ setScaleMultiple(value);
724
+ };
718
725
  useEffect(() => {
719
726
  eventRef.current.on(startTimeToHideAllComponent, listenStart);
720
727
  eventRef.current.on(pauseTimeToHideAllComponent, listenPause);
@@ -723,6 +730,7 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
723
730
  eventRef.current.on('disablePlayerTap', handDisablePlayerTap);
724
731
  eventRef.current.on('refreshBottomLeft', refreshBottomLeft);
725
732
  eventRef.current.on(changeIgnoreHideStopPreview, onChangeIgnoreHideStopPreview);
733
+ eventRef.current.on(setScaleMultipleEvent, onSetScaleMultiple);
726
734
  return () => {
727
735
  eventRef.current.off(startTimeToHideAllComponent, listenStart);
728
736
  eventRef.current.off(pauseTimeToHideAllComponent, listenPause);
@@ -731,6 +739,7 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
731
739
  eventRef.current.off('disablePlayerTap', handDisablePlayerTap);
732
740
  eventRef.current.off('refreshBottomLeft', refreshBottomLeft);
733
741
  eventRef.current.off(changeIgnoreHideStopPreview, onChangeIgnoreHideStopPreview);
742
+ eventRef.current.off(setScaleMultipleEvent, onSetScaleMultiple);
734
743
  if (multiTapTimerRef.current) {
735
744
  clearTimeout(multiTapTimerRef.current);
736
745
  multiTapTimerRef.current = null;
@@ -788,6 +797,7 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
788
797
  setScaleMultiple(zoomLevel);
789
798
  }
790
799
  setCurrentZoomLevel(zoomLevel);
800
+ instance.event.emit(zoomLevelChange, zoomLevel);
791
801
  return false;
792
802
  });
793
803
  const playerContainerHeight = screenType === 'vertical' ? (style === null || style === void 0 ? void 0 : style.height) || '100%' : '100vh';
@@ -851,8 +861,6 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
851
861
  return;
852
862
  }
853
863
  console.log('res===on onVideoTap', data);
854
- eventRef.current.emit(playerTap);
855
- console.log(prevTriggerEvent.current, 'prevTriggerEvent.current');
856
864
  if (instance.multiCameraCtx.isSupport) {
857
865
  var _instance$multiCamera, _instance$multiCamera2;
858
866
  const preTapIndex = (_instance$multiCamera = (_instance$multiCamera2 = instance.multiCameraCtx.selectedLenInfoRef.current) === null || _instance$multiCamera2 === void 0 ? void 0 : _instance$multiCamera2.index) !== null && _instance$multiCamera !== void 0 ? _instance$multiCamera : prevSelectedIndexRef.current;
@@ -881,10 +889,21 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
881
889
  prevSelectedIndexRef.current = currentIndex;
882
890
  multiTapTimerRef.current = null;
883
891
  }, 50);
884
- } else if (prevTriggerEvent.current === hideAllComponent) {
885
- triggerEvent(showAllComponent);
892
+ } else if (componentHideState) {
893
+ // 当前隐藏 → 显示(带自动隐藏计时器)
894
+ showComponents();
895
+ eventRef.current.emit(playerTap);
886
896
  } else {
887
- triggerEvent(hideAllComponent);
897
+ // 当前显示 → 隐藏
898
+ if (timer.current) {
899
+ clearTimeout(timer.current);
900
+ timer.current = null;
901
+ }
902
+ setComponentHideState(true);
903
+ // 标记正在隐藏,防止 emit(playerTap) 触发子组件 emit(showAllComponent) 导致隐藏被覆盖
904
+ isHidingByTapRef.current = true;
905
+ eventRef.current.emit(playerTap);
906
+ isHidingByTapRef.current = false;
888
907
  }
889
908
  onPlayerTap && onPlayerTap(data);
890
909
  return false; // eslint-disable-line
@@ -18,3 +18,4 @@ export * from './multiCamera';
18
18
  export * from './smallIntercom';
19
19
  export * from './toggleVerticalFull';
20
20
  export * from './flowLowTip';
21
+ export * from './realTimeMagnification';
@@ -17,4 +17,5 @@ export * from './ptzControlTip';
17
17
  export * from './multiCamera';
18
18
  export * from './smallIntercom';
19
19
  export * from './toggleVerticalFull';
20
- export * from './flowLowTip';
20
+ export * from './flowLowTip';
21
+ export * from './realTimeMagnification';
@@ -3,7 +3,7 @@ import React, { useContext } from 'react';
3
3
  import clsx from 'clsx';
4
4
  import { useStore } from '../../ctx/store';
5
5
  import { UIEventContext } from '../../ui/context';
6
- import { widgetLabs, widgetClick } from '../../ui/constant';
6
+ import { widgetLabs, widgetClick, pauseTimeToHideAllComponent, startTimeToHideAllComponent } from '../../ui/constant';
7
7
  import './muted.less';
8
8
  export const Muted = props => {
9
9
  const {
@@ -27,7 +27,9 @@ export const Muted = props => {
27
27
  event.emit(widgetClick, {
28
28
  widgetId: widgetLabs.MUTED
29
29
  });
30
+ event.emit(pauseTimeToHideAllComponent);
30
31
  setMute(!isMuted);
32
+ event.emit(startTimeToHideAllComponent);
31
33
  }
32
34
  }, isMuted ? /*#__PURE__*/React.createElement(Text, {
33
35
  className: "ipc-player-plugin-muted-text-icon icon-panel icon-panel-mute-off"
@@ -0,0 +1 @@
1
+ export * from './realTimeMagnification';
@@ -0,0 +1 @@
1
+ export * from './realTimeMagnification';
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import { ComponentConfigProps } from '../../interface';
3
+ import './realTimeMagnification.less';
4
+ type Props = ComponentConfigProps & {
5
+ className?: string;
6
+ };
7
+ export declare const RealTimeMagnification: (props: Props) => React.JSX.Element | null;
8
+ export {};
@@ -0,0 +1,91 @@
1
+ import React, { useCallback, useEffect, useMemo, useState } from 'react';
2
+ import { View, Text } from '@ray-js/ray';
3
+ import clsx from 'clsx';
4
+ import { PlayState } from '../../interface';
5
+ import { useStore } from '../../ctx/store';
6
+ import { zoomLevelChange, setScaleMultipleEvent, pauseTimeToHideAllComponent, startTimeToHideAllComponent } from '../../ui/constant';
7
+ import './realTimeMagnification.less';
8
+
9
+ /** 全量档位列表 */
10
+ const ALL_ZOOM_LEVELS = [1, 2, 4, 6, 8, 12];
11
+ export const RealTimeMagnification = props => {
12
+ const {
13
+ playState,
14
+ event,
15
+ className,
16
+ screenType: screenTypeAtom,
17
+ maxZoomSettings: maxZoomAtom
18
+ } = props;
19
+ const {
20
+ playState: currentPlayState,
21
+ screenType,
22
+ maxZoomSettings
23
+ } = useStore({
24
+ playState,
25
+ screenType: screenTypeAtom,
26
+ maxZoomSettings: maxZoomAtom
27
+ });
28
+ const [currentZoom, setCurrentZoom] = useState(1);
29
+
30
+ /** 根据 maxZoomSettings 动态生成可用档位列表 */
31
+ const zoomLevels = useMemo(() => {
32
+ const max = maxZoomSettings || 6;
33
+ const levels = ALL_ZOOM_LEVELS.filter(level => level <= max);
34
+ // 若最大值不在预设档位中,追加到末尾
35
+ if (max > 1 && levels[levels.length - 1] !== max) {
36
+ levels.push(max);
37
+ }
38
+ return levels;
39
+ }, [maxZoomSettings]);
40
+ useEffect(() => {
41
+ const onZoomChange = zoomLevel => {
42
+ if (zoomLevel > 0) {
43
+ setCurrentZoom(zoomLevel);
44
+ }
45
+ };
46
+ event.on(zoomLevelChange, onZoomChange);
47
+ return () => {
48
+ event.off(zoomLevelChange, onZoomChange);
49
+ };
50
+ }, [event]);
51
+
52
+ /** 获取当前倍数对应的档位显示值(取最接近且 <= currentZoom 的档位) */
53
+ const getDisplayZoom = useCallback(() => {
54
+ for (let i = zoomLevels.length - 1; i >= 0; i--) {
55
+ if (currentZoom >= zoomLevels[i]) {
56
+ return zoomLevels[i];
57
+ }
58
+ }
59
+ return zoomLevels[0];
60
+ }, [currentZoom, zoomLevels]);
61
+
62
+ /** 获取下一档倍数,循环切换 */
63
+ const getNextZoom = useCallback(() => {
64
+ const display = getDisplayZoom();
65
+ const currentIndex = zoomLevels.indexOf(display);
66
+ const nextIndex = (currentIndex + 1) % zoomLevels.length;
67
+ return zoomLevels[nextIndex];
68
+ }, [getDisplayZoom, zoomLevels]);
69
+
70
+ /** 点击切换到下一档倍数 */
71
+ const handleClick = useCallback(() => {
72
+ event.emit(pauseTimeToHideAllComponent);
73
+ const nextZoom = getNextZoom();
74
+ console.log('RealTimeMagnification click', 'currentZoom:', currentZoom, 'nextZoom:', nextZoom);
75
+ event.emit(setScaleMultipleEvent, nextZoom);
76
+ event.emit(startTimeToHideAllComponent);
77
+ }, [getNextZoom, event, currentZoom]);
78
+ if (currentPlayState !== PlayState.PLAYING) {
79
+ return null;
80
+ }
81
+ return /*#__PURE__*/React.createElement(View, {
82
+ onClick: handleClick,
83
+ className: clsx(className)
84
+ }, /*#__PURE__*/React.createElement(View, {
85
+ className: clsx('ipc-player-plugin-realtime-magnification', {
86
+ 'ipc-player-plugin-realtime-magnification-full': screenType === 'full'
87
+ })
88
+ }, /*#__PURE__*/React.createElement(Text, {
89
+ className: "magnificationText"
90
+ }, currentZoom.toFixed(1), "X")));
91
+ };
@@ -0,0 +1,20 @@
1
+ .ipc-player-plugin-realtime-magnification {
2
+ background-color: rgba(255, 255, 255, 0.3);
3
+ padding: calc(4px * var(--ipc-player-size-scale, 1)) calc(5px * var(--ipc-player-size-scale, 1));
4
+ display: flex;
5
+ justify-content: center;
6
+ align-items: center;
7
+ border-radius: calc(4px * var(--ipc-player-size-scale, 1));
8
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
9
+ overflow: hidden;
10
+ .magnificationText {
11
+ color: var(--iconColor);
12
+ font-weight: 600;
13
+ font-size: calc(12px * var(--ipc-player-size-scale, 1));
14
+ }
15
+ }
16
+ .ipc-player-plugin-realtime-magnification-full {
17
+ padding-left: calc(8px * var(--ipc-player-size-scale, 1));
18
+ padding-right: calc(8px * var(--ipc-player-size-scale, 1));
19
+ border-radius: calc(5px * var(--ipc-player-size-scale, 1));
20
+ }