@ray-js/ipc-player-integration 0.0.1-beta-60 → 0.0.1-beta-61

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.
@@ -1,7 +1,7 @@
1
1
  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
- import IPCUtils from '@ray-js/ray-ipc-utils';
4
+ import { getCameraConfigInfo } from '@ray-js/ray-ipc-utils';
5
5
  import { IntercomMode, MuteMode, ClarityType } from '@ray-js/ray-ipc-utils/lib/interface';
6
6
  import { createUseCtx } from './ctx';
7
7
  import { FullSmallIntercom, VerticalSmallIntercom, BatteryFull, Battery, Screenshot, TempHumidity, RecordVideo, FullScreen, VideoBitKBP, Muted, Resolution, Ptz } from '../widgets';
@@ -72,7 +72,7 @@ const getMemoryState = devId => {
72
72
  isIntercomSupported: false
73
73
  };
74
74
  return new Promise(resolve => {
75
- IPCUtils.getCameraConfigInfo(devId).then(res => {
75
+ getCameraConfigInfo(devId).then(res => {
76
76
  if (res.code === -1) {
77
77
  return resolve(defaultValue);
78
78
  }
@@ -1,6 +1,6 @@
1
1
  export { IntercomMode } from '@ray-js/ray-ipc-utils/lib/interface';
2
2
 
3
- // plugin 获取电池电量 todo
3
+ // plugin 获取电池电量
4
4
 
5
5
  // plugin 获取是否支持Ptz
6
6
 
package/lib/ui/ui.d.ts CHANGED
@@ -24,6 +24,7 @@ type Props = {
24
24
  CSSVariable?: Partial<CSSVariable>;
25
25
  brandColor?: string;
26
26
  verticalMic?: boolean;
27
+ landscapeMode?: 'fill' | 'standard';
27
28
  eventRef?: React.RefObject<EventInstance>;
28
29
  onPlayerTap?: (data: any) => void;
29
30
  extend?: Record<string, any>;
package/lib/ui/ui.js CHANGED
@@ -51,6 +51,7 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
51
51
  brandColor = '#FF592A',
52
52
  verticalMic = true,
53
53
  eventRef: eventRefProp,
54
+ landscapeMode = 'standard',
54
55
  onPlayerTap,
55
56
  extend = {}
56
57
  } = props;
@@ -81,6 +82,8 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
81
82
  }
82
83
  useImperativeHandle(eventRefProp, () => eventRef.current, [eventRef.current]);
83
84
  const timer = useRef();
85
+ const [scaleMultiple, setScaleMultiple] = useState(1);
86
+ const [currentZoomLevel, setCurrentZoomLevel] = useState(1);
84
87
  useEffect(() => {
85
88
  setBrandColor(brandColor);
86
89
  setVerticalMic(verticalMic);
@@ -106,11 +109,21 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
106
109
  deviceType
107
110
  } = systemInfo.current;
108
111
  // 针对pad 暂不支持横屏,且在ios pad模式下 会触发onResize事件, 待解决
112
+
109
113
  if (deviceType === 'pad') {
110
114
  setScreenType('vertical');
111
115
  } else {
112
116
  setScreenType(type === 'landscape' ? 'full' : 'vertical');
113
117
  }
118
+
119
+ // 若为全屏模式并且要求按宽填充,即横屏时充满,主动设置模式为-1即可
120
+ if (type === 'landscape' && landscapeMode === 'fill') {
121
+ console.log('横屏时充满');
122
+ setScaleMultiple(-1);
123
+ } else {
124
+ // 将屏幕播放比例设为1
125
+ setScaleMultiple(1);
126
+ }
114
127
  } catch (err) {
115
128
  console.log(err, 'err');
116
129
  }
@@ -206,7 +219,25 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
206
219
  /**
207
220
  * 视频流加载状态封装
208
221
  */
209
-
222
+ const onChangeStreamStatus = useMemoizedFn(code => {
223
+ var _props$onPlayStatus;
224
+ const playStateMap = {
225
+ [PlayerStreamStatus.PreviewSuccess]: PlayState.PLAYING,
226
+ // 播放中
227
+ [PlayerStreamStatus.PAUSE]: PlayState.PAUSE // 暂停
228
+ };
229
+ // 合并为三种状态 连接中 暂停 播放中
230
+ const playState = playStateMap[code] || PlayState.CONNECTING;
231
+ if (playState !== PlayState.PLAYING) {
232
+ setScaleMultiple(currentZoomLevel);
233
+ }
234
+ setPlayState(playState);
235
+ (_props$onPlayStatus = props.onPlayStatus) === null || _props$onPlayStatus === void 0 || _props$onPlayStatus.call(props, {
236
+ playState,
237
+ playCode: code
238
+ });
239
+ instance.changeStreamStatus(code);
240
+ });
210
241
  const disablePlayerTap = useRef(false);
211
242
  const handDisablePlayerTap = value => {
212
243
  disablePlayerTap.current = !!value;
@@ -277,29 +308,21 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
277
308
  devId: devId,
278
309
  onlineStatus: deviceOnline,
279
310
  ipcPlayerContext: instance.IPCPlayerInstance,
280
- onChangeStreamStatus: code => {
281
- var _props$onPlayStatus;
282
- const playStateMap = {
283
- [PlayerStreamStatus.PreviewSuccess]: PlayState.PLAYING,
284
- // 播放中
285
- [PlayerStreamStatus.PAUSE]: PlayState.PAUSE // 暂停
286
- };
287
- // 合并为三种状态 连接中 暂停 播放中
288
- const playState = playStateMap[code] || PlayState.CONNECTING;
289
- setPlayState(playState);
290
- (_props$onPlayStatus = props.onPlayStatus) === null || _props$onPlayStatus === void 0 || _props$onPlayStatus.call(props, {
291
- playState,
292
- playCode: code
293
- });
294
- instance.changeStreamStatus(code);
295
- }
296
- // onCtx={getIpcPlayer}
311
+ onChangeStreamStatus: onChangeStreamStatus
312
+ // onCtx={getIpcPlayerCtx}
297
313
  // onPlayerTap={handlePlayerClick}
298
314
  ,
299
315
  onCameraNotifyWeakNetwork: data => {
300
316
  console.log(`onCameraNotifyWeakNetwork: ${JSON.stringify(data)}`);
301
317
  },
302
- clarity: decodeClarityDic[resolution]
318
+ clarity: decodeClarityDic[resolution],
319
+ onZoomChange: data => {
320
+ const {
321
+ zoomLevel
322
+ } = data === null || data === void 0 ? void 0 : data.detail;
323
+ setCurrentZoomLevel(zoomLevel);
324
+ },
325
+ scaleMultiple: scaleMultiple
303
326
  // 安卓横屏问题
304
327
  // ptzControllable={screenType === 'vertical'}
305
328
  ,
@@ -1,7 +1,7 @@
1
1
  import "core-js/modules/esnext.iterator.constructor.js";
2
2
  import "core-js/modules/esnext.iterator.find.js";
3
3
  import "core-js/modules/esnext.iterator.for-each.js";
4
- import IpcUtils from '@ray-js/ray-ipc-utils';
4
+ import { getDevInfo } from '@ray-js/ray-ipc-utils';
5
5
  export function getDpValue(options) {
6
6
  return new Promise((resolve, reject) => {
7
7
  ty.device.getDeviceInfo({
@@ -90,32 +90,6 @@ export const showMathPowValue = (value, scale) => {
90
90
  }
91
91
  return v;
92
92
  };
93
- export const getDevInfo = deviceId => {
94
- return new Promise(resolve => {
95
- try {
96
- ty.device.getDeviceInfo({
97
- deviceId,
98
- success: res => {
99
- resolve({
100
- code: 0,
101
- data: res
102
- });
103
- },
104
- fail: err => {
105
- resolve({
106
- code: -1,
107
- msg: err
108
- });
109
- }
110
- });
111
- } catch (err) {
112
- resolve({
113
- code: -1,
114
- msg: String(err)
115
- });
116
- }
117
- });
118
- };
119
93
 
120
94
  /**
121
95
  * 根据DpCode获取枚举型DP的range是否包含对应项
@@ -123,7 +97,7 @@ export const getDevInfo = deviceId => {
123
97
  */
124
98
 
125
99
  export const getEnumRangeIsValid = async (devId, dpCode, rangValue) => {
126
- const infoData = await IpcUtils.getDevInfo(devId);
100
+ const infoData = await getDevInfo(devId);
127
101
  if (infoData.code === 0) {
128
102
  var _targetSchema$propert;
129
103
  const {
@@ -5,7 +5,7 @@ import clsx from 'clsx';
5
5
  import _find from 'lodash/find';
6
6
  import _get from 'lodash/get';
7
7
  import IpcPtzZoom from '@ray-js/ipc-ptz-zoom';
8
- import IpcUtils from '@ray-js/ray-ipc-utils';
8
+ import { getDpIdByCode, publishDps } from '@ray-js/ray-ipc-utils';
9
9
  import { useMemoizedFn } from '../../hooks';
10
10
  import { useComponentHideState } from '../../ui/hooks';
11
11
  import { UIEventContext } from '../../ui/context';
@@ -106,17 +106,17 @@ export const PtzControl = props => {
106
106
  const {
107
107
  type
108
108
  } = data;
109
- const dpData = await IpcUtils.getDpIdByCode(devId, 'ptz_control');
109
+ const dpData = await getDpIdByCode(devId, 'ptz_control');
110
110
  if (dpData.code === 0) {
111
111
  const ptzControlId = dpData.data;
112
112
  const sndDpValue = _get(_find(ptzData.current, {
113
113
  type
114
114
  }), 'dpValue', null);
115
- IpcUtils.publishDps(devId, {
115
+ publishDps(devId, {
116
116
  [ptzControlId]: sndDpValue
117
117
  });
118
118
  ptzTimeId.current = setInterval(() => {
119
- IpcUtils.publishDps(devId, {
119
+ publishDps(devId, {
120
120
  [ptzControlId]: sndDpValue
121
121
  });
122
122
  }, 1000);
@@ -133,10 +133,10 @@ export const PtzControl = props => {
133
133
  }
134
134
  },
135
135
  onTouchPtzEnd: async () => {
136
- const ptzStopData = await IpcUtils.getDpIdByCode(devId, 'ptz_stop');
136
+ const ptzStopData = await getDpIdByCode(devId, 'ptz_stop');
137
137
  if (ptzStopData.code === 0) {
138
138
  const ptzStopId = ptzStopData.data;
139
- IpcUtils.publishDps(devId, {
139
+ publishDps(devId, {
140
140
  [ptzStopId]: true
141
141
  });
142
142
  }
@@ -2,7 +2,7 @@ import React, { useState, useEffect, useRef, useContext } from 'react';
2
2
  import { View, Text, Image } from '@ray-js/ray';
3
3
  import { useSetState, useUpdateEffect } from 'ahooks';
4
4
  import clsx from 'clsx';
5
- import IpcUtils from '@ray-js/ray-ipc-utils';
5
+ import { goToIpcPageNativeRoute } from '@ray-js/ray-ipc-utils';
6
6
  import Strings from '../../i18n';
7
7
  import { PlayState } from '../../interface';
8
8
  import { UIEventContext } from '../../ui/context';
@@ -167,7 +167,7 @@ export function RecordVideo(props) {
167
167
  });
168
168
  deleteContent('absolute', RECORD_VIDEO_SUCCESS_TOAST_ID);
169
169
  clearInterval(timer.current);
170
- IpcUtils.goToIpcPageNativeRoute('ipc_album_panel', devId);
170
+ goToIpcPageNativeRoute('ipc_album_panel', devId);
171
171
  };
172
172
 
173
173
  /** 添加录制成功弹窗 */
@@ -2,7 +2,7 @@ import React, { useContext, useRef } from 'react';
2
2
  import { View, Image, Text, showModal, openAppSystemSettingPage } from '@ray-js/ray';
3
3
  import { useSetState, useUpdateEffect, useMemoizedFn } from 'ahooks';
4
4
  import clsx from 'clsx';
5
- import IpcUtils from '@ray-js/ray-ipc-utils';
5
+ import { goToIpcPageNativeRoute } from '@ray-js/ray-ipc-utils';
6
6
  import Strings from '../../i18n';
7
7
  import { useStore } from '../../ctx/store';
8
8
  import { UIEventContext } from '../../ui/context';
@@ -61,7 +61,7 @@ export function Screenshot(props) {
61
61
  });
62
62
  deleteContent('absolute', 'plugin-screenshot-toast');
63
63
  clearInterval(timer.current);
64
- IpcUtils.goToIpcPageNativeRoute('ipc_album_panel', devId);
64
+ goToIpcPageNativeRoute('ipc_album_panel', devId);
65
65
  };
66
66
 
67
67
  /** 添加截屏成功弹窗 */
@@ -1,7 +1,7 @@
1
1
  import React, { useEffect, useState } from 'react';
2
2
  import { View } from '@ray-js/ray';
3
3
  import clsx from 'clsx';
4
- import IpcUtils from '@ray-js/ray-ipc-utils';
4
+ import { getVideoBitrateKbps } from '@ray-js/ray-ipc-utils';
5
5
  import { PlayState } from '../../interface';
6
6
  import './videoBitKBP.less';
7
7
  import { useStore } from '../../ctx/store';
@@ -30,7 +30,7 @@ export const VideoBitKBP = props => {
30
30
  };
31
31
  }, [store.playState]);
32
32
  const init = async () => {
33
- const res = await IpcUtils.getVideoBitrateKbps(devId);
33
+ const res = await getVideoBitrateKbps(devId);
34
34
  if (res.code !== -1) {
35
35
  setBitKBP(`${res.data.kbps}KB/S`);
36
36
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/ipc-player-integration",
3
- "version": "0.0.1-beta-60",
3
+ "version": "0.0.1-beta-61",
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-13",
42
- "@ray-js/ray-ipc-utils": "1.1.0-beta-16",
42
+ "@ray-js/ray-ipc-utils": "1.1.0-beta-17",
43
43
  "@ray-js/svg": "0.2.0",
44
44
  "clsx": "^1.2.1",
45
45
  "jotai": "^2.10.2"