@ray-js/ipc-player-integration 0.0.1-beta-54 → 0.0.1-beta-56

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.
@@ -68,7 +68,8 @@ const getMemoryState = devId => {
68
68
  mute: true,
69
69
  intercomMode: IntercomMode.TwoWay,
70
70
  resolution: ClarityType.HD,
71
- resolutionList: [ClarityType.HD, ClarityType.SD]
71
+ resolutionList: [ClarityType.HD, ClarityType.SD],
72
+ isIntercomSupported: false
72
73
  };
73
74
  return new Promise(resolve => {
74
75
  IPCUtils.getCameraConfigInfo(devId).then(res => {
@@ -79,6 +80,7 @@ const getMemoryState = devId => {
79
80
  return resolve({
80
81
  mute: muteValue,
81
82
  intercomMode: res.data.intercomInfo.cachedIntercomMode,
83
+ isIntercomSupported: res.data.intercomInfo.isIntercomSupported,
82
84
  resolution: res.data.videoResolution.cachedResolution,
83
85
  resolutionList: res.data.videoResolution.availableResolutions
84
86
  });
package/lib/ctx/ctx.js CHANGED
@@ -59,6 +59,8 @@ export const createUseCtx = _ref => {
59
59
 
60
60
  // 单向对讲还是双向对讲
61
61
  const [intercomMode, setIntercomMode] = useAtom(IntercomMode.TwoWay);
62
+ // 摄像头配置是否支持对讲
63
+ const [intercomSupported, setIntercomSupported] = useAtom(false);
62
64
 
63
65
  // 对讲中
64
66
  const [intercom] = useAtom(false);
@@ -80,15 +82,34 @@ export const createUseCtx = _ref => {
80
82
  if (!eventRef.current) {
81
83
  eventRef.current = getEventInstance();
82
84
  }
85
+ useEffect(() => {
86
+ // 初始化获取缓存值
87
+
88
+ (async () => {
89
+ if (!devId) return;
90
+ try {
91
+ const res = await getMemoryState(devId);
92
+ console.log('==== getMemoryState ====xghazh', res);
93
+ setResolutionList(res.resolutionList);
94
+ _setResolution(res.resolution, true);
95
+ _setMute(res.mute, true);
96
+ setIntercomMode(res.intercomMode);
97
+ } catch (error) {
98
+ console.error('获取 getMemoryState 失败:', error);
99
+ }
100
+ })();
101
+ }, [devId]);
83
102
  useEffect(() => {
84
103
  if (devId && _playState === PlayState.PLAYING) {
85
104
  // 获取缓存的值且同步
86
105
  getMemoryState(devId).then(res => {
87
- console.log('==== getMemoryState ====', res);
106
+ console.log('PlayingMemoryState', res);
88
107
  setResolutionList(res.resolutionList);
89
- _setResolution(res.resolution);
90
- _setMute(res.mute);
108
+ // 传true表示值即可,会取播放器的值
109
+ _setResolution(res.resolution, true);
110
+ _setMute(res.mute, true);
91
111
  setIntercomMode(res.intercomMode);
112
+ setIntercomSupported(res.isIntercomSupported);
92
113
  });
93
114
  }
94
115
  }, [devId, _playState]);
@@ -126,8 +147,13 @@ export const createUseCtx = _ref => {
126
147
  if (!IPCPlayerInstance.current) {
127
148
  IPCPlayerInstance.current = createPlayContext(devId);
128
149
  }
129
- const _setMute = async target => {
150
+ const _setMute = async function (target) {
151
+ let onlyUpdateAtom = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
130
152
  console.log(target, '_setMute====');
153
+ if (onlyUpdateAtom) {
154
+ updateAtom(mute, target);
155
+ return false;
156
+ }
131
157
  return new Promise((resolve, reject) => {
132
158
  IPCPlayerInstance.current.setMuted({
133
159
  mute: target,
@@ -155,8 +181,13 @@ export const createUseCtx = _ref => {
155
181
  * 设置清晰度
156
182
  *
157
183
  */
158
- const _setResolution = async target => {
184
+ const _setResolution = async function (target) {
185
+ let onlyUpdateAtom = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
159
186
  // target 为需要切换的清晰度
187
+ if (onlyUpdateAtom) {
188
+ updateAtom(resolution, target);
189
+ return false;
190
+ }
160
191
  return new Promise((resolve, reject) => {
161
192
  IPCPlayerInstance.current.setClarity({
162
193
  clarity: target === ClarityType.HD ? 'hd' : 'normal',
@@ -187,6 +218,7 @@ export const createUseCtx = _ref => {
187
218
  resolutionList,
188
219
  intercom,
189
220
  intercomMode,
221
+ intercomSupported,
190
222
  playState,
191
223
  setPlayState,
192
224
  setBrandColor,
@@ -44,7 +44,7 @@ export const useBattery = devId => {
44
44
  const batteryInfo = useMemo(() => {
45
45
  return {
46
46
  batteryValue: getEleValue(dpState[POWER_VALUE_DP_CODE], dpState[POWER_CALC_METHOD_DP_CODE]),
47
- batteryCharging: dpState[POWER_MODE_DP_CODE]
47
+ batteryCharging: dpState[POWER_MODE_DP_CODE] === '1'
48
48
  };
49
49
  }, [dpState]);
50
50
  return batteryInfo;
@@ -77,8 +77,9 @@ export function useDpState(options) {
77
77
  codeMapToIdRef.current = codeMapToId;
78
78
  dpCodeSchemaMapsRef.current = dpCodeSchemaMaps;
79
79
  const initValue = options.dpCodes.reduce((ret, key) => {
80
+ const currentId = codeMapToIdRef.current[key];
80
81
  return _objectSpread(_objectSpread({}, ret), {}, {
81
- [key]: res.dpCodes[key]
82
+ [key]: res.dps[currentId]
82
83
  });
83
84
  }, {});
84
85
  setValues(initValue);
@@ -53,6 +53,7 @@ export type UseCtx = (options: {
53
53
  mute: RetAtom<boolean>;
54
54
  intercom: RetAtom<boolean>;
55
55
  intercomMode: RetAtom<IntercomMode>;
56
+ intercomSupported: RetAtom<boolean>;
56
57
  resolution: RetAtom<string>;
57
58
  resolutionList: RetAtom<string[]>;
58
59
  playState: RetAtom<PlayState>;
@@ -12,6 +12,7 @@ export declare const Battery: import("react").FunctionComponent<{
12
12
  mute: import("../..").RetAtom<boolean>;
13
13
  intercom: import("../..").RetAtom<boolean>;
14
14
  intercomMode: import("../..").RetAtom<import("@ray-js/ray-ipc-utils/lib/interface").IntercomMode>;
15
+ intercomSupported: import("../..").RetAtom<boolean>;
15
16
  resolution: import("../..").RetAtom<string>;
16
17
  resolutionList: import("../..").RetAtom<string[]>;
17
18
  playState: import("../..").RetAtom<import("../..").PlayState>;
@@ -56,6 +57,7 @@ export declare const BatteryFull: import("react").FunctionComponent<{
56
57
  mute: import("../..").RetAtom<boolean>;
57
58
  intercom: import("../..").RetAtom<boolean>;
58
59
  intercomMode: import("../..").RetAtom<import("@ray-js/ray-ipc-utils/lib/interface").IntercomMode>;
60
+ intercomSupported: import("../..").RetAtom<boolean>;
59
61
  resolution: import("../..").RetAtom<string>;
60
62
  resolutionList: import("../..").RetAtom<string[]>;
61
63
  playState: import("../..").RetAtom<import("../..").PlayState>;
@@ -5,7 +5,7 @@ import { useUpdateEffect } from 'ahooks';
5
5
  import clsx from 'clsx';
6
6
  import { unstable_batchedUpdates as batchedUpdates } from '@ray-core/ray';
7
7
  import { UIEventContext } from '../../ui/context';
8
- import { showAllComponent, voiceIntercomId, verticalScreenId, fullTravelRouteControlId, ptzControlId, fullResolutionId, pauseTimeToHideAllComponent } from '../../ui/constant';
8
+ import { showAllComponent, voiceIntercomId, verticalScreenId, fullTravelRouteControlId, ptzControlId, fullResolutionId, fullSmallIntercomId, pauseTimeToHideAllComponent } from '../../ui/constant';
9
9
  import { useStore } from '../../ctx/store';
10
10
  import { VerticalScreen } from './verticalScreen';
11
11
  import { FullVoiceIntercom } from './fullVoiceIntercom';
@@ -19,6 +19,7 @@ export function FullScreen(props) {
19
19
  setScreenType,
20
20
  addContent,
21
21
  deleteContent,
22
+ hideContent,
22
23
  className,
23
24
  showContent,
24
25
  devId,
@@ -55,9 +56,16 @@ export function FullScreen(props) {
55
56
  absoluteContentClassName: 'ipc-player-plugin-vertical-screen-wrap',
56
57
  initProps: _objectSpread(_objectSpread({}, props), {}, {
57
58
  onClick: () => {
59
+ // 点击返回时提前调用一波
60
+ deleteContent('topLeft', verticalScreenId);
61
+ hideContent('bottomLeft', fullSmallIntercomId);
62
+ deleteContent('absolute', voiceIntercomId);
63
+ deleteContent('absolute', ptzControlId);
64
+ deleteContent('absolute', fullResolutionId);
65
+ deleteContent('absolute', fullTravelRouteControlId);
66
+ handClick('vertical');
58
67
  event.emit(pauseTimeToHideAllComponent);
59
68
  event.emit(showAllComponent);
60
- handClick('vertical');
61
69
  }
62
70
  })
63
71
  });
@@ -101,6 +109,7 @@ export function FullScreen(props) {
101
109
  showMenuButton();
102
110
  showStatusBar();
103
111
  deleteContent('topLeft', verticalScreenId);
112
+ hideContent('bottomLeft', fullSmallIntercomId);
104
113
  deleteContent('absolute', voiceIntercomId);
105
114
  deleteContent('absolute', ptzControlId);
106
115
  deleteContent('absolute', fullResolutionId);
@@ -4,5 +4,5 @@
4
4
  import React from 'react';
5
5
  import type { ComponentConfigProps } from '../../interface';
6
6
  type Props = ComponentConfigProps;
7
- export declare function FullVoiceIntercom(props: Props): React.JSX.Element;
7
+ export declare function FullVoiceIntercom(props: Props): React.JSX.Element | null;
8
8
  export {};
@@ -18,9 +18,11 @@ export function FullVoiceIntercom(props) {
18
18
  event
19
19
  } = useContext(UIEventContext);
20
20
  const {
21
- screenType
21
+ screenType,
22
+ intercomSupported
22
23
  } = useStore({
23
- screenType: props.screenType
24
+ screenType: props.screenType,
25
+ intercomSupported: props.intercomSupported
24
26
  });
25
27
  const onPtzControlShow = useMemoizedFn(() => {
26
28
  setIsPtzActive(true);
@@ -36,6 +38,9 @@ export function FullVoiceIntercom(props) {
36
38
  event.off('ptzControlHide', onPtzControlHide);
37
39
  };
38
40
  }, []);
41
+ if (!intercomSupported) {
42
+ return null;
43
+ }
39
44
  return /*#__PURE__*/React.createElement(View, {
40
45
  className: clsx('ipc-player-plugin-full-screen-voice', {
41
46
  'ipc-player-plugin-full-screen-voice-hide': shouldHide || isPtzActive,
@@ -13,10 +13,12 @@ export function FullSmallIntercom(props) {
13
13
  } = props;
14
14
  const {
15
15
  screenType,
16
- brandColor
16
+ brandColor,
17
+ intercomSupported
17
18
  } = useStore({
18
19
  screenType: props.screenType,
19
- brandColor: props.brandColor
20
+ brandColor: props.brandColor,
21
+ intercomSupported: props.intercomSupported
20
22
  });
21
23
  const {
22
24
  event
@@ -30,7 +32,7 @@ export function FullSmallIntercom(props) {
30
32
  const onTouchEnd = () => {
31
33
  // event.emit(startTimeToHideAllComponent);
32
34
  };
33
- if (screenType === 'full') {
35
+ if (screenType === 'full' && intercomSupported) {
34
36
  return /*#__PURE__*/React.createElement(View, {
35
37
  className: clsx(className)
36
38
  }, /*#__PURE__*/React.createElement(VoiceIntercom, _extends({}, props, {
@@ -260,17 +260,11 @@ export function RecordVideo(props) {
260
260
  }
261
261
  } catch (err) {
262
262
  console.log('录制失败', err);
263
- if ((err === null || err === void 0 ? void 0 : err.errorCode) === 7) {
264
- toast({
265
- title: Strings.getLang('ipc_player_require_record_permission')
266
- });
267
- } else {
268
- const errObj = err.innerError || err || {};
269
- const errMsg = errObj.errorMsg || Strings.getLang('ipc_player_error_record_tip');
270
- toast({
271
- title: errMsg
272
- });
273
- }
263
+ const errObj = err.innerError || err || {};
264
+ const errMsg = errObj.errorMsg || Strings.getLang('ipc_player_error_record_tip');
265
+ toast({
266
+ title: errMsg
267
+ });
274
268
  setState({
275
269
  showTimer: false
276
270
  });
@@ -14,12 +14,14 @@ export function VerticalSmallIntercom(props) {
14
14
  const {
15
15
  screenType,
16
16
  verticalMic,
17
- brandColor
17
+ brandColor,
18
+ intercomSupported
18
19
  } = useStore({
19
20
  screenType: props.screenType,
20
21
  verticalMic: props.verticalMic,
21
22
  intercomMode: props.intercomMode,
22
- brandColor: props.brandColor
23
+ brandColor: props.brandColor,
24
+ intercomSupported: props.intercomSupported
23
25
  });
24
26
  const {
25
27
  event
@@ -30,7 +32,7 @@ export function VerticalSmallIntercom(props) {
30
32
  const onTouchEnd = () => {
31
33
  // event.emit(startTimeToHideAllComponent);
32
34
  };
33
- if (screenType === 'vertical' && verticalMic) {
35
+ if (screenType === 'vertical' && verticalMic && intercomSupported) {
34
36
  return /*#__PURE__*/React.createElement(View, {
35
37
  className: clsx(className)
36
38
  }, /*#__PURE__*/React.createElement(VoiceIntercom, _extends({}, props, {
@@ -9,3 +9,13 @@ export declare const verticalScreenId = "verticalScreenId";
9
9
  export declare const ptzControlId = "ptzControlId";
10
10
  export declare const fullResolutionId = "fullResolutionId";
11
11
  export declare const batteryId = "Battery";
12
+ export declare const fullSmallIntercomId = "FullSmallIntercom";
13
+ export declare const decodeClarityDic: {
14
+ SS: string;
15
+ SD: string;
16
+ HD: string;
17
+ UD: string;
18
+ SSP: string;
19
+ AUTO: string;
20
+ AUDIO: string;
21
+ };
@@ -8,4 +8,20 @@ export const fullTravelRouteControlId = 'fullTravelRouteControl';
8
8
  export const verticalScreenId = 'verticalScreenId';
9
9
  export const ptzControlId = 'ptzControlId';
10
10
  export const fullResolutionId = 'fullResolutionId';
11
- export const batteryId = 'Battery';
11
+ export const batteryId = 'Battery';
12
+ export const fullSmallIntercomId = 'FullSmallIntercom';
13
+ export const decodeClarityDic = {
14
+ SS: 'ss',
15
+ // 省流量
16
+ SD: 'normal',
17
+ // 标清
18
+ HD: 'hd',
19
+ // 高清
20
+ UD: 'ud',
21
+ // 超清
22
+ SSP: 'ssp',
23
+ // 超超清
24
+ AUTO: 'auto',
25
+ // 自动
26
+ AUDIO: 'audio' // 音频模式
27
+ };
package/lib/ui/ui.js CHANGED
@@ -10,7 +10,7 @@ import { PlayState, PlayerStreamStatus } from '../interface';
10
10
  import { useCtx } from '../ctx/ctx.composition';
11
11
  import { useStore } from '../ctx/store';
12
12
  import { UIEventContext } from './context';
13
- import { showAllComponent, hideAllComponent, playerTap, startTimeToHideAllComponent, pauseTimeToHideAllComponent } from './constant';
13
+ import { showAllComponent, hideAllComponent, playerTap, startTimeToHideAllComponent, pauseTimeToHideAllComponent, decodeClarityDic } from './constant';
14
14
  import BottomLeftContent from './bottomLeftContent';
15
15
  import BottomRightContent from './bottomRightContent';
16
16
  import TopLeftContent from './topLeftContent';
@@ -271,7 +271,6 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
271
271
  }, /*#__PURE__*/React.createElement(View, {
272
272
  className: clsx('ipc-player-content', className),
273
273
  style: _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, defaultCSSVariable), CSSVariable), style), {}, {
274
- // backgroundColor: 'rgba(0,0,0,0.2)',
275
274
  height: screenType === 'vertical' ? (style === null || style === void 0 ? void 0 : style.height) || '100%' : '100vh'
276
275
  })
277
276
  }, /*#__PURE__*/React.createElement(IPCPlayer, _extends({
@@ -302,7 +301,7 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
302
301
  onCameraNotifyWeakNetwork: data => {
303
302
  console.log(`onCameraNotifyWeakNetwork: ${JSON.stringify(data)}`);
304
303
  },
305
- clarity: resolution === 'HD' ? 'hd' : 'normal'
304
+ clarity: decodeClarityDic[resolution]
306
305
  // 安卓横屏问题
307
306
  // ptzControllable={screenType === 'vertical'}
308
307
  ,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/ipc-player-integration",
3
- "version": "0.0.1-beta-54",
3
+ "version": "0.0.1-beta-56",
4
4
  "description": "IPC 播放器功能集成",
5
5
  "main": "lib/index",
6
6
  "files": [
@@ -39,7 +39,7 @@
39
39
  "@ray-js/ipc-ptz-zoom": "0.0.2-beta-7",
40
40
  "@ray-js/panel-sdk": "^1.13.1",
41
41
  "@ray-js/ray-ipc-player": "2.0.20-beta-12",
42
- "@ray-js/ray-ipc-utils": "1.1.0-beta-15",
42
+ "@ray-js/ray-ipc-utils": "1.1.0-beta-16",
43
43
  "@ray-js/svg": "0.2.0",
44
44
  "clsx": "^1.2.1",
45
45
  "jotai": "^2.10.2"