@ray-js/ipc-player-integration 0.0.1-beta-45 → 0.0.1-beta-47

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
@@ -80,7 +80,9 @@ export const createUseCtx = _ref => {
80
80
  eventRef.current = getEventInstance();
81
81
  }
82
82
  useEffect(() => {
83
+ console.log('========================+++++');
83
84
  if (devId && _playState === PlayState.PLAYING) {
85
+ console.log('===================');
84
86
  // 获取缓存的值且同步
85
87
  getMemoryState(devId).then(res => {
86
88
  console.log('==== getMemoryState ====', res);
@@ -4,3 +4,4 @@ export * from './useTemperature';
4
4
  export * from './useDpState';
5
5
  export * from './useMemoizedFn';
6
6
  export * from './usePtz';
7
+ export * from './useSchemaInfo.tsx';
@@ -3,4 +3,5 @@ export * from './useHumidity';
3
3
  export * from './useTemperature';
4
4
  export * from './useDpState';
5
5
  export * from './useMemoizedFn';
6
- export * from './usePtz';
6
+ export * from './usePtz';
7
+ export * from './useSchemaInfo.tsx';
@@ -0,0 +1,2 @@
1
+ import { Schema } from '../../utils/device';
2
+ export declare function useSchemaInfo<T extends string>(devId: string, dpCodes: T[]): [Record<T, Schema> | null];
@@ -0,0 +1,17 @@
1
+ import { useState, useEffect } from 'react';
2
+ import { getDpSchemaByCodes, getDpSchemaByCodesSync } from '../../utils/device';
3
+ export function useSchemaInfo(devId, dpCodes) {
4
+ const [schemaInfo, setSchemaInfo] = useState(() => {
5
+ const info = getDpSchemaByCodesSync(devId, dpCodes);
6
+ if (info) return info;
7
+ return null;
8
+ });
9
+ useEffect(() => {
10
+ if (!schemaInfo) {
11
+ getDpSchemaByCodes(devId, dpCodes).then(res => {
12
+ setSchemaInfo(res);
13
+ });
14
+ }
15
+ }, [schemaInfo]);
16
+ return [schemaInfo];
17
+ }
@@ -39,7 +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
+ event: import("../..").EventInstance;
43
43
  } & {
44
44
  className?: string | undefined;
45
45
  }>;
@@ -83,7 +83,7 @@ export declare const BatteryFull: import("react").FunctionComponent<{
83
83
  hideContent: (type: import("../..").ContentPlaceType, id: string) => void;
84
84
  showContent: (type: import("../..").ContentPlaceType, id: string) => void;
85
85
  toast: import("../../ports.output").Toast;
86
- event: import("../../interface").EventInstance;
86
+ event: import("../..").EventInstance;
87
87
  } & {
88
88
  className?: string | undefined;
89
89
  }>;
@@ -124,7 +124,7 @@ export function FullScreen(props) {
124
124
  if (screenType === 'full' || hideHorizontalMenu) return null;
125
125
  return /*#__PURE__*/React.createElement(View, {
126
126
  className: clsx(className),
127
- onClick: () => handClick('full')
127
+ onTouchStart: () => handClick('full')
128
128
  }, /*#__PURE__*/React.createElement(Text, {
129
129
  className: clsx('icon-panel', 'icon-panel-landscape', 'ipc-player-plugin-full-screen')
130
130
  }));
@@ -12,6 +12,7 @@ import { useDpState } from '../../hooks';
12
12
  import { useComponentHideState } from '../../ui/hooks';
13
13
  import { pauseTimeToHideAllComponent, startTimeToHideAllComponent } from '../../ui/constant';
14
14
  import { DIRECTION_CONTROL_DP_CODE } from './constant';
15
+ import { useStore } from '../../ctx/store';
15
16
  export function FullTravelRouteControl(props) {
16
17
  const [shouldHide] = useComponentHideState();
17
18
  const [isPtzActive, setIsPtzActive] = useState(false);
@@ -19,6 +20,11 @@ export function FullTravelRouteControl(props) {
19
20
  event
20
21
  } = useContext(UIEventContext);
21
22
  const prevRotate = useRef('-1');
23
+ const {
24
+ brandColor
25
+ } = useStore({
26
+ brandColor: props.brandColor
27
+ });
22
28
  const [state, _, sendDp] = useDpState({
23
29
  devId: props.devId,
24
30
  dpCodes: [DIRECTION_CONTROL_DP_CODE],
@@ -38,6 +44,10 @@ export function FullTravelRouteControl(props) {
38
44
  event.off('ptzControlHide', onPtzControlHide);
39
45
  };
40
46
  }, []);
47
+ const handTouchEnd = () => {
48
+ event.emit(startTimeToHideAllComponent);
49
+ sendDpValue('-1');
50
+ };
41
51
  const {
42
52
  run: sendDpValue
43
53
  } = useDebounceFn(value => {
@@ -65,9 +75,10 @@ export function FullTravelRouteControl(props) {
65
75
  event.emit(pauseTimeToHideAllComponent);
66
76
  sendDpValue(String(value));
67
77
  },
68
- onTouchEnd: () => {
69
- event.emit(startTimeToHideAllComponent);
70
- sendDpValue('-1');
71
- }
78
+ onTouchEnd: handTouchEnd,
79
+ onMoveNonIntersection: handTouchEnd,
80
+ showArcOnTouchInEdgeProximity: true,
81
+ arcEdgeProximityColor: brandColor,
82
+ touchDistanceThreshold: 50
72
83
  }));
73
84
  }
@@ -1,12 +1,27 @@
1
- import React, { useCallback, useContext, useEffect, useState } from 'react';
1
+ import "core-js/modules/esnext.iterator.constructor.js";
2
+ import "core-js/modules/esnext.iterator.map.js";
3
+ import React, { useCallback, useContext, useEffect, useState, useMemo } from 'react';
2
4
  import clsx from 'clsx';
3
5
  import { MoveInterActiveControlUI } from './moveInteractiveControlUI';
4
6
  import { playerTap, showAllComponent } from '../../ui/constant';
5
- import { useDpState } from '../../hooks';
7
+ import { useDpState, useSchemaInfo } from '../../hooks';
6
8
  import { UIEventContext } from '../../ui/context';
7
9
  import './moveInteractiveControl.less';
8
10
  const TYPE_CODE = 'ipc_manual_petting';
9
11
  const STATE_CODE = 'ipc_manual_petting_state';
12
+ const iconMap = {
13
+ '0': 'icon-panel-move-control-rotate-place',
14
+ '1': 'icon-panel-move-control-straight-line',
15
+ '2': 'icon-panel-move-control-8',
16
+ '3': 'icon-panel-move-control-rotation',
17
+ '4': 'icon-panel-move-control-big-rotation',
18
+ '5': 'icon-panel-move-control-z',
19
+ '6': 'icon-panel-move-control-wave',
20
+ '7': 'icon-panel-move-control-p-steering',
21
+ '8': 'icon-panel-move-control-chacha',
22
+ '9': 'icon-panel-tange1',
23
+ '10': 'icon-panel-move-control-waltz'
24
+ };
10
25
  export function MoveInteractiveControl(props) {
11
26
  const {
12
27
  devId
@@ -17,6 +32,17 @@ export function MoveInteractiveControl(props) {
17
32
  listenDpChange: false
18
33
  });
19
34
  console.log('state', state);
35
+ const [schemaInfo] = useSchemaInfo(devId, [TYPE_CODE]);
36
+ const menu = useMemo(() => {
37
+ if (!schemaInfo || !(schemaInfo !== null && schemaInfo !== void 0 && schemaInfo[TYPE_CODE])) {
38
+ return [];
39
+ }
40
+ return schemaInfo[TYPE_CODE].property.range.map(key => ({
41
+ key,
42
+ label: I18n.t(`dp_ipc_manual_petting_${key}`),
43
+ iconName: iconMap[key]
44
+ }));
45
+ }, [schemaInfo]);
20
46
  const {
21
47
  event
22
48
  } = useContext(UIEventContext);
@@ -40,6 +66,7 @@ export function MoveInteractiveControl(props) {
40
66
  wrapClsName: clsx('ipc-player-plugin-move-control', {
41
67
  'ipc-player-plugin-move-control-hide': hide
42
68
  }),
69
+ menu: menu,
43
70
  onClick: value => {
44
71
  sendDp({
45
72
  [TYPE_CODE]: value
@@ -70,7 +70,8 @@ export function MoveInterActiveControlUI(props) {
70
70
  activeKey,
71
71
  onClick
72
72
  } = props;
73
- const handClick = item => {
73
+ const handClick = (item, e) => {
74
+ e.origin.stopPropagation();
74
75
  onClick && onClick(item.key);
75
76
  };
76
77
  return /*#__PURE__*/React.createElement(View
@@ -88,7 +89,7 @@ export function MoveInterActiveControlUI(props) {
88
89
  }, /*#__PURE__*/React.createElement(View, {
89
90
  className: clsx('ipc-player-plugin-active-control', contentClsName)
90
91
  }, menu.map(item => /*#__PURE__*/React.createElement(View, {
91
- onClick: () => handClick(item),
92
+ onClick: e => handClick(item, e),
92
93
  key: item.key,
93
94
  className: clsx('ipc-player-plugin-active-control-item', {
94
95
  'ipc-player-plugin-active-control-item-active': activeKey === item.key
@@ -29,7 +29,9 @@ export const Resolution = props => {
29
29
  event
30
30
  } = useContext(UIEventContext);
31
31
  const onResolution = useMemoizedFn(() => {
32
+ console.log('你触发了高标清点击了吗');
32
33
  event.emit('resolutionBtnControlClick');
34
+ console.log(`screenType: ${screenType}`);
33
35
  if (screenType === 'full') {
34
36
  event.emit(hideAllComponent);
35
37
  if (hasContent('absolute', fullResolutionId)) {
@@ -55,11 +57,12 @@ export const Resolution = props => {
55
57
  });
56
58
  return /*#__PURE__*/React.createElement(View, {
57
59
  onClick: onResolution,
58
- className: clsx(className, screenType === 'vertical' ? 'ipc-player-plugin-resolution-vertical' : 'ipc-player-plugin-resolution-full')
60
+ className: clsx(className)
59
61
  }, /*#__PURE__*/React.createElement(View, {
60
62
  className: clsx('ipc-player-plugin-resolution', {
61
63
  'ipc-player-plugin-resolution-full': screenType === 'full'
62
- })
64
+ }),
65
+ onClick: onResolution
63
66
  }, /*#__PURE__*/React.createElement(Text, {
64
67
  className: "resolutionText"
65
68
  }, Strings.getLang(`ipc_player_resolution_${resolution}`))));
@@ -71,14 +71,8 @@ export const VoiceIntercom = props => {
71
71
  };
72
72
  const endVoice = async () => {
73
73
  console.log('=== 结束对讲 ====');
74
- // 单向对讲,结束对讲之后,强制关闭静态状态
75
- if (intercomMode === IntercomMode.OneWay) {
76
- console.log('=== 单向对讲,强制关闭静音状态 ===');
77
- await setMute(false);
78
- } else {
79
- console.log(`=== 双向对讲,恢复对讲之前的静音状态 ${originMuteStatusBeforeVoice.current}===`);
80
- await setMute(originMuteStatusBeforeVoice.current);
81
- }
74
+ // 对讲结束之后,统一关闭静态状态
75
+ await setMute(false);
82
76
  await setIntercom(false);
83
77
  event.emit(startTimeToHideAllComponent);
84
78
  };
package/lib/ui/event.d.ts CHANGED
@@ -1,8 +1,2 @@
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
- };
1
+ import { EventInstance } from '../interface';
7
2
  export declare function getEventInstance(): EventInstance;
8
- export {};
package/lib/ui/ui.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import React from 'react';
2
- import { PlayStatusData, UseCtx } from '../interface';
3
- import { EventInstance } from './event';
2
+ import { PlayStatusData, UseCtx, EventInstance } from '../interface';
4
3
  import './ui.less';
5
4
  type CtxInstance = ReturnType<UseCtx>;
6
5
  type CSSVariable = {
@@ -26,6 +25,8 @@ type Props = {
26
25
  brandColor?: string;
27
26
  verticalMic?: boolean;
28
27
  eventRef?: React.RefObject<EventInstance>;
28
+ onPlayerTap?: (data: any) => void;
29
+ extend?: Record<string, any>;
29
30
  };
30
31
  export declare const IPCPlayerIntegration: React.MemoExoticComponent<(props: Props) => React.JSX.Element>;
31
32
  export {};
package/lib/ui/ui.js CHANGED
@@ -1,3 +1,4 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
1
2
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
3
  import "core-js/modules/esnext.iterator.constructor.js";
3
4
  import "core-js/modules/esnext.iterator.map.js";
@@ -49,7 +50,9 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
49
50
  deviceOnline = true,
50
51
  brandColor = '#FF592A',
51
52
  verticalMic = true,
52
- eventRef: eventRefProp
53
+ eventRef: eventRefProp,
54
+ onPlayerTap,
55
+ extend = {}
53
56
  } = props;
54
57
  const instance = getCtxInstance(props.instance, devId);
55
58
  const {
@@ -258,7 +261,7 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
258
261
  // backgroundColor: 'rgba(0,0,0,0.2)',
259
262
  height: screenType === 'vertical' ? (style === null || style === void 0 ? void 0 : style.height) || '100%' : '100vh'
260
263
  })
261
- }, /*#__PURE__*/React.createElement(IPCPlayer, {
264
+ }, /*#__PURE__*/React.createElement(IPCPlayer, _extends({
262
265
  objectFit: "",
263
266
  defaultMute: mute,
264
267
  devId: devId,
@@ -266,16 +269,14 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
266
269
  ipcPlayerContext: instance.IPCPlayerInstance,
267
270
  onChangeStreamStatus: code => {
268
271
  var _props$onPlayStatus;
269
- console.log(code, 'code');
270
272
  const playStateMap = {
271
273
  [PlayerStreamStatus.PreviewSuccess]: PlayState.PLAYING,
272
274
  // 播放中
273
275
  [PlayerStreamStatus.PAUSE]: PlayState.PAUSE // 暂停
274
276
  };
275
- const playState = playStateMap[code];
276
- if (typeof playState !== 'undefined') {
277
- setPlayState(playState);
278
- }
277
+ // 合并为三种状态 连接中 暂停 播放中
278
+ const playState = playStateMap[code] || PlayState.CONNECTING;
279
+ setPlayState(playState);
279
280
  (_props$onPlayStatus = props.onPlayStatus) === null || _props$onPlayStatus === void 0 || _props$onPlayStatus.call(props, {
280
281
  playState,
281
282
  playCode: code
@@ -285,18 +286,6 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
285
286
  // onCtx={getIpcPlayer}
286
287
  // onPlayerTap={handlePlayerClick}
287
288
  ,
288
- onZoomChange: data => {
289
- console.log(`zoomChange事件: ${JSON.stringify(data)}`);
290
- },
291
- onCameraPreviewFailure: data => {
292
- console.log(`onCameraPreviewFailure事件: ${JSON.stringify(data)}`);
293
- // ty.showToast({
294
- // title: `onCameraPreviewFailure事件: ${JSON.stringify(data)}`,
295
- // });
296
- // setTimeout(() => {
297
- // ty.hideToast();
298
- // }, 3000);
299
- },
300
289
  onCameraNotifyWeakNetwork: data => {
301
290
  console.log(`onCameraNotifyWeakNetwork: ${JSON.stringify(data)}`);
302
291
  },
@@ -306,10 +295,11 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
306
295
  ptzControllable: screenType === 'vertical',
307
296
  privateState: privateState,
308
297
  onPlayerTap: data => {
309
- if (disablePlayerTap.current) {
310
- console.log('playerTap 事件已禁止');
311
- return;
312
- }
298
+ onPlayerTap(data);
299
+ // if (disablePlayerTap.current) {
300
+ // console.log('playerTap 事件已禁止');
301
+ // return;
302
+ // }
313
303
  console.log('res===on onVideoTap', data);
314
304
  eventRef.current.emit(playerTap);
315
305
  console.log(prevTriggerEvent.current, 'prevTriggerEvent.current');
@@ -318,11 +308,12 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
318
308
  } else {
319
309
  triggerEvent(hideAllComponent);
320
310
  }
311
+ // onPlayerTap(data);
321
312
  return false; // eslint-disable-line
322
313
  } // 对应原来的onVideoTap
323
314
  ,
324
315
  brandColor: brandColor
325
- }), /*#__PURE__*/React.createElement(View, {
316
+ }, extend)), /*#__PURE__*/React.createElement(View, {
326
317
  className: clsx('ipc-player-top-content', {
327
318
  'ipc-player-top-content-hide': componentHideState,
328
319
  'ipc-player-top-content-show': !componentHideState
@@ -43,27 +43,41 @@ export function getDeviceInfo(devId) {
43
43
  });
44
44
  });
45
45
  }
46
- export function getDpIdsByCodes(devId) {
47
- return new Promise((resolve, reject) => {
48
- ty.device.getDeviceInfo({
49
- deviceId: devId,
50
- success: res => {
51
- console.log('res', res);
52
- // console.log('res', res);
53
- // const { dps } = res;
54
- // // @ts-ignore
55
- // const ret: Record<T, any> = {};
56
- // options.dps.forEach(dpId => {
57
- // ret[dpId] = dps[dpId];
58
- // });
59
- // resolve(ret);
60
- },
61
- fail: err => {
62
- reject(err); // eslint-disable-line
46
+ const memorySchema = {};
47
+ export function getDpSchemaByCodes(devId, dpCodes) {
48
+ return new Promise(resolve => {
49
+ const ret = {};
50
+ if (memorySchema[devId]) {
51
+ dpCodes.forEach(code => {
52
+ ret[code] = memorySchema[devId][code];
53
+ });
54
+ resolve(ret);
55
+ return;
56
+ }
57
+ getDeviceInfo(devId).then(res => {
58
+ if (!memorySchema[devId]) {
59
+ memorySchema[devId] = {};
60
+ res.schema.forEach(item => {
61
+ memorySchema[devId][item.code] = item;
62
+ });
63
63
  }
64
+ dpCodes.forEach(code => {
65
+ ret[code] = memorySchema[devId][code];
66
+ });
67
+ resolve(ret);
64
68
  });
65
69
  });
66
70
  }
71
+ export function getDpSchemaByCodesSync(devId, dpCodes) {
72
+ const ret = {};
73
+ if (memorySchema[devId]) {
74
+ dpCodes.forEach(code => {
75
+ ret[code] = memorySchema[devId][code];
76
+ });
77
+ return ret;
78
+ }
79
+ return null;
80
+ }
67
81
  export const showMathPowValue = (value, scale) => {
68
82
  if (isNaN(Number(value))) {
69
83
  return 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/ipc-player-integration",
3
- "version": "0.0.1-beta-45",
3
+ "version": "0.0.1-beta-47",
4
4
  "description": "IPC 播放器功能集成",
5
5
  "main": "lib/index",
6
6
  "files": [
@@ -32,7 +32,7 @@
32
32
  "test": "yarn jest"
33
33
  },
34
34
  "peerDependencies": {
35
- "@ray-js/direction-control": "0.0.3-beta-1",
35
+ "@ray-js/direction-control": "0.0.7-beta-3",
36
36
  "ahooks": "^3.1.6"
37
37
  },
38
38
  "dependencies": {
@@ -48,7 +48,7 @@
48
48
  "@commitlint/cli": "^7.2.1",
49
49
  "@commitlint/config-conventional": "^9.0.1",
50
50
  "@ray-js/cli": "^1.4.9",
51
- "@ray-js/direction-control": "0.0.3-beta-1",
51
+ "@ray-js/direction-control": "0.0.7-beta-3",
52
52
  "@ray-js/ray": "^1.4.9",
53
53
  "@testing-library/react-hooks": "^8.0.1",
54
54
  "@types/jest": "^29.5.14",