@ray-js/ipc-player-integration 0.0.1-beta-34 → 0.0.1-beta-36

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/lib/ctx/ctx.js CHANGED
@@ -3,6 +3,7 @@ import Strings from '../i18n';
3
3
  import { useAtom, updateAtom, getDefaultStore, useStore } from './store';
4
4
  import { PlayState, IntercomMode } from '../interface';
5
5
  import { ClarityType } from '@ray-js/ray-ipc-utils/lib/interface';
6
+ import { getEventInstance } from './event';
6
7
  const SAVE_TO_ALBUM = 1;
7
8
  export const createUseCtx = _ref => {
8
9
  let {
@@ -70,6 +71,10 @@ export const createUseCtx = _ref => {
70
71
  } = useStore({
71
72
  _playState: playState
72
73
  });
74
+ const eventRef = useRef();
75
+ if (!eventRef.current) {
76
+ eventRef.current = getEventInstance();
77
+ }
73
78
  useEffect(() => {
74
79
  if (devId && _playState === PlayState.PLAYING) {
75
80
  // 获取缓存的值且同步
@@ -335,7 +340,8 @@ export const createUseCtx = _ref => {
335
340
  getStreamStatus: () => {
336
341
  return streamStatus.current;
337
342
  },
338
- toast
343
+ toast,
344
+ event: eventRef.current
339
345
  };
340
346
  };
341
347
  };
@@ -0,0 +1,8 @@
1
+ type Task = (...args: any[]) => void;
2
+ export type EventInstance = {
3
+ on: (type: string, cb: Task) => void;
4
+ off: (type: string, cb: Task) => void;
5
+ emit: (type: string, ...args: any[]) => void;
6
+ };
7
+ export declare function getEventInstance(): EventInstance;
8
+ export {};
@@ -0,0 +1,26 @@
1
+ export function getEventInstance() {
2
+ const map = {};
3
+ return {
4
+ on(type, cb) {
5
+ if (!map[type]) {
6
+ map[type] = [];
7
+ }
8
+ map[type].push(cb);
9
+ },
10
+ off(type, cb) {
11
+ if (map[type]) {
12
+ map[type] = map[type].filter(item => item !== cb);
13
+ }
14
+ },
15
+ emit(type) {
16
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
17
+ args[_key - 1] = arguments[_key];
18
+ }
19
+ if (map[type]) {
20
+ map[type].forEach(cb => {
21
+ cb && cb.apply(null, args); // eslint-disable-line
22
+ });
23
+ }
24
+ }
25
+ };
26
+ }
@@ -11,6 +11,7 @@ declare const Strings: kit.I18N<{
11
11
  ipc_player_record_success_check: string;
12
12
  ipc_player_recording_now_tip: string;
13
13
  ipc_player_stop_recording_err: string;
14
+ ipc_player_resolution_change_error: string;
14
15
  };
15
16
  zh: {
16
17
  ipc_player_resolution_HD: string;
@@ -23,6 +24,7 @@ declare const Strings: kit.I18N<{
23
24
  ipc_player_record_success_check: string;
24
25
  ipc_player_recording_now_tip: string;
25
26
  ipc_player_stop_recording_err: string;
27
+ ipc_player_resolution_change_error: string;
26
28
  };
27
29
  }, {
28
30
  ipc_player_resolution_HD: string;
@@ -35,6 +37,7 @@ declare const Strings: kit.I18N<{
35
37
  ipc_player_record_success_check: string;
36
38
  ipc_player_recording_now_tip: string;
37
39
  ipc_player_stop_recording_err: string;
40
+ ipc_player_resolution_change_error: string;
38
41
  } | {
39
42
  ipc_player_resolution_HD: string;
40
43
  ipc_player_resolution_SD: string;
@@ -46,5 +49,6 @@ declare const Strings: kit.I18N<{
46
49
  ipc_player_record_success_check: string;
47
50
  ipc_player_recording_now_tip: string;
48
51
  ipc_player_stop_recording_err: string;
52
+ ipc_player_resolution_change_error: string;
49
53
  }>;
50
54
  export default Strings;
@@ -10,6 +10,7 @@ declare const _default: {
10
10
  ipc_player_record_success_check: string;
11
11
  ipc_player_recording_now_tip: string;
12
12
  ipc_player_stop_recording_err: string;
13
+ ipc_player_resolution_change_error: string;
13
14
  };
14
15
  zh: {
15
16
  ipc_player_resolution_HD: string;
@@ -22,6 +23,7 @@ declare const _default: {
22
23
  ipc_player_record_success_check: string;
23
24
  ipc_player_recording_now_tip: string;
24
25
  ipc_player_stop_recording_err: string;
26
+ ipc_player_resolution_change_error: string;
25
27
  };
26
28
  };
27
29
  export default _default;
@@ -9,7 +9,8 @@ export default {
9
9
  ipc_player_shot_success_check: 'View',
10
10
  ipc_player_record_success_check: 'View',
11
11
  ipc_player_recording_now_tip: 'Recording in progress...',
12
- ipc_player_stop_recording_err: 'Failed to stop recording. Please exit and try again.'
12
+ ipc_player_stop_recording_err: 'Failed to stop recording. Please exit and try again.',
13
+ ipc_player_resolution_change_error: 'Switch failed, check device and network.'
13
14
  },
14
15
  zh: {
15
16
  ipc_player_resolution_HD: '高清',
@@ -21,6 +22,7 @@ export default {
21
22
  ipc_player_shot_success_check: '查看',
22
23
  ipc_player_record_success_check: '查看',
23
24
  ipc_player_recording_now_tip: '正在录像中...',
24
- ipc_player_stop_recording_err: '结束录像失败,请退出重试'
25
+ ipc_player_stop_recording_err: '结束录像失败,请退出重试',
26
+ ipc_player_resolution_change_error: '切换失败,请检查设备及网络状态'
25
27
  }
26
28
  };
@@ -25,6 +25,12 @@ export declare const enum PlayState {
25
25
  PAUSE = 2
26
26
  }
27
27
  export type ContentPlaceType = 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight' | 'absolute';
28
+ type Task = (...args: any[]) => void;
29
+ export type EventInstance = {
30
+ on: (type: string, cb: Task) => void;
31
+ off: (type: string, cb: Task) => void;
32
+ emit: (type: string, ...args: any[]) => void;
33
+ };
28
34
  export type UseCtx = (options: {
29
35
  devId: string;
30
36
  initTopLeftContent?: ComponentConfig[];
@@ -71,6 +77,7 @@ export type UseCtx = (options: {
71
77
  hideContent: (type: ContentPlaceType, id: string) => void;
72
78
  showContent: (type: ContentPlaceType, id: string) => void;
73
79
  toast: Toast;
80
+ event: EventInstance;
74
81
  };
75
82
  export type ComponentConfig<T = ReturnType<UseCtx> & Record<string, any>> = {
76
83
  id: string;
@@ -39,6 +39,7 @@ export declare const Battery: import("react").FunctionComponent<{
39
39
  hideContent: (type: import("../..").ContentPlaceType, id: string) => void;
40
40
  showContent: (type: import("../..").ContentPlaceType, id: string) => void;
41
41
  toast: import("../../ports.output").Toast;
42
+ event: import("../../interface").EventInstance;
42
43
  } & {
43
44
  className?: string | undefined;
44
45
  }>;
@@ -82,6 +83,7 @@ export declare const BatteryFull: import("react").FunctionComponent<{
82
83
  hideContent: (type: import("../..").ContentPlaceType, id: string) => void;
83
84
  showContent: (type: import("../..").ContentPlaceType, id: string) => void;
84
85
  toast: import("../../ports.output").Toast;
86
+ event: import("../../interface").EventInstance;
85
87
  } & {
86
88
  className?: string | undefined;
87
89
  }>;
@@ -4,9 +4,8 @@
4
4
  height: calc(24px * var(--ipc-player-size-scale, 1));
5
5
  padding: 0 calc(9px * var(--ipc-player-size-scale, 1));
6
6
  border-radius: calc(24px * var(--ipc-player-size-scale, 1));
7
- background-color: rgba(255, 255, 255, 0.3);
7
+ background-color: rgba(255, 255, 255, 0.2);
8
8
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
9
- // backdrop-filter: blur(10px);
10
9
 
11
10
  .ipc-player-plugin-battery-border {
12
11
  position: relative;
@@ -93,19 +93,17 @@ export function FullScreen(props) {
93
93
  handleFull();
94
94
  },
95
95
  vertical: () => {
96
- event.emit(pauseTimeToHideAllComponent);
97
96
  ty.setNavigationBarBack({
98
97
  type: 'system'
99
98
  });
100
- ty.showMenuButton();
101
- ty.showStatusBar();
102
99
  event.emit(pauseTimeToHideAllComponent);
103
- deleteContent('topLeft', verticalScreenId);
104
100
  deleteContent('absolute', voiceIntercomId);
105
101
  deleteContent('absolute', ptzControlId);
102
+ deleteContent('topLeft', verticalScreenId);
106
103
  deleteContent('absolute', fullResolutionId);
107
104
  deleteContent('absolute', fullTravelRouteControlId);
108
- // 还原全屏清晰度状态值
105
+ ty.showMenuButton();
106
+ ty.showStatusBar();
109
107
  }
110
108
  };
111
109
  useUpdateEffect(() => {
@@ -47,7 +47,14 @@ export const FullResolutionControl = props => {
47
47
  title: Strings.getLang('ipc_player_current_resolution_is_equal')
48
48
  });
49
49
  } else {
50
- setResolution(value);
50
+ setResolution(value).then(() => {
51
+ setHide(true);
52
+ }).catch(() => {
53
+ ty.showToast({
54
+ icon: 'error',
55
+ title: Strings.getLang('ipc_player_resolution_change_error')
56
+ });
57
+ });
51
58
  }
52
59
  }, [resolution]);
53
60
  return /*#__PURE__*/React.createElement(View, {
@@ -48,9 +48,9 @@ export const TempHumidity = props => {
48
48
  className: clsx('ipc-player-plugin-tempHumidity')
49
49
  }, (() => {
50
50
  if ((tempC || tempUnit === '1' && tempF) && humidity) {
51
- return /*#__PURE__*/React.createElement(React.Fragment, null, tempRender(), /*#__PURE__*/React.createElement(Text, {
51
+ return /*#__PURE__*/React.createElement(React.Fragment, null, tempRender(), /*#__PURE__*/React.createElement(View, {
52
52
  className: "ipc-player-plugin-tempHumidity-divider"
53
- }, "/"), humRender());
53
+ }), humRender());
54
54
  }
55
55
  if (tempC || tempUnit === '1' && tempF) {
56
56
  return /*#__PURE__*/React.createElement(React.Fragment, null, tempRender());
@@ -6,13 +6,16 @@
6
6
  border-radius: calc(24px * var(--ipc-player-size-scale, 1));
7
7
  color: var(--iconColor);
8
8
  font-size: calc(12px * var(--ipc-player-size-scale, 1));
9
- background-color: rgba(255, 255, 255, 0.3);
9
+ background-color: rgba(255, 255, 255, 0.2);
10
10
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
11
11
  }
12
12
 
13
13
  .ipc-player-plugin-tempHumidity-divider {
14
- margin: calc(4px * var(--ipc-player-size-scale, 1));
15
- color: var(--iconColor);
14
+ margin: calc(6px * var(--ipc-player-size-scale, 1));
15
+ color: rgba(0,0,0,0.2);
16
+ width: calc(1px * var(--ipc-player-size-scale, 1));
17
+ height: calc(12px * var(--ipc-player-size-scale, 1));
18
+ background-color: rgba(255, 255, 255, 0.2);
16
19
  }
17
20
 
18
21
  // .text-icon-tempHumidity {
@@ -6,6 +6,6 @@
6
6
  border-radius: calc(24px * var(--ipc-player-size-scale, 1));
7
7
  color: var(--iconColor);
8
8
  font-size: calc(12px * var(--ipc-player-size-scale, 1));
9
- background-color: rgba(255, 255, 255, 0.3);
9
+ background-color: rgba(255, 255, 255, 0.2);
10
10
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
11
11
  }
@@ -19,7 +19,7 @@ const BottomLeftContent = _ref => {
19
19
  className: clsx('ipc-player-bottom-left-content-wrap')
20
20
  }, /*#__PURE__*/React.createElement(View, {
21
21
  style: {
22
- paddingBottom: screenType === 'vertical' ? '14px' : '20px',
22
+ paddingBottom: screenType === 'vertical' ? '14px' : '32px',
23
23
  paddingLeft: screenType === 'vertical' ? 0 : '25px'
24
24
  },
25
25
  className: clsx('ipc-player-bottom-left-content-container', {
@@ -19,7 +19,7 @@ const BottomRightContent = _ref => {
19
19
  className: clsx('ipc-player-bottom-right-content-wrap')
20
20
  }, /*#__PURE__*/React.createElement(View, {
21
21
  style: {
22
- paddingBottom: screenType === 'vertical' ? '14px' : '20px',
22
+ paddingBottom: screenType === 'vertical' ? '14px' : '32px',
23
23
  paddingRight: screenType === 'vertical' ? 0 : '25px'
24
24
  },
25
25
  className: clsx('ipc-player-bottom-right-content-container', {
package/lib/ui/ui.js CHANGED
@@ -1,12 +1,11 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
- import React, { useContext, useState, useRef, useMemo, useEffect, useImperativeHandle } from 'react';
2
+ import React, { useState, useRef, useMemo, useEffect, useImperativeHandle } from 'react';
3
3
  import { View, CoverView, getSystemInfoSync, usePageEvent } from '@ray-js/ray';
4
4
  import clsx from 'clsx';
5
5
  import IPCPlayer from '@ray-js/ray-ipc-player';
6
6
  import { PlayState, PlayerStreamStatus } from '../interface';
7
7
  import { useCtx } from '../ctx/ctx.composition';
8
8
  import { useStore } from '../ctx/store';
9
- import { getEventInstance } from './event';
10
9
  import { UIEventContext } from './context';
11
10
  import { showAllComponent, hideAllComponent, playerTap, startTimeToHideAllComponent, pauseTimeToHideAllComponent } from './constant';
12
11
  import BottomLeftContent from './bottomLeftContent';
@@ -67,19 +66,16 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
67
66
  */
68
67
  const [componentHideState, setComponentHideState] = useState(false);
69
68
  prevTriggerEvent.current = componentHideState ? hideAllComponent : showAllComponent;
70
- const eventRef = useRef();
69
+ const eventRef = useRef(instance.event);
70
+ if (eventRef.current !== instance.event) {
71
+ eventRef.current = instance.event;
72
+ }
71
73
  useImperativeHandle(eventRefProp, () => eventRef.current, [eventRef.current]);
72
74
  const timer = useRef();
73
- if (!eventRef.current) {
74
- eventRef.current = getEventInstance();
75
- }
76
75
  useEffect(() => {
77
76
  setBrandColor(brandColor);
78
77
  setVerticalMic(verticalMic);
79
78
  }, []);
80
- const {
81
- event
82
- } = useContext(UIEventContext);
83
79
 
84
80
  /**
85
81
  * 监听屏幕布局变化
@@ -159,9 +155,11 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
159
155
  }, instance), {}, {
160
156
  IPCPlayerContext: instance.IPCPlayerInstance,
161
157
  // 添加通用变量单独组件类名
162
- className: clsx('bottom-left-item-container')
158
+ className: clsx('bottom-left-item-container', {
159
+ 'bottom-left-item-full-container': screenType === 'full'
160
+ })
163
161
  })));
164
- }, [bottomLeftContent, instance]);
162
+ }, [bottomLeftContent, instance, screenType]);
165
163
 
166
164
  /**
167
165
  * 渲染播放器右下角内容
@@ -181,6 +179,10 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
181
179
  * 视频流加载状态封装
182
180
  */
183
181
 
182
+ const disablePlayerTap = useRef(false);
183
+ const handDisablePlayerTap = value => {
184
+ disablePlayerTap.current = !!value;
185
+ };
184
186
  const triggerEvent = type => {
185
187
  if (prevTriggerEvent.current === type) return;
186
188
  if (timer.current) {
@@ -220,11 +222,13 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
220
222
  eventRef.current.on(pauseTimeToHideAllComponent, listenPause);
221
223
  eventRef.current.on(showAllComponent, listenShowEvent);
222
224
  eventRef.current.on(hideAllComponent, listenHideEvent);
225
+ eventRef.current.on('disablePlayerTap', handDisablePlayerTap);
223
226
  return () => {
224
227
  eventRef.current.off(startTimeToHideAllComponent, listenStart);
225
228
  eventRef.current.off(pauseTimeToHideAllComponent, listenPause);
226
229
  eventRef.current.off(showAllComponent, listenShowEvent);
227
230
  eventRef.current.off(hideAllComponent, listenHideEvent);
231
+ eventRef.current.off('disablePlayerTap', handDisablePlayerTap);
228
232
  };
229
233
  }, []);
230
234
  const playerReady = playState === PlayState.PLAYING;
@@ -284,6 +288,10 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
284
288
  clarity: resolution === 'HD' ? 'hd' : 'normal',
285
289
  privateState: privateState,
286
290
  onPlayerTap: data => {
291
+ if (disablePlayerTap.current) {
292
+ console.log('playerTap 事件已禁止');
293
+ return;
294
+ }
287
295
  console.log('res===on onVideoTap', data);
288
296
  eventRef.current.emit(playerTap);
289
297
  console.log(prevTriggerEvent.current, 'prevTriggerEvent.current');
@@ -292,7 +300,7 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
292
300
  } else {
293
301
  triggerEvent(hideAllComponent);
294
302
  }
295
- return false;
303
+ return false; // eslint-disable-line
296
304
  } // 对应原来的onVideoTap
297
305
  }), /*#__PURE__*/React.createElement(View, {
298
306
  className: clsx('ipc-player-top-content', {
@@ -312,7 +320,7 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
312
320
  'ipc-player-bottom-content-show': !componentHideState
313
321
  }),
314
322
  style: {
315
- height: screenType === 'vertical' ? '48px' : '60px'
323
+ height: screenType === 'vertical' ? '48px' : '72px'
316
324
  }
317
325
  }, /*#__PURE__*/React.createElement(BottomLeftContent, {
318
326
  ctx: instance
package/lib/ui/ui.less CHANGED
@@ -203,6 +203,21 @@
203
203
  padding: 0 0 0 16px;
204
204
  }
205
205
 
206
+ // 左下角全屏子元素容器
207
+ .bottom-left-item-full-container {
208
+ padding: 0 24px !important;
209
+ }
210
+
211
+ .bottom-left-item-full-container:first-of-type {
212
+ padding: 0 24px 0 16px !important;
213
+ }
214
+ .bottom-left-item-full-container:last-of-type {
215
+ padding: 0 0 0 24px !important;
216
+ }
217
+ .bottom-left-item-full-container:only-of-type{
218
+ padding: 0 0 0 16px !important;
219
+ }
220
+
206
221
  // 右下角子元素容器
207
222
  .bottom-right-item-container {
208
223
  padding: 0 8px;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/ipc-player-integration",
3
- "version": "0.0.1-beta-34",
3
+ "version": "0.0.1-beta-36",
4
4
  "description": "IPC 播放器功能集成",
5
5
  "main": "lib/index",
6
6
  "files": [
@@ -36,7 +36,7 @@
36
36
  "ahooks": "^3.1.6"
37
37
  },
38
38
  "dependencies": {
39
- "@ray-js/ipc-ptz-zoom": "0.0.2-beta-4",
39
+ "@ray-js/ipc-ptz-zoom": "0.0.2-beta-5",
40
40
  "@ray-js/panel-sdk": "^1.13.1",
41
41
  "@ray-js/ray-ipc-player": "2.0.20-beta-6",
42
42
  "@ray-js/ray-ipc-utils": "1.1.0-beta-13",