@ray-js/ray-ipc-player 2.0.18-beta-8 → 2.0.20-beta-1

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/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
1
  /// <reference types="react" />
2
- import { IProps } from './typings';
3
2
  declare const Player: (props: IProps) => JSX.Element;
4
3
  export default Player;
package/lib/index.js CHANGED
@@ -6,7 +6,7 @@ import { useImmer } from 'use-immer';
6
6
  import { IpcPlayer, View, CoverView } from '@ray-js/components';
7
7
  import { setPageOrientation, usePageEvent } from '@ray-js/ray';
8
8
  import clsx from 'clsx';
9
- import locals from './i18n';
9
+ import Strings from './i18n';
10
10
  import Styles from './index.module.less';
11
11
  import { IpcFailCode } from './constant';
12
12
  import { putDpData, getIsConnected, getIsOnPreview } from './utils';
@@ -17,7 +17,6 @@ const Player = props => {
17
17
  onChangeStreamStatus,
18
18
  onPlayerTap,
19
19
  onZoomChange,
20
- onSessionDidDisconnected,
21
20
  onCameraPreviewFailure,
22
21
  onCameraNotifyWeakNetwork,
23
22
  onInitPreview,
@@ -40,7 +39,8 @@ const Player = props => {
40
39
  },
41
40
  privateState = false,
42
41
  objectFit = 'contain',
43
- extend = {}
42
+ extend = {},
43
+ brandColor = '#FF592A'
44
44
  } = props;
45
45
  const {
46
46
  borderRadius,
@@ -59,7 +59,8 @@ const Player = props => {
59
59
  errorMsg: '',
60
60
  // 异常信息
61
61
  updateLy: '',
62
- deviceOnlineState: true,
62
+ deviceOnlineState: onlineStatus,
63
+ // 设备在线状态
63
64
  initLy: false
64
65
  });
65
66
  const [screenType, setScreenType] = useState('portrait');
@@ -75,6 +76,7 @@ const Player = props => {
75
76
  usePageEvent('onShow', useCallback(async () => {
76
77
  // 视图准备就绪
77
78
  if (playState.initLy && ipcCtx.current) {
79
+ console.log('retry连接');
78
80
  retry();
79
81
  }
80
82
  }, [playState.connectState, privateState, playState.initLy]));
@@ -108,16 +110,18 @@ const Player = props => {
108
110
  });
109
111
  }, [updateLayout]);
110
112
 
