@ray-js/ipc-player-integration 0.0.1-beta-14 → 0.0.1-beta-16

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.
@@ -2,7 +2,7 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
3
  const _excluded = ["title", "duration"];
4
4
  import IPCUtils from '@ray-js/ray-ipc-utils';
5
- import { IntercomMode, MuteMode } from '@ray-js/ray-ipc-utils/lib/interface';
5
+ import { IntercomMode, MuteMode, ClarityType } from '@ray-js/ray-ipc-utils/lib/interface';
6
6
  import { createUseCtx } from './ctx';
7
7
  import { Battery, Screenshot, TempHumidity, RecordVideo, FullScreen, VideoBitKbps, Muted, Resolution, Ptz } from '../plugins';
8
8
  import { authorizeStatus } from '../utils/authorize';
@@ -54,17 +54,22 @@ const toast = _ref => {
54
54
  const getMemoryState = devId => {
55
55
  const defaultValue = {
56
56
  mute: true,
57
- intercomMode: IntercomMode.TwoWay
57
+ intercomMode: IntercomMode.TwoWay,
58
+ resolution: ClarityType.HD,
59
+ resolutionList: [ClarityType.HD, ClarityType.SD]
58
60
  };
59
61
  return new Promise(resolve => {
60
62
  IPCUtils.getCameraConfigInfo(devId).then(res => {
61
63
  if (res.code === -1) {
62
64
  return resolve(defaultValue);
63
65
  }
64
- const value = res.data.microphoneSettings.cachedMuteMode === MuteMode.OFF;
66
+ console.log(res, '========');
67
+ const muteValue = res.data.microphoneSettings.cachedMuteMode === MuteMode.OFF;
65
68
  return resolve({
66
- mute: value,
67
- intercomMode: res.data.intercomInfo.cachedIntercomMode
69
+ mute: muteValue,
70
+ intercomMode: res.data.intercomInfo.cachedIntercomMode,
71
+ resolution: res.data.videoResolution.cachedResolution,
72
+ resolutionList: res.data.videoResolution.availableResolutions
68
73
  });
69
74
  }).catch(() => {
70
75
  resolve(defaultValue);
package/lib/ctx/ctx.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { useRef, useCallback, useEffect } from 'react';
2
2
  import { useAtom, updateAtom, getDefaultStore, useStore } from './store';
3
3
  import { PlayState, IntercomMode } from '../interface';
4
+ import { ClarityType } from '@ray-js/ray-ipc-utils/lib/interface';
4
5
  const SAVE_TO_ALBUM = 1;
5
6
  export const createUseCtx = _ref => {
6
7
  let {
@@ -31,12 +32,17 @@ export const createUseCtx = _ref => {
31
32
  // 静音 true 代表静音 false 代表不静音
32
33
  const [mute] = useAtom(false);
33
34
 
34
- // 清晰度
35
- const [resolution] = useAtom('HD');
35
+ // 品牌色 默认
36
+ const [brandColor, setBrandColor] = useAtom('#FF592A');
36
37
 
37
38
  // ptz 是否点击
38
39
  const [ptzActive, setPtzActive] = useAtom(false);
39
40
 
41
+ // resolution 当前清晰度
42
+ const [resolution] = useAtom('HD');
43
+ // resolution 清晰度列表
44
+ const [resolutionList, setResolutionList] = useAtom([]);
45
+
40
46
  // 单向对讲还是双向对讲
41
47
  const [intercomMode, setIntercomMode] = useAtom(IntercomMode.TwoWay);
42
48
 
@@ -64,6 +70,8 @@ export const createUseCtx = _ref => {
64
70
  console.log('==== getMemoryState ====', res);
65
71
  _setMute(res.mute);
66
72
  setIntercomMode(res.intercomMode);
73
+ _setResolution(res.resolution, 'res.resolution');
74
+ setResolutionList(res.resolutionList);
67
75
  });
68
76
  }
69
77
  }, [devId, _playState]);
@@ -103,20 +111,40 @@ export const createUseCtx = _ref => {
103
111
  * 设置清晰度
104
112
  *
105
113
  */
106
-
114
+ const _setResolution = async target => {
115
+ // target 为需要切换的清晰度
116
+ return new Promise((resolve, reject) => {
117
+ IPCPlayerInstance.current.setClarity({
118
+ clarity: target === ClarityType.HD ? 'hd' : 'normal',
119
+ success: () => {
120
+ console.log('setClarity success', target);
121
+ updateAtom(resolution, target);
122
+ resolve(true);
123
+ },
124
+ fail: err => {
125
+ console.log(err, 'setClarity err');
126
+ // updateAtom(mute, !target);
127
+ reject(err);
128
+ }
129
+ });
130
+ });
131
+ };
107
132
  return {
108
133
  devId,
134
+ brandColor,
109
135
  saveToAlbum,
110
136
  screenType,
111
137
  recording,
112
138
  mute,
113
139
  resolution,
140
+ resolutionList,
114
141
  ptzActive,
115
142
  fullResolutionActive,
116
143
  intercom,
117
144
  intercomMode,
118
145
  playState,
119
146
  setPlayState,
147
+ setBrandColor,
120
148
  setIntercom: async target => {
121
149
  const store = getDefaultStore();
122
150
  const _intercom = store.get(intercom);
@@ -156,24 +184,8 @@ export const createUseCtx = _ref => {
156
184
  });
157
185
  },
158
186
  setMute: _setMute,
159
- setResolution: async target => {
160
- console.log('执行清晰度方法');
161
- return new Promise((resolve, reject) => {
162
- IPCPlayerInstance.current.setClarity({
163
- clarity: target,
164
- success: () => {
165
- console.log('setClarity success');
166
- updateAtom(resolution, target === 'hd' ? 'HD' : 'SD');
167
- resolve(true);
168
- },
169
- fail: err => {
170
- console.log('setClarity err');
171
- // updateAtom(mute, !target);
172
- reject(err);
173
- }
174
- });
175
- });
176
- },
187
+ setResolution: _setResolution,
188
+ setResolutionList,
177
189
  setRecording: async target => {
178
190
  const store = getDefaultStore();
179
191
  const _recording = store.get(recording);
@@ -0,0 +1,22 @@
1
+ import { kit } from '@ray-js/panel-sdk';
2
+ declare const Strings: kit.I18N<{
3
+ en: {
4
+ ipc_player_resolution_HD: string;
5
+ ipc_player_resolution_SD: string;
6
+ ipc_player_current_resolution_is_equal: string;
7
+ };
8
+ zh: {
9
+ ipc_player_resolution_HD: string;
10
+ ipc_player_resolution_SD: string;
11
+ ipc_player_current_resolution_is_equal: string;
12
+ };
13
+ }, {
14
+ ipc_player_resolution_HD: string;
15
+ ipc_player_resolution_SD: string;
16
+ ipc_player_current_resolution_is_equal: string;
17
+ } | {
18
+ ipc_player_resolution_HD: string;
19
+ ipc_player_resolution_SD: string;
20
+ ipc_player_current_resolution_is_equal: string;
21
+ }>;
22
+ export default Strings;
@@ -0,0 +1,7 @@
1
+ import { kit } from '@ray-js/panel-sdk';
2
+ import strings from './strings';
3
+ const {
4
+ I18N
5
+ } = kit;
6
+ const Strings = new I18N(strings);
7
+ export default Strings;
@@ -0,0 +1,13 @@
1
+ declare const _default: {
2
+ en: {
3
+ ipc_player_resolution_HD: string;
4
+ ipc_player_resolution_SD: string;
5
+ ipc_player_current_resolution_is_equal: string;
6
+ };
7
+ zh: {
8
+ ipc_player_resolution_HD: string;
9
+ ipc_player_resolution_SD: string;
10
+ ipc_player_current_resolution_is_equal: string;
11
+ };
12
+ };
13
+ export default _default;
@@ -0,0 +1,12 @@
1
+ export default {
2
+ en: {
3
+ ipc_player_resolution_HD: 'HD',
4
+ ipc_player_resolution_SD: 'SD',
5
+ ipc_player_current_resolution_is_equal: 'Already at current clarity'
6
+ },
7
+ zh: {
8
+ ipc_player_resolution_HD: '高清',
9
+ ipc_player_resolution_SD: '标清',
10
+ ipc_player_current_resolution_is_equal: '已是当前清晰度'
11
+ }
12
+ };
@@ -32,6 +32,7 @@ export type UseCtx = (options: {
32
32
  saveToAlbum?: 0 | 1;
33
33
  }) => {
34
34
  devId: string;
35
+ brandColor: string;
35
36
  saveToAlbum: 0 | 1;
36
37
  screenType: RetAtom<ScreenType>;
37
38
  recording: RetAtom<boolean>;
@@ -39,14 +40,19 @@ export type UseCtx = (options: {
39
40
  intercom: RetAtom<boolean>;
40
41
  intercomMode: RetAtom<IntercomMode>;
41
42
  ptzActive: RetAtom<boolean>;
43
+ resolution: RetAtom<string>;
44
+ resolutionList: RetAtom<string[]>;
42
45
  fullResolutionActive: RetAtom<boolean>;
43
46
  playState: RetAtom<PlayState>;
44
47
  IPCPlayerInstance: IpcContext;
45
48
  topContent: RetAtom<ComponentConfig[]>;
46
49
  bottomContent: RetAtom<ComponentConfig[]>;
47
50
  absoluteContent: RetAtom<ComponentConfig[]>;
51
+ setBrandColor: (color: string) => void;
48
52
  setScreenType: (type: ScreenType) => void;
49
53
  setPtzActive: (type: boolean) => void;
54
+ setResolution: (type: string) => void;
55
+ setResolutionList: (type: string[]) => void;
50
56
  setFullResolutionActive: (type: boolean) => void;
51
57
  setRecording: (value: boolean) => Promise<boolean>;
52
58
  setIntercom: (value: boolean) => Promise<boolean>;
@@ -3,6 +3,7 @@ export declare const Battery: import("react").FunctionComponent<{
3
3
  IPCPlayerContext: IpcContext;
4
4
  } & {
5
5
  devId: string;
6
+ brandColor: string;
6
7
  saveToAlbum: 0 | 1;
7
8
  screenType: import("../..").RetAtom<import("../..").ScreenType>;
8
9
  recording: import("../..").RetAtom<boolean>;
@@ -10,14 +11,19 @@ export declare const Battery: import("react").FunctionComponent<{
10
11
  intercom: import("../..").RetAtom<boolean>;
11
12
  intercomMode: import("../..").RetAtom<import("@ray-js/ray-ipc-utils/lib/interface").IntercomMode>;
12
13
  ptzActive: import("../..").RetAtom<boolean>;
14
+ resolution: import("../..").RetAtom<string>;
15
+ resolutionList: import("../..").RetAtom<string[]>;
13
16
  fullResolutionActive: import("../..").RetAtom<boolean>;
14
17
  playState: import("../..").RetAtom<import("../..").PlayState>;
15
18
  IPCPlayerInstance: IpcContext;
16
19
  topContent: import("../..").RetAtom<import("../..").ComponentConfig<any & Record<string, any>>[]>;
17
20
  bottomContent: import("../..").RetAtom<import("../..").ComponentConfig<any & Record<string, any>>[]>;
18
21
  absoluteContent: import("../..").RetAtom<import("../..").ComponentConfig<any & Record<string, any>>[]>;
22
+ setBrandColor: (color: string) => void;
19
23
  setScreenType: (type: import("../..").ScreenType) => void;
20
24
  setPtzActive: (type: boolean) => void;
25
+ setResolution: (type: string) => void;
26
+ setResolutionList: (type: string[]) => void;
21
27
  setFullResolutionActive: (type: boolean) => void;
22
28
  setRecording: (value: boolean) => Promise<boolean>;
23
29
  setIntercom: (value: boolean) => Promise<boolean>;
@@ -1,4 +1,3 @@
1
- import _extends from "@babel/runtime/helpers/esm/extends";
2
1
  import React, { useContext } from 'react';
3
2
  import { CoverView } from '@ray-js/ray';
4
3
  import clsx from 'clsx';
@@ -10,19 +9,21 @@ import { startTimeToHideAllComponent, pauseTimeToHideAllComponent } from '../../
10
9
  import './ptz.less';
11
10
  export const PtzControl = props => {
12
11
  const {
13
- screenType
12
+ screenType,
13
+ brandColor
14
14
  } = useStore({
15
- screenType: props.screenType
15
+ screenType: props.screenType,
16
+ brandColor: props.brandColor
16
17
  });
17
18
  const [shouldHide] = useComponentHideState(screenType);
18
19
  const {
19
20
  event
20
21
  } = useContext(UIEventContext);
21
- return /*#__PURE__*/React.createElement(CoverView, _extends({
22
+ return /*#__PURE__*/React.createElement(CoverView, {
22
23
  className: clsx('ipc-player-plugin-full-screen-ptz-control', {
23
24
  'ipc-player-plugin-full-screen-ptz-control-hide': shouldHide
24
25
  })
25
- }, props), /*#__PURE__*/React.createElement(IpcPtzZoom, {
26
+ }, /*#__PURE__*/React.createElement(IpcPtzZoom, {
26
27
  ptzSize: "172px",
27
28
  zoomData: [],
28
29
  ptzData: [{
@@ -58,7 +59,7 @@ export const PtzControl = props => {
58
59
  console.log('dsads');
59
60
  event.emit(startTimeToHideAllComponent);
60
61
  },
61
- brandColor: "red",
62
+ brandColor: brandColor,
62
63
  iconClassName: clsx('arrow-icon-wrapper')
63
64
  }));
64
65
  };
@@ -1,31 +1,56 @@
1
- import _extends from "@babel/runtime/helpers/esm/extends";
2
1
  import React, { useContext } from 'react';
3
2
  import { Text, View } from '@ray-js/ray';
4
3
  import clsx from 'clsx';
4
+ import Strings from '../../i18n';
5
5
  import { useComponentHideState } from '../../ui/hooks';
6
6
  import { UIEventContext } from '../../ui/context';
7
7
  import { useStore } from '../../ctx/store';
8
8
  import { startTimeToHideAllComponent, pauseTimeToHideAllComponent } from '../../ui/constant';
9
9
  import './resolution.less';
10
10
  export const FullResolutionControl = props => {
11
+ const {
12
+ setResolution,
13
+ setFullResolutionActive
14
+ } = props;
11
15
  const {
12
16
  screenType,
13
- fullResolutionActive
17
+ fullResolutionActive,
18
+ resolution,
19
+ resolutionList,
20
+ brandColor
14
21
  } = useStore({
15
22
  screenType: props.screenType,
16
- fullResolutionActive: props.fullResolutionActive
23
+ fullResolutionActive: props.fullResolutionActive,
24
+ resolutionList: props.resolutionList,
25
+ brandColor: props.brandColor,
26
+ resolution: props.resolution
17
27
  });
28
+ console.log(resolutionList, 'resolutionList');
18
29
  const [shouldHide] = useComponentHideState(screenType);
19
30
  const {
20
31
  event
21
32
  } = useContext(UIEventContext);
22
- return /*#__PURE__*/React.createElement(View, _extends({
33
+ const changeResolution = value => {
34
+ if (value === resolution) {
35
+ ty.showToast({
36
+ icon: 'none',
37
+ title: Strings.getLang('ipc_player_current_resolution_is_equal')
38
+ });
39
+ } else {
40
+ setResolution(value);
41
+ setFullResolutionActive(false);
42
+ }
43
+ };
44
+ return /*#__PURE__*/React.createElement(View, {
23
45
  className: clsx('ipc-player-plugin-full-resolution-control', {
24
46
  'ipc-player-plugin-full-resolution-control-hide': shouldHide || !fullResolutionActive
25
47
  })
26
- }, props), /*#__PURE__*/React.createElement(Text, {
27
- className: clsx('ipc-player-plugin-full-resolution-control-text')
28
- }, "\u9AD8\u6E05"), /*#__PURE__*/React.createElement(Text, {
29
- className: clsx('ipc-player-plugin-full-resolution-control-text')
30
- }, "\u6807\u6E05"));
48
+ }, resolutionList.map(item => /*#__PURE__*/React.createElement(Text, {
49
+ onClick: () => changeResolution(item),
50
+ key: item,
51
+ className: clsx('ipc-player-plugin-full-resolution-control-text'),
52
+ style: item === resolution && {
53
+ color: brandColor
54
+ }
55
+ }, I18n.t(`ipc_player_resolution_${item}`))));
31
56
  };
@@ -1,41 +1,31 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
2
  import { View, Text } from '@ray-js/ray';
3
3
  import clsx from 'clsx';
4
- import React, { useContext, useEffect } from 'react';
4
+ import React, { useContext } from 'react';
5
+ import Strings from '../../i18n';
5
6
  import { FullResolutionControl } from './fullResolutionControl';
6
7
  import { fullResolutionId, pauseTimeToHideAllComponent } from '../../ui/constant';
7
8
  import { UIEventContext } from '../../ui/context';
8
- import { useStore, updateAtom } from '../../ctx/store';
9
+ import { useStore } from '../../ctx/store';
9
10
  import './resolution.less';
10
11
  export const Resolution = props => {
11
12
  const {
12
13
  IPCPlayerContext,
13
- resolution,
14
14
  setResolution,
15
- screenType: screenTypeAtom,
16
- fullResolutionActive,
17
- addContent
15
+ addContent,
16
+ setFullResolutionActive
18
17
  } = props;
19
18
  const {
20
- currentResolution,
21
- screenType,
22
- isFullResolutionActive
19
+ resolution,
20
+ screenType
23
21
  } = useStore({
24
- currentResolution: resolution,
25
- screenType: screenTypeAtom,
26
- isFullResolutionActive: fullResolutionActive
22
+ resolution: props.resolution,
23
+ screenType: props.screenType,
24
+ fullResolutionActive: props.fullResolutionActive
27
25
  });
28
26
  const {
29
27
  event
30
28
  } = useContext(UIEventContext);
31
- console.log(screenType, 'screenType');
32
- // const setIsMuted = (value: typeof currentResolution) => {
33
- // // updateAtom(mute, value);
34
- // };
35
-
36
- useEffect(() => {
37
- // init();
38
- }, []);
39
29
  return /*#__PURE__*/React.createElement(View, {
40
30
  onClick: () => {
41
31
  if (screenType === 'full') {
@@ -48,15 +38,15 @@ export const Resolution = props => {
48
38
  absoluteContentClassName: 'ipc-player-plugin-full-resolution-control-wrap',
49
39
  initProps: _objectSpread({}, props)
50
40
  });
51
- updateAtom(fullResolutionActive, true);
41
+ setFullResolutionActive(true);
52
42
  event.emit(pauseTimeToHideAllComponent);
53
43
  return false;
54
44
  }
55
- setResolution(currentResolution === 'HD' ? 'normal' : 'hd');
45
+ setResolution(resolution === 'HD' ? 'SD' : 'HD');
56
46
  return true;
57
47
  },
58
48
  className: clsx('ipc-player-plugin-resolution', screenType === 'vertical' ? 'ipc-player-plugin-resolution-vertical' : 'ipc-player-plugin-resolution-full')
59
49
  }, /*#__PURE__*/React.createElement(Text, {
60
50
  className: "resolutionText"
61
- }, currentResolution));
51
+ }, Strings.getLang(`ipc_player_resolution_${resolution}`)));
62
52
  };
@@ -38,6 +38,7 @@
38
38
  display: flex;
39
39
  justify-content: center;
40
40
  align-items: center;
41
+ background-color: transparent;
41
42
  // transform: translate(200%, 0);
42
43
  z-index: 3;
43
44
  }
@@ -48,4 +49,5 @@
48
49
  text-align: center;
49
50
  color: #ffffff;
50
51
  min-height: 40px;
52
+ width: 100%;
51
53
  }
package/lib/ui/ui.d.ts CHANGED
@@ -16,6 +16,8 @@ type Props = {
16
16
  className?: string;
17
17
  onPlayStatus?: (data: PlayStatusData) => void;
18
18
  style?: React.CSSProperties;
19
+ privateState?: boolean;
20
+ deviceOnline?: boolean;
19
21
  CSSVariable?: Partial<CSSVariable>;
20
22
  };
21
23
  export declare const IPCPlayerIntegration: React.MemoExoticComponent<(props: Props) => React.JSX.Element>;
package/lib/ui/ui.js CHANGED
@@ -38,10 +38,11 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
38
38
  className,
39
39
  devId,
40
40
  style,
41
- CSSVariable = defaultCSSVariable
41
+ CSSVariable = defaultCSSVariable,
42
+ privateState = false,
43
+ deviceOnline = true
42
44
  } = props;
43
45
  const instance = getCtxInstance(props.instance, devId);
44
- console.log(instance, 'instance');
45
46
  const {
46
47
  setPlayState,
47
48
  setScreenType,
@@ -184,7 +185,7 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
184
185
  objectFit: "",
185
186
  defaultMute: true,
186
187
  devId: devId,
187
- onlineStatus: true,
188
+ onlineStatus: deviceOnline,
188
189
  ipcPlayerContext: instance.IPCPlayerInstance,
189
190
  onChangeStreamStatus: code => {
190
191
  var _props$onPlayStatus;
@@ -234,7 +235,7 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
234
235
  }, 3000);
235
236
  },
236
237
  clarity: "hd",
237
- privateState: false,
238
+ privateState: privateState,
238
239
  onPlayerTap: handPlayerTap // 对应原来的onVideoTap
239
240
  }), playerReady && /*#__PURE__*/React.createElement(TopContent, {
240
241
  ctx: instance
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/ipc-player-integration",
3
- "version": "0.0.1-beta-14",
3
+ "version": "0.0.1-beta-16",
4
4
  "description": "IPC 播放器功能集成",
5
5
  "main": "lib/index",
6
6
  "files": [