@ray-js/ray-ipc-player 2.0.19-beta-beta-1 → 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 +0 -1
- package/lib/index.js +32 -23
- package/lib/index.module.less +1 -1
- package/package.json +1 -1
- package/lib/typings/index.d.ts +0 -149
package/lib/index.d.ts
CHANGED
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
|
|
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';
|
|
@@ -39,7 +39,8 @@ const Player = props => {
|
|
|
39
39
|
},
|
|
40
40
|
privateState = false,
|
|
41
41
|
objectFit = 'contain',
|
|
42
|
-
extend = {}
|
|
42
|
+
extend = {},
|
|
43
|
+
brandColor = '#FF592A'
|
|
43
44
|
} = props;
|
|
44
45
|
const {
|
|
45
46
|
borderRadius,
|
|
@@ -58,7 +59,8 @@ const Player = props => {
|
|
|
58
59
|
errorMsg: '',
|
|
59
60
|
// 异常信息
|
|
60
61
|
updateLy: '',
|
|
61
|
-
deviceOnlineState:
|
|
62
|
+
deviceOnlineState: onlineStatus,
|
|
63
|
+
// 设备在线状态
|
|
62
64
|
initLy: false
|
|
63
65
|
});
|
|
64
66
|
const [screenType, setScreenType] = useState('portrait');
|
|
@@ -74,6 +76,7 @@ const Player = props => {
|
|
|
74
76
|
usePageEvent('onShow', useCallback(async () => {
|
|
75
77
|
// 视图准备就绪
|
|
76
78
|
if (playState.initLy && ipcCtx.current) {
|
|
79
|
+
console.log('retry连接');
|
|
77
80
|
retry();
|
|
78
81
|
}
|
|
79
82
|
}, [playState.connectState, privateState, playState.initLy]));
|
|
@@ -107,7 +110,7 @@ const Player = props => {
|
|
|
107
110
|
});
|
|
108
111
|
}, [updateLayout]);
|
|
109
112
|
|
|
110
|
-
|
|
113
|
+
/** 监听设备离线、隐私模式 */
|
|
111
114
|
useEffect(() => {
|
|
112
115
|
console.log(onlineStatus, 'onlineStatus');
|
|
113
116
|
setPlayState(d => {
|
|
@@ -115,9 +118,10 @@ const Player = props => {
|
|
|
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 =
|
|
124
|
+
d.errorMsg = Strings.getLang('ipc_player_no_line');
|
|
121
125
|
});
|
|
122
126
|
} else if (playState.initLy && !privateState) {
|
|
123
127
|
retry();
|
|
@@ -140,8 +144,9 @@ const Player = props => {
|
|
|
140
144
|
};
|
|
141
145
|
const retry = useCallback(() => {
|
|
142
146
|
// console.log('retry:', muteRef.current);
|
|
143
|
-
|
|
144
|
-
|
|
147
|
+
console.log('重新拉流启动');
|
|
148
|
+
onlineStatus && !privateState && _retry();
|
|
149
|
+
}, [playState.connectState, privateState, onlineStatus]);
|
|
145
150
|
|
|
146
151
|
// 创建ipc实例
|
|
147
152
|
const createIpcCtx = () => {
|
|
@@ -173,7 +178,7 @@ const Player = props => {
|
|
|
173
178
|
setPlayState(d => {
|
|
174
179
|
d.connectState = false;
|
|
175
180
|
d.errorState = true;
|
|
176
|
-
d.errorMsg =
|
|
181
|
+
d.errorMsg = Strings.getLang('ipc_player_connect_fail');
|
|
177
182
|
d.loadingState = false;
|
|
178
183
|
});
|
|
179
184
|
onChangeStreamStatus && onChangeStreamStatus(-1001);
|
|
@@ -214,7 +219,7 @@ const Player = props => {
|
|
|
214
219
|
setPlayState(d => {
|
|
215
220
|
d.errorState = true;
|
|
216
221
|
d.loadingState = false;
|
|
217
|
-
d.errorMsg =
|
|
222
|
+
d.errorMsg = Strings.getLang('ipc_player_preview_fail');
|
|
218
223
|
});
|
|
219
224
|
onChangeStreamStatus && onChangeStreamStatus(-1002);
|
|
220
225
|
},
|
|
@@ -281,7 +286,7 @@ const Player = props => {
|
|
|
281
286
|
setPlayState(d => {
|
|
282
287
|
d.loadingState = false;
|
|
283
288
|
d.errorState = true;
|
|
284
|
-
d.errorMsg =
|
|
289
|
+
d.errorMsg = Strings.getLang(IpcFailCode[type]);
|
|
285
290
|
d.connectState = false;
|
|
286
291
|
});
|
|
287
292
|
}
|
|
@@ -323,16 +328,14 @@ const Player = props => {
|
|
|
323
328
|
return /*#__PURE__*/React.createElement(View, {
|
|
324
329
|
className: Styles.ipc_player,
|
|
325
330
|
onClick: handlePlayerClick
|
|
326
|
-
}, /*#__PURE__*/React.createElement(IpcPlayer
|
|
327
|
-
// @ts-ignore
|
|
328
|
-
, _extends({
|
|
331
|
+
}, /*#__PURE__*/React.createElement(IpcPlayer, _extends({
|
|
329
332
|
className: "".concat(Styles.player, " ").concat(playState.updateLy),
|
|
330
333
|
onVideoTap: handlePlayerClick,
|
|
331
334
|
onZoomChange: onZoomChange,
|
|
332
335
|
onCameraPreviewFailure: onCameraPreviewFailure,
|
|
333
336
|
onCameraNotifyWeakNetwork: onCameraNotifyWeakNetwork,
|
|
334
337
|
onInitDone: () => {
|
|
335
|
-
|
|
338
|
+
console.log('视图层准备就绪~');
|
|
336
339
|
setPlayState(d => {
|
|
337
340
|
d.updateLy = Math.random();
|
|
338
341
|
d.initLy = true;
|
|
@@ -341,7 +344,7 @@ const Player = props => {
|
|
|
341
344
|
onError: onError,
|
|
342
345
|
onConnectChange: e => {
|
|
343
346
|
var _e$detail2;
|
|
344
|
-
|
|
347
|
+
console.log('连接状态发生变化', e);
|
|
345
348
|
const code = e === null || e === void 0 || (_e$detail2 = e.detail) === null || _e$detail2 === void 0 ? void 0 : _e$detail2.state;
|
|
346
349
|
onChangeStreamStatus && onChangeStreamStatus(code === 0 ? 1001 : -1001);
|
|
347
350
|
if (code === 0) {
|
|
@@ -357,7 +360,7 @@ const Player = props => {
|
|
|
357
360
|
d.connectState = false;
|
|
358
361
|
d.loadingState = false;
|
|
359
362
|
d.errorState = true;
|
|
360
|
-
d.errorMsg =
|
|
363
|
+
d.errorMsg = Strings.getLang(IpcFailCode[-1001]);
|
|
361
364
|
});
|
|
362
365
|
}
|
|
363
366
|
},
|
|
@@ -380,19 +383,25 @@ const Player = props => {
|
|
|
380
383
|
style: {
|
|
381
384
|
borderRadius: "".concat(borderRadius)
|
|
382
385
|
},
|
|
383
|
-
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
|
+
}
|
|
384
390
|
}, /*#__PURE__*/React.createElement(View, {
|
|
385
391
|
className: Styles.load_icon
|
|
386
392
|
}), /*#__PURE__*/React.createElement(View, {
|
|
387
393
|
className: Styles.load_des
|
|
388
|
-
}, loadText ||
|
|
394
|
+
}, loadText || Strings.getLang('ipc_player_get_video_stream'))), /*#__PURE__*/React.createElement(CoverView, {
|
|
389
395
|
style: {
|
|
390
396
|
borderRadius: "".concat(borderRadius)
|
|
391
397
|
},
|
|
392
|
-
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
|
+
}
|
|
393
402
|
}, privateState && /*#__PURE__*/React.createElement(View, null, /*#__PURE__*/React.createElement(View, {
|
|
394
403
|
className: Styles.device_sleep
|
|
395
|
-
},
|
|
404
|
+
}, Strings.getLang('ipc_player_device_sleep')), /*#__PURE__*/React.createElement(View, {
|
|
396
405
|
className: Styles.re_wake_camera
|
|
397
406
|
// @ts-ignore
|
|
398
407
|
,
|
|
@@ -401,7 +410,7 @@ const Player = props => {
|
|
|
401
410
|
105: false
|
|
402
411
|
}, devId);
|
|
403
412
|
}
|
|
404
|
-
},
|
|
413
|
+
}, Strings.getLang('ipc_player_re_wake_camera'))), !privateState && /*#__PURE__*/React.createElement(View, {
|
|
405
414
|
className: clsx(Styles.err_container)
|
|
406
415
|
}, /*#__PURE__*/React.createElement(View, {
|
|
407
416
|
className: clsx(Styles.iconfont, Styles.icon_tishi, !playState.deviceOnlineState && Styles.hide)
|
|
@@ -409,12 +418,12 @@ const Player = props => {
|
|
|
409
418
|
className: Styles.err_msg
|
|
410
419
|
}, /*#__PURE__*/React.createElement(View, {
|
|
411
420
|
className: clsx(Styles.msg, Styles.ellipsis)
|
|
412
|
-
}, playState.errorMsg), /*#__PURE__*/React.createElement(View
|
|
421
|
+
}, playState.deviceOnlineState ? playState.errorMsg : Strings.getLang('ipc_player_no_line')), /*#__PURE__*/React.createElement(View
|
|
413
422
|
// @ts-ignore
|
|
414
423
|
, {
|
|
415
424
|
onClick: retry,
|
|
416
425
|
className: clsx(Styles.retry, !playState.deviceOnlineState && Styles.hide)
|
|
417
|
-
},
|
|
426
|
+
}, Strings.getLang('ipc_player_retry'))))), screenType === 'landscape' && (playState.loadingState || playState.errorState) && /*#__PURE__*/React.createElement(CoverView, {
|
|
418
427
|
className: clsx(Styles.load_full_back_container),
|
|
419
428
|
onClick: () => {
|
|
420
429
|
setPageOrientation({
|
package/lib/index.module.less
CHANGED
package/package.json
CHANGED
package/lib/typings/index.d.ts
DELETED
|
@@ -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
|
-
};
|