111
- // 设备离线、隐私模式
113
+ /** 监听设备离线、隐私模式 */
112
114
  useEffect(() => {
115
+ console.log(onlineStatus, 'onlineStatus');
113
116
  setPlayState(d => {
114
117
  d.deviceOnlineState = onlineStatus;
115
118
  d.errorState = privateState;
116
119
  });
117
120
  if (!onlineStatus) {
121
+ console.log('监听到设备离线');
118
122
  setPlayState(d => {
119
123
  d.errorState = true;
120
- d.errorMsg = locals.getLang('ipc_player_no_line');
124
+ d.errorMsg = Strings.getLang('ipc_player_no_line');
121
125
  });
122
126
  } else if (playState.initLy && !privateState) {
123
127
  retry();
@@ -140,11 +144,14 @@ const Player = props => {
140
144
  };
141
145
  const retry = useCallback(() => {
142
146
  // console.log('retry:', muteRef.current);
143
- !privateState && _retry();
144
- }, [playState.connectState, privateState]);
147
+ console.log('重新拉流启动');
148
+ onlineStatus && !privateState && _retry();
149
+ }, [playState.connectState, privateState, onlineStatus]);
145
150
 
146
151
  // 创建ipc实例
147
152
  const createIpcCtx = () => {
153
+ console.log('创建ipc实例');
154
+ console.log(onCtx, 'onCtx');
148
155
  onCtx && onCtx({
149
156
  ctx: ipcCtx.current,
150
157
  retry
@@ -171,7 +178,7 @@ const Player = props => {
171
178
  setPlayState(d => {
172
179
  d.connectState = false;
173
180
  d.errorState = true;
174
- d.errorMsg = locals.getLang('ipc_player_connect_fail');
181
+ d.errorMsg = Strings.getLang('ipc_player_connect_fail');
175
182
  d.loadingState = false;
176
183
  });
177
184
  onChangeStreamStatus && onChangeStreamStatus(-1001);
@@ -212,7 +219,7 @@ const Player = props => {
212
219
  setPlayState(d => {
213
220
  d.errorState = true;
214
221
  d.loadingState = false;
215
- d.errorMsg = locals.getLang('ipc_player_preview_fail');
222
+ d.errorMsg = Strings.getLang('ipc_player_preview_fail');
216
223
  });
217
224
  onChangeStreamStatus && onChangeStreamStatus(-1002);
218
225
  },
@@ -279,7 +286,7 @@ const Player = props => {
279
286
  setPlayState(d => {
280
287
  d.loadingState = false;
281
288
  d.errorState = true;
282
- d.errorMsg = locals.getLang(IpcFailCode[type]);
289
+ d.errorMsg = Strings.getLang(IpcFailCode[type]);
283
290
  d.connectState = false;
284
291
  });
285
292
  }
@@ -321,16 +328,14 @@ const Player = props => {
321
328
  return /*#__PURE__*/React.createElement(View, {
322
329
  className: Styles.ipc_player,
323
330
  onClick: handlePlayerClick
324
- }, /*#__PURE__*/React.createElement(IpcPlayer
325
- // @ts-ignore
326
- , _extends({
331
+ }, /*#__PURE__*/React.createElement(IpcPlayer, _extends({
327
332
  className: "".concat(Styles.player, " ").concat(playState.updateLy),
328
333
  onVideoTap: handlePlayerClick,
329
334
  onZoomChange: onZoomChange,
330
335
  onCameraPreviewFailure: onCameraPreviewFailure,
331
336
  onCameraNotifyWeakNetwork: onCameraNotifyWeakNetwork,
332
337
  onInitDone: () => {
333
- // console.log('视图层准备就绪:', devId);
338
+ console.log('视图层准备就绪~');
334
339
  setPlayState(d => {
335
340
  d.updateLy = Math.random();
336
341
  d.initLy = true;
@@ -339,7 +344,7 @@ const Player = props => {
339
344
  onError: onError,
340
345
  onConnectChange: e => {
341
346
  var _e$detail2;
342
- // console.log('连接状态发生变化', e);
347
+ console.log('连接状态发生变化', e);
343
348
  const code = e === null || e === void 0 || (_e$detail2 = e.detail) === null || _e$detail2 === void 0 ? void 0 : _e$detail2.state;
344
349
  onChangeStreamStatus && onChangeStreamStatus(code === 0 ? 1001 : -1001);
345
350
  if (code === 0) {
@@ -355,7 +360,7 @@ const Player = props => {
355
360
  d.connectState = false;
356
361
  d.loadingState = false;
357
362
  d.errorState = true;
358
- d.errorMsg = locals.getLang(IpcFailCode[-1001]);
363
+ d.errorMsg = Strings.getLang(IpcFailCode[-1001]);
359
364
  });
360
365
  }
361
366
  },
@@ -378,19 +383,25 @@ const Player = props => {
378
383
  style: {
379
384
  borderRadius: "".concat(borderRadius)
380
385
  },
381
- className: clsx(Styles.load_box, Styles.bg_center, !playState.loadingState && Styles.hide)
386
+ className: clsx(Styles.load_box, Styles.bg_center, !playState.loadingState && Styles.hide),
387
+ onClick: () => {
388
+ return false;
389
+ }
382
390
  }, /*#__PURE__*/React.createElement(View, {
383
391
  className: Styles.load_icon
384
392
  }), /*#__PURE__*/React.createElement(View, {
385
393
  className: Styles.load_des
386
- }, loadText || locals.getLang('ipc_player_get_video_stream'))), /*#__PURE__*/React.createElement(CoverView, {
394
+ }, loadText || Strings.getLang('ipc_player_get_video_stream'))), /*#__PURE__*/React.createElement(CoverView, {
387
395
  style: {
388
396
  borderRadius: "".concat(borderRadius)
389
397
  },
390
- className: clsx(Styles.bg_center, Styles.state_label, !playState.errorState && Styles.hide)
398
+ className: clsx(Styles.bg_center, Styles.state_label, !playState.errorState && Styles.hide),
399
+ onClick: () => {
400
+ return false;
401
+ }
391
402
  }, privateState && /*#__PURE__*/React.createElement(View, null, /*#__PURE__*/React.createElement(View, {
392
403
  className: Styles.device_sleep
393
- }, locals.getLang('ipc_player_device_sleep')), /*#__PURE__*/React.createElement(View, {
404
+ }, Strings.getLang('ipc_player_device_sleep')), /*#__PURE__*/React.createElement(View, {
394
405
  className: Styles.re_wake_camera
395
406
  // @ts-ignore
396
407
  ,
@@ -399,7 +410,7 @@ const Player = props => {
399
410
  105: false
400
411
  }, devId);
401
412
  }
402
- }, locals.getLang('ipc_player_re_wake_camera'))), !privateState && /*#__PURE__*/React.createElement(View, {
413
+ }, Strings.getLang('ipc_player_re_wake_camera'))), !privateState && /*#__PURE__*/React.createElement(View, {
403
414
  className: clsx(Styles.err_container)
404
415
  }, /*#__PURE__*/React.createElement(View, {
405
416
  className: clsx(Styles.iconfont, Styles.icon_tishi, !playState.deviceOnlineState && Styles.hide)
@@ -407,12 +418,12 @@ const Player = props => {
407
418
  className: Styles.err_msg
408
419
  }, /*#__PURE__*/React.createElement(View, {
409
420
  className: clsx(Styles.msg, Styles.ellipsis)
410
- }, playState.errorMsg), /*#__PURE__*/React.createElement(View
421
+ }, playState.deviceOnlineState ? playState.errorMsg : Strings.getLang('ipc_player_no_line')), /*#__PURE__*/React.createElement(View
411
422
  // @ts-ignore
412
423
  , {
413
424
  onClick: retry,
414
425
  className: clsx(Styles.retry, !playState.deviceOnlineState && Styles.hide)
415
- }, locals.getLang('ipc_player_retry'))))), screenType === 'landscape' && (playState.loadingState || playState.errorState) && /*#__PURE__*/React.createElement(CoverView, {
426
+ }, Strings.getLang('ipc_player_retry'))))), screenType === 'landscape' && (playState.loadingState || playState.errorState) && /*#__PURE__*/React.createElement(CoverView, {
416
427
  className: clsx(Styles.load_full_back_container),
417
428
  onClick: () => {
418
429
  setPageOrientation({
@@ -39,7 +39,7 @@
39
39
  }
40
40
 
41
41
  :root[theme='dark'] {
42
- --video-bg: rgba(255, 255, 255, 0.1);
42
+ --video-bg: #000000;
43
43
  }
44
44
 
45
45
  .load_icon {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/ray-ipc-player",
3
- "version": "2.0.18-beta-8",
3
+ "version": "2.0.20-beta-1",
4
4
  "description": "ray小程序播放器",
5
5
  "keywords": [
6
6
  "tuya-miniapp",
@@ -1,149 +0,0 @@
1
- declare module '*.module.less' {
2
- const classes: {
3
- readonly [key: string]: string;
4
- };
5
- export default classes;
6
- declare module '*.less';
7
- }
8
- export type IProps = {
9
- /**
10
- * @description.en devId
11
- * @description.zh 设备id
12
- * @default ""
13
- */
14
- devId: string;
15
- /**
16
- * @description.en onlineStatus
17
- * @description.zh 设备是否在线
18
- * @default true
19
- */
20
- onlineStatus: boolean;
21
- /**
22
- * @description.en privateState
23
- * @description.zh 隐私模式
24
- * @default false
25
- */
26
- privateState?: boolean;
27
- /**
28
- * @description.en defaultMute
29
- * @description.zh 默认静音
30
- * @default true
31
- */
32
- defaultMute?: boolean;
33
- /**
34
- * @description.en clarity
35
- * @description.zh 清晰度 normal:标清,hd:高清
36
- * @default "normal"
37
- */
38
- clarity?: 'normal' | 'hd';
39
- /**
40
- * @description.en updateLayout
41
- * @description.zh 外层父节点样式变化,播放器监听不到,需要主动触发播放器视图更新,每次需要设置不同的字符串值
42
- * @default ""
43
- */
44
- updateLayout?: any;
45
- /**
46
- * @description.en IPC Player instance. If not passed, an instance will be generated inside the component.
47
- * @description.zh IPC Player实例,如果不传组件内部会生成实例
48
- * @default ""
49
- */
50
- ipcPlayerContext?: IpcContext;
51
- /**
52
- * @description.en onChangeStreamStatus
53
- * @description.zh 通知视频流状态发生变化
54
- * @default (data) => void
55
- */
56
- onChangeStreamStatus?: (data) => void;
57
- /**
58
- * @description.en onCtx
59
- * @description.zh 获取ipcPlayer实例ctx以及重试方法retry
60
- * @default (playerRef) => void
61
- */
62
- onCtx?: (playerRef) => void;
63
- /**
64
- * @description.en onInitPreview
65
- * @description.zh 初始化预览成功通知
66
- * @default (devId) => void
67
- */
68
- onInitPreview?: (data) => void;
69
- /**
70
- * @description.en onPlayerTap
71
- * @description.zh 播放器区域点击事件
72
- * @default (devId) => void
73
- */
74
- onPlayerTap?: (data) => void;
75
- /**
76
- * @description.en onZoomchange
77
- * @description.zh 视频缩放比例及当前倍数变化,detail = { zoomLevel }, zoomLevel 为缩放比例
78
- */
79
- onZoomChange?: (data) => void;
80
- /**
81
- * @description.en onSessionDidDisconnected
82
- * @description.zh 事件:session断开事件
83
- */
84
- onSessionDidDisconnected?: (data) => void;
85
- /**
86
- * @description.en onCameraPreviewFailure
87
- * @description.zh 事件:预览失败,错误码监听事件
88
- */
89
- onCameraPreviewFailure?: (data) => void;
90
- /**
91
- * @description.en onCameraNotifyWeakNetwork
92
- * @description.zh 事件:画面网速监听状态值事件
93
- */
94
- onCameraNotifyWeakNetwork?: (data) => void;
95
- /**
96
- * @description.en scalable
97
- * @description.zh 是否可缩放
98
- * @default true
99
- */
100
- scalable?: boolean;
101
- /**
102
- * @description.en scaleMultiple
103
- * @description.zh 缩放比例
104
- * @default 0
105
- */
106
- scaleMultiple?: number;
107
- /**
108
- * @description.en rotateZ
109
- * @description.zh 摄像头旋转角度
110
- * @default 0
111
- */
112
- rotateZ?: number;
113
- /**
114
- * @description.en ptzControllable
115
- * @description.zh 是否开启视频区云平台控制
116
- * @default true
117
- */
118
- ptzControllable?: boolean;
119
- /**
120
- * @description.en playerStyle
121
- * @description.zh 播放器样式
122
- * @default {}
123
- */
124
- playerStyle?: {
125
- bgColor?: string; // 背景底色
126
- borderRadius?: number | string; // 边框圆角
127
- borderStyle?: 'solid' | 'dashed'; // 边框样式
128
- borderColor?: string; // 边框颜色
129
- borderWidth?: string | number; // 边框宽度
130
- };
131
- /**
132
- * @description.en loadText
133
- * @description.zh 加载过程中的文案,可结合onChangeStreamStatus事件做文案配置
134
- * @default "正在获取视频流..."
135
- */
136
- loadText?: string;
137
- /**
138
- * @description.en objectFit:contain|fillCrop
139
- * @description.zh 填充模式设置:contain: 图像长边填满屏幕,短边区域会被填充⿊⾊, fillCrop: 图像铺满屏幕
140
- * @default "contain"
141
- */
142
- objectFit?: string;
143
- /**
144
- * @description.en extend
145
- * @description.zh 扩展属性
146
- * @default {}
147
- */
148
- extend?: Record<string, any>;
149
- };