@ray-js/ipc-player-integration 0.0.1-beta-53 → 0.0.1-beta-55

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,14 +80,32 @@ export const createUseCtx = _ref => {
80
80
  if (!eventRef.current) {
81
81
  eventRef.current = getEventInstance();
82
82
  }
83
+ useEffect(() => {
84
+ // 初始化获取缓存值
85
+
86
+ (async () => {
87
+ if (!devId) return;
88
+ try {
89
+ const res = await getMemoryState(devId);
90
+ console.log('==== getMemoryState ====xghazh', res);
91
+ setResolutionList(res.resolutionList);
92
+ _setResolution(res.resolution, true);
93
+ _setMute(res.mute, true);
94
+ setIntercomMode(res.intercomMode);
95
+ } catch (error) {
96
+ console.error('获取 getMemoryState 失败:', error);
97
+ }
98
+ })();
99
+ }, [devId]);
83
100
  useEffect(() => {
84
101
  if (devId && _playState === PlayState.PLAYING) {
85
102
  // 获取缓存的值且同步
86
103
  getMemoryState(devId).then(res => {
87
- console.log('==== getMemoryState ====', res);
104
+ console.log('PlayingMemoryState', res);
88
105
  setResolutionList(res.resolutionList);
89
- _setResolution(res.resolution);
90
- _setMute(res.mute);
106
+ // 传true表示值即可,会取播放器的值
107
+ _setResolution(res.resolution, true);
108
+ _setMute(res.mute, true);
91
109
  setIntercomMode(res.intercomMode);
92
110
  });
93
111
  }
@@ -126,8 +144,13 @@ export const createUseCtx = _ref => {
126
144
  if (!IPCPlayerInstance.current) {
127
145
  IPCPlayerInstance.current = createPlayContext(devId);
128
146
  }
129
- const _setMute = async target => {
147
+ const _setMute = async function (target) {
148
+ let onlyUpdateAtom = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
130
149
  console.log(target, '_setMute====');
150
+ if (onlyUpdateAtom) {
151
+ updateAtom(mute, target);
152
+ return false;
153
+ }
131
154
  return new Promise((resolve, reject) => {
132
155
  IPCPlayerInstance.current.setMuted({
133
156
  mute: target,
@@ -155,8 +178,13 @@ export const createUseCtx = _ref => {
155
178
  * 设置清晰度
156
179
  *
157
180
  */
158
- const _setResolution = async target => {
181
+ const _setResolution = async function (target) {
182
+ let onlyUpdateAtom = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
159
183
  // target 为需要切换的清晰度
184
+ if (onlyUpdateAtom) {
185
+ updateAtom(resolution, target);
186
+ return false;
187
+ }
160
188
  return new Promise((resolve, reject) => {
161
189
  IPCPlayerInstance.current.setClarity({
162
190
  clarity: target === ClarityType.HD ? 'hd' : 'normal',
@@ -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);
@@ -19,6 +19,7 @@ declare const Strings: kit.I18N<{
19
19
  ipc_player_authorize_cancel_text: string;
20
20
  ipc_player_authorize_confirm_text: string;
21
21
  ipc_player_error_record_tip: string;
22
+ ipc_player_change_resolution_success: string;
22
23
  };
23
24
  zh: {
24
25
  ipc_player_resolution_HD: string;
@@ -39,6 +40,7 @@ declare const Strings: kit.I18N<{
39
40
  ipc_player_authorize_cancel_text: string;
40
41
  ipc_player_authorize_confirm_text: string;
41
42
  ipc_player_error_record_tip: string;
43
+ ipc_player_change_resolution_success: string;
42
44
  };
43
45
  }, {
44
46
  ipc_player_resolution_HD: string;
@@ -59,6 +61,7 @@ declare const Strings: kit.I18N<{
59
61
  ipc_player_authorize_cancel_text: string;
60
62
  ipc_player_authorize_confirm_text: string;
61
63
  ipc_player_error_record_tip: string;
64
+ ipc_player_change_resolution_success: string;
62
65
  } | {
63
66
  ipc_player_resolution_HD: string;
64
67
  ipc_player_resolution_SD: string;
@@ -78,5 +81,6 @@ declare const Strings: kit.I18N<{
78
81
  ipc_player_authorize_cancel_text: string;
79
82
  ipc_player_authorize_confirm_text: string;
80
83
  ipc_player_error_record_tip: string;
84
+ ipc_player_change_resolution_success: string;
81
85
  }>;
82
86
  export default Strings;
@@ -18,6 +18,7 @@ declare const _default: {
18
18
  ipc_player_authorize_cancel_text: string;
19
19
  ipc_player_authorize_confirm_text: string;
20
20
  ipc_player_error_record_tip: string;
21
+ ipc_player_change_resolution_success: string;
21
22
  };
22
23
  zh: {
23
24
  ipc_player_resolution_HD: string;
@@ -38,6 +39,7 @@ declare const _default: {
38
39
  ipc_player_authorize_cancel_text: string;
39
40
  ipc_player_authorize_confirm_text: string;
40
41
  ipc_player_error_record_tip: string;
42
+ ipc_player_change_resolution_success: string;
41
43
  };
42
44
  };
43
45
  export default _default;
@@ -17,7 +17,8 @@ export default {
17
17
  ipc_player_no_album_permission: 'You currently do not have access to the album or storage. Please enable this permission in the settings.',
18
18
  ipc_player_authorize_cancel_text: 'Cancel',
19
19
  ipc_player_authorize_confirm_text: 'Go to Settings',
20
- ipc_player_error_record_tip: 'The recording has failed, please try again later.'
20
+ ipc_player_error_record_tip: 'The recording has failed, please try again later.',
21
+ ipc_player_change_resolution_success: '切换成功'
21
22
  },
22
23
  zh: {
23
24
  ipc_player_resolution_HD: '高清',
@@ -37,6 +38,7 @@ export default {
37
38
  ipc_player_no_album_permission: '您当前没有 相册/存储 的访问权限, 请在设置中打开此权限',
38
39
  ipc_player_authorize_cancel_text: '取消',
39
40
  ipc_player_authorize_confirm_text: '去设置',
40
- ipc_player_error_record_tip: '录制出错了,请稍后再试'
41
+ ipc_player_error_record_tip: '录制出错了,请稍后再试',
42
+ ipc_player_change_resolution_success: '切换成功'
41
43
  }
42
44
  };
@@ -1,6 +1,6 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
2
  import React, { useContext } from 'react';
3
- import { View, setPageOrientation, Text } from '@ray-js/ray';
3
+ import { View, setPageOrientation, Text, hideMenuButton, showMenuButton, showStatusBar, hideStatusBar, setNavigationBarBack } from '@ray-js/ray';
4
4
  import { useUpdateEffect } from 'ahooks';
5
5
  import clsx from 'clsx';
6
6
  import { unstable_batchedUpdates as batchedUpdates } from '@ray-core/ray';
@@ -42,9 +42,9 @@ export function FullScreen(props) {
42
42
  */
43
43
  const handleFull = () => {
44
44
  hasDpCode(devId, DIRECTION_CONTROL_DP_CODE).then(hasDirectionControlDpCode => {
45
- ty.hideMenuButton();
46
- ty.hideStatusBar();
47
- ty.setNavigationBarBack({
45
+ hideMenuButton();
46
+ hideStatusBar();
47
+ setNavigationBarBack({
48
48
  type: 'custom'
49
49
  });
50
50
  batchedUpdates(() => {
@@ -55,9 +55,15 @@ export function FullScreen(props) {
55
55
  absoluteContentClassName: 'ipc-player-plugin-vertical-screen-wrap',
56
56
  initProps: _objectSpread(_objectSpread({}, props), {}, {
57
57
  onClick: () => {
58
+ // 点击返回时提前调用一波
59
+ deleteContent('topLeft', verticalScreenId);
60
+ deleteContent('absolute', voiceIntercomId);
61
+ deleteContent('absolute', ptzControlId);
62
+ deleteContent('absolute', fullResolutionId);
63
+ deleteContent('absolute', fullTravelRouteControlId);
64
+ handClick('vertical');
58
65
  event.emit(pauseTimeToHideAllComponent);
59
66
  event.emit(showAllComponent);
60
- handClick('vertical');
61
67
  }
62
68
  })
63
69
  });
@@ -95,11 +101,11 @@ export function FullScreen(props) {
95
101
  },
96
102
  vertical: () => {
97
103
  event.emit(pauseTimeToHideAllComponent);
98
- ty.setNavigationBarBack({
104
+ setNavigationBarBack({
99
105
  type: 'system'
100
106
  });
101
- ty.showMenuButton();
102
- ty.showStatusBar();
107
+ showMenuButton();
108
+ showStatusBar();
103
109
  deleteContent('topLeft', verticalScreenId);
104
110
  deleteContent('absolute', voiceIntercomId);
105
111
  deleteContent('absolute', ptzControlId);
@@ -111,13 +117,21 @@ export function FullScreen(props) {
111
117
  var _handlers$screenType;
112
118
  (_handlers$screenType = handlers[screenType]) === null || _handlers$screenType === void 0 || _handlers$screenType.call(handlers);
113
119
  }, [screenType]);
120
+
121
+ // 点击事件处理函数
114
122
  const handClick = target => {
123
+ // 根据target的值设置pageOrientation的值
115
124
  const pageOrientation = target === 'vertical' ? 'portrait' : 'landscape';
125
+ // 发射事件
116
126
  event.emit(pauseTimeToHideAllComponent);
127
+ // 设置screenType的值
128
+ setScreenType(target);
129
+ // 设置pageOrientation的值
117
130
  setPageOrientation({
118
131
  pageOrientation,
119
132
  success: () => {
120
- setScreenType(target);
133
+ // 忽略横屏
134
+ // setScreenType(target);
121
135
  }
122
136
  });
123
137
  };
@@ -12,7 +12,7 @@
12
12
  top: 50%;
13
13
  transform: translate(0, -50%);
14
14
  // transform: translate(180%, 0);
15
- right: calc(36px * var(--ipc-player-size-scale, 1));
15
+ right: calc(50px * var(--ipc-player-size-scale, 1));
16
16
  z-index: 340;
17
17
  }
18
18
 
@@ -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
  });
@@ -1,7 +1,7 @@
1
1
  import "core-js/modules/esnext.iterator.constructor.js";
2
2
  import "core-js/modules/esnext.iterator.map.js";
3
3
  import React, { useCallback, useState, useContext, useEffect } from 'react';
4
- import { Text, View } from '@ray-js/ray';
4
+ import { Text, View, showToast } from '@ray-js/ray';
5
5
  import clsx from 'clsx';
6
6
  import Strings from '../../i18n';
7
7
  import { useMemoizedFn } from '../../hooks';
@@ -44,15 +44,19 @@ export const FullResolutionControl = props => {
44
44
  }, []);
45
45
  const changeResolution = useCallback(value => {
46
46
  if (value === resolution) {
47
- ty.showToast({
47
+ showToast({
48
48
  icon: 'none',
49
49
  title: Strings.getLang('ipc_player_current_resolution_is_equal')
50
50
  });
51
51
  } else {
52
52
  setResolution(value).then(() => {
53
+ showToast({
54
+ icon: 'none',
55
+ title: Strings.getLang('ipc_player_change_resolution_success')
56
+ });
53
57
  setHide(true);
54
58
  }).catch(() => {
55
- ty.showToast({
59
+ showToast({
56
60
  icon: 'error',
57
61
  title: Strings.getLang('ipc_player_resolution_change_error')
58
62
  });
@@ -9,3 +9,12 @@ 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 decodeClarityDic: {
13
+ SS: string;
14
+ SD: string;
15
+ HD: string;
16
+ UD: string;
17
+ SSP: string;
18
+ AUTO: string;
19
+ AUDIO: string;
20
+ };
@@ -8,4 +8,19 @@ 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 decodeClarityDic = {
13
+ SS: 'ss',
14
+ // 省流量
15
+ SD: 'normal',
16
+ // 标清
17
+ HD: 'hd',
18
+ // 高清
19
+ UD: 'ud',
20
+ // 超清
21
+ SSP: 'ssp',
22
+ // 超超清
23
+ AUTO: 'auto',
24
+ // 自动
25
+ AUDIO: 'audio' // 音频模式
26
+ };
@@ -2,7 +2,6 @@ import React from 'react';
2
2
  import { CoverView, View } from '@ray-js/ray';
3
3
  import clsx from 'clsx';
4
4
  import { useStore } from '../ctx/store';
5
- import { useComponentHideState } from './hooks';
6
5
  const TopLeftContent = _ref => {
7
6
  let {
8
7
  ctx,
@@ -14,7 +13,6 @@ const TopLeftContent = _ref => {
14
13
  screenType: ctx.screenType,
15
14
  playState: ctx.playState
16
15
  });
17
- const [shouldHide] = useComponentHideState();
18
16
  return /*#__PURE__*/React.createElement(CoverView, {
19
17
  className: clsx('ipc-player-top-left-content-wrap'),
20
18
  style: {
@@ -25,10 +23,7 @@ const TopLeftContent = _ref => {
25
23
  paddingTop: screenType === 'vertical' ? '12px' : '16px',
26
24
  paddingLeft: screenType === 'vertical' ? 0 : '25px'
27
25
  },
28
- className: clsx('ipc-player-top-left-content-container', {
29
- // 'ipc-player-top-left-content-hide': shouldHide,
30
- // 'ipc-player-top-left-content-show': !shouldHide,
31
- })
26
+ className: clsx('ipc-player-top-left-content-container')
32
27
  }, children));
33
28
  };
34
29
  export default /*#__PURE__*/React.memo(TopLeftContent);
package/lib/ui/ui.js CHANGED
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
3
3
  import "core-js/modules/esnext.iterator.constructor.js";
4
4
  import "core-js/modules/esnext.iterator.map.js";
5
- import React, { useState, useRef, useMemo, useEffect, useImperativeHandle } from 'react';
5
+ import React, { useContext, useState, useRef, useMemo, useEffect, useImperativeHandle } from 'react';
6
6
  import { View, CoverView, getSystemInfoSync, usePageEvent } from '@ray-js/ray';
7
7
  import clsx from 'clsx';
8
8
  import IPCPlayer from '@ray-js/ray-ipc-player';
@@ -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';
@@ -54,6 +54,9 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
54
54
  onPlayerTap,
55
55
  extend = {}
56
56
  } = props;
57
+ const {
58
+ event
59
+ } = useContext(UIEventContext);
57
60
  const instance = getCtxInstance(props.instance, devId);
58
61
  const {
59
62
  setPlayState,
@@ -70,6 +73,7 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
70
73
  这里用一个统一的状态标志期望控件是否展示
71
74
  */
72
75
  const [componentHideState, setComponentHideState] = useState(false);
76
+ const [showRightContent, setShowRightContent] = useState(true);
73
77
  prevTriggerEvent.current = componentHideState ? hideAllComponent : showAllComponent;
74
78
  const eventRef = useRef(instance.event);
75
79
  if (eventRef.current !== instance.event) {
@@ -81,6 +85,13 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
81
85
  setBrandColor(brandColor);
82
86
  setVerticalMic(verticalMic);
83
87
  }, []);
88
+ const refreshBottomLeft = value => {
89
+ console.log(value, '++++++++++++++----sadbjasbdjbsj');
90
+ event.current.emit(startTimeToHideAllComponent);
91
+ event.current.emit(showAllComponent);
92
+ event.current.emit(playerTap);
93
+ setShowRightContent(value);
94
+ };
84
95
 
85
96
  /**
86
97
  * 监听屏幕布局变化
@@ -241,15 +252,17 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
241
252
  eventRef.current.on(showAllComponent, listenShowEvent);
242
253
  eventRef.current.on(hideAllComponent, listenHideEvent);
243
254
  eventRef.current.on('disablePlayerTap', handDisablePlayerTap);
255
+ eventRef.current.on('refreshBottomLeft', refreshBottomLeft);
244
256
  return () => {
245
257
  eventRef.current.off(startTimeToHideAllComponent, listenStart);
246
258
  eventRef.current.off(pauseTimeToHideAllComponent, listenPause);
247
259
  eventRef.current.off(showAllComponent, listenShowEvent);
248
260
  eventRef.current.off(hideAllComponent, listenHideEvent);
249
261
  eventRef.current.off('disablePlayerTap', handDisablePlayerTap);
262
+ eventRef.current.off('refreshBottomLeft', refreshBottomLeft);
250
263
  };
251
264
  }, []);
252
- const playerReady = playState === PlayState.PLAYING;
265
+ playState === PlayState.PLAYING;
253
266
  return /*#__PURE__*/React.createElement(UIEventContext.Provider, {
254
267
  value: {
255
268
  event: eventRef.current,
@@ -258,7 +271,6 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
258
271
  }, /*#__PURE__*/React.createElement(View, {
259
272
  className: clsx('ipc-player-content', className),
260
273
  style: _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, defaultCSSVariable), CSSVariable), style), {}, {
261
- // backgroundColor: 'rgba(0,0,0,0.2)',
262
274
  height: screenType === 'vertical' ? (style === null || style === void 0 ? void 0 : style.height) || '100%' : '100vh'
263
275
  })
264
276
  }, /*#__PURE__*/React.createElement(IPCPlayer, _extends({
@@ -289,7 +301,7 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
289
301
  onCameraNotifyWeakNetwork: data => {
290
302
  console.log(`onCameraNotifyWeakNetwork: ${JSON.stringify(data)}`);
291
303
  },
292
- clarity: resolution === 'HD' ? 'hd' : 'normal'
304
+ clarity: decodeClarityDic[resolution]
293
305
  // 安卓横屏问题
294
306
  // ptzControllable={screenType === 'vertical'}
295
307
  ,
@@ -336,7 +348,7 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
336
348
  ctx: instance
337
349
  }, renderBottomLeftContent), /*#__PURE__*/React.createElement(BottomRightContent, {
338
350
  ctx: instance
339
- }, renderBottomRightContent)), playerReady && (() => {
351
+ }, renderBottomRightContent)), (() => {
340
352
  if (!absoluteContent || !(absoluteContent !== null && absoluteContent !== void 0 && absoluteContent.length)) return null;
341
353
  return absoluteContent.map(item => {
342
354
  if (item.hidden) return null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/ipc-player-integration",
3
- "version": "0.0.1-beta-53",
3
+ "version": "0.0.1-beta-55",
4
4
  "description": "IPC 播放器功能集成",
5
5
  "main": "lib/index",
6
6
  "files": [
@@ -38,8 +38,8 @@
38
38
  "dependencies": {
39
39
  "@ray-js/ipc-ptz-zoom": "0.0.2-beta-7",
40
40
  "@ray-js/panel-sdk": "^1.13.1",
41
- "@ray-js/ray-ipc-player": "2.0.20-beta-10",
42
- "@ray-js/ray-ipc-utils": "1.1.0-beta-15",
41
+ "@ray-js/ray-ipc-player": "2.0.20-beta-12",
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"