@ray-js/ray-ipc-player 2.0.20-beta-2 → 2.0.20-beta-3
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/config/errCodeConfig.d.ts +43 -0
- package/lib/config/errCodeConfig.js +136 -0
- package/lib/config/index.d.ts +14 -0
- package/lib/config/index.js +19 -0
- package/lib/constant.d.ts +1 -1
- package/lib/constant.js +1 -1
- package/lib/i18n/index.d.ts +404 -4
- package/lib/i18n/strings.d.ts +202 -2
- package/lib/i18n/strings.js +230 -6
- package/lib/index.js +349 -71
- package/lib/index.module.less +92 -6
- package/lib/svg/errIcon.svg +7 -0
- package/lib/svg/index.d.ts +2 -0
- package/lib/svg/index.js +1 -0
- package/lib/utils.d.ts +30 -1
- package/lib/utils.js +112 -18
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import "core-js/modules/es.json.stringify.js";
|
|
2
3
|
import "core-js/modules/web.dom-collections.iterator.js";
|
|
3
4
|
/* eslint-disable no-unneeded-ternary */
|
|
4
5
|
import React, { useState, useEffect, useRef, useCallback } from 'react';
|
|
5
6
|
import { useImmer } from 'use-immer';
|
|
7
|
+
import _isEmpty from 'lodash/isEmpty';
|
|
6
8
|
import { IpcPlayer, View, CoverView } from '@ray-js/components';
|
|
7
|
-
import {
|
|
9
|
+
import { useMount, useUnmount } from 'ahooks';
|
|
10
|
+
import { setPageOrientation, usePageEvent, getNetworkType, offNetworkStatusChange, onNetworkStatusChange, publishDps, showToast } from '@ray-js/ray';
|
|
8
11
|
import clsx from 'clsx';
|
|
9
12
|
import Strings from './i18n';
|
|
10
13
|
import Styles from './index.module.less';
|
|
11
14
|
import { IpcFailCode } from './constant';
|
|
12
|
-
import {
|
|
15
|
+
import { getIsConnected, getIsOnPreview, openTargetMinByShortLink, getLanguage, getHomeInfo, getDeviceInfo, getDpIdByDpCode, ipcTTTOperatorLog } from './utils';
|
|
16
|
+
import { getErrCodeDetailDataByCode, codeCoverToInt } from './config/errCodeConfig';
|
|
17
|
+
import { deviceFreezeReasonStore, miniIdLabs } from './config';
|
|
13
18
|
const Player = props => {
|
|
14
19
|
const {
|
|
15
20
|
updateLayout = '',
|
|
@@ -40,7 +45,10 @@ const Player = props => {
|
|
|
40
45
|
privateState = false,
|
|
41
46
|
objectFit = 'contain',
|
|
42
47
|
extend = {},
|
|
43
|
-
brandColor = '#FF592A'
|
|
48
|
+
brandColor = '#FF592A',
|
|
49
|
+
renderErrIcon,
|
|
50
|
+
isShare = false,
|
|
51
|
+
onPlayerContainerTap
|
|
44
52
|
} = props;
|
|
45
53
|
const {
|
|
46
54
|
borderRadius,
|
|
@@ -64,6 +72,19 @@ const Player = props => {
|
|
|
64
72
|
initLy: false
|
|
65
73
|
});
|
|
66
74
|
const [screenType, setScreenType] = useState('portrait');
|
|
75
|
+
const [videoErrCode, setVideoErrCode] = useState('');
|
|
76
|
+
// 标记是否为配置149的老方案低功耗设备 待实现
|
|
77
|
+
const [isLowPowerDevice, setIsLowPowerDevice] = useState(false);
|
|
78
|
+
// 自定义计时老低功耗方案设备在线状态, 用于短暂时间报上下线的UI展示兼容 待实现
|
|
79
|
+
const [lowPowerDeviceOnlineState, setLowPowerDeviceOnlineState] = useState(true);
|
|
80
|
+
// 4G设备是否被冻结, 待实现
|
|
81
|
+
const [device4GIsFreeze, setDevice4GIsFreeze] = useState(false);
|
|
82
|
+
// 4G设备冻结原因, 待实现
|
|
83
|
+
const [deviceFreezeReason, setDeviceFreezeReason] = useState(1);
|
|
84
|
+
// 4G设备流量是否不足
|
|
85
|
+
const [trafficLessOrEqualZero, setTrafficLessOrEqualZero] = useState(false);
|
|
86
|
+
// 手机连接网络状态
|
|
87
|
+
const [phoneNetworkConnect, setPhoneNetworkConnect] = useState(true);
|
|
67
88
|
const ipcCtx = useRef(null); // ipc实例
|
|
68
89
|
if (!ipcCtx.current) {
|
|
69
90
|
var _ty;
|
|
@@ -75,17 +96,34 @@ const Player = props => {
|
|
|
75
96
|
|
|
76
97
|
usePageEvent('onShow', useCallback(async () => {
|
|
77
98
|
// 视图准备就绪
|
|
78
|
-
if (playState.initLy && ipcCtx.current) {
|
|
79
|
-
|
|
99
|
+
if (phoneNetworkConnect && playState.initLy && ipcCtx.current && onlineStatus && !privateState) {
|
|
100
|
+
ipcTTTOperatorLog('VID: onShow_event_to_retry');
|
|
80
101
|
retry();
|
|
81
102
|
}
|
|
82
|
-
}, [playState.connectState, privateState, playState.initLy]));
|
|
103
|
+
}, [phoneNetworkConnect, onlineStatus && playState.connectState, privateState, playState.initLy]));
|
|
104
|
+
usePageEvent('onShow', () => {
|
|
105
|
+
getNetworkType({
|
|
106
|
+
success: res => {
|
|
107
|
+
setPhoneNetworkConnect(res.networkType !== 'none');
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
});
|
|
83
111
|
usePageEvent('onResize', sizeData => {
|
|
84
112
|
const {
|
|
85
113
|
type
|
|
86
114
|
} = sizeData;
|
|
87
115
|
setScreenType(type);
|
|
88
116
|
});
|
|
117
|
+
useMount(() => {
|
|
118
|
+
onNetworkStatusChange(res => {
|
|
119
|
+
setPhoneNetworkConnect(res.isConnected);
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
useUnmount(() => {
|
|
123
|
+
offNetworkStatusChange(res => {
|
|
124
|
+
console.log(res);
|
|
125
|
+
});
|
|
126
|
+
});
|
|
89
127
|
usePageEvent('onHide', async () => {
|
|
90
128
|
setPlayState(d => {
|
|
91
129
|
d.loadingState = true;
|
|
@@ -110,23 +148,28 @@ const Player = props => {
|
|
|
110
148
|
});
|
|
111
149
|
}, [updateLayout]);
|
|
112
150
|
|
|
113
|
-
/**
|
|
151
|
+
/** 监听设备离线、隐私模式及手机网络状态 */
|
|
114
152
|
useEffect(() => {
|
|
115
153
|
console.log(onlineStatus, 'onlineStatus');
|
|
116
154
|
setPlayState(d => {
|
|
117
155
|
d.deviceOnlineState = onlineStatus;
|
|
118
|
-
d.errorState = privateState;
|
|
156
|
+
d.errorState = privateState || !phoneNetworkConnect;
|
|
119
157
|
});
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
158
|
+
ipcTTTOperatorLog("VID: device_online_status_change: ".concat(onlineStatus));
|
|
159
|
+
if (phoneNetworkConnect) {
|
|
160
|
+
if (!onlineStatus) {
|
|
161
|
+
ipcTTTOperatorLog("VID: device_offline_show_text");
|
|
162
|
+
console.log('监听到设备离线');
|
|
163
|
+
setPlayState(d => {
|
|
164
|
+
d.errorState = true;
|
|
165
|
+
d.errorMsg = Strings.getLang('ipc_player_device_offline');
|
|
166
|
+
});
|
|
167
|
+
} else if (playState.initLy && !privateState) {
|
|
168
|
+
ipcTTTOperatorLog("VID: privateState_status_change: ".concat(privateState));
|
|
169
|
+
retry();
|
|
170
|
+
}
|
|
128
171
|
}
|
|
129
|
-
}, [onlineStatus, playState.initLy, privateState]);
|
|
172
|
+
}, [phoneNetworkConnect, onlineStatus, playState.initLy, privateState]);
|
|
130
173
|
|
|
131
174
|
// 重试
|
|
132
175
|
const _retry = async () => {
|
|
@@ -138,15 +181,41 @@ const Player = props => {
|
|
|
138
181
|
d.errorState = false;
|
|
139
182
|
d.loadingState = isOnPreview ? false : true;
|
|
140
183
|
});
|
|
184
|
+
setVideoErrCode('');
|
|
141
185
|
// !prePlayRef.current && connectState && (await disconnect());
|
|
142
186
|
// console.log(connectState, isOnPreview, '当前链接状态和预览状态');
|
|
187
|
+
ipcTTTOperatorLog("VID: start_create_p2p_connect");
|
|
143
188
|
ipcCtx.current && createConnect();
|
|
144
189
|
};
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* 关闭隐私模式,重新拉流
|
|
193
|
+
*/
|
|
194
|
+
const handleReWakeCamera = async () => {
|
|
195
|
+
const sendDpId = await getDpIdByDpCode(devId, 'basic_private');
|
|
196
|
+
if (sendDpId === -1) {
|
|
197
|
+
showToast(Strings.getLang('ipc_player_basic_private_not_exist'));
|
|
198
|
+
} else {
|
|
199
|
+
publishDps({
|
|
200
|
+
deviceId: devId,
|
|
201
|
+
dps: {
|
|
202
|
+
[sendDpId]: false
|
|
203
|
+
},
|
|
204
|
+
mode: 1,
|
|
205
|
+
pipelines: [0, 1, 2, 3, 4, 5, 6],
|
|
206
|
+
options: {},
|
|
207
|
+
success: () => {
|
|
208
|
+
console.log('下发隐私模式成功');
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
};
|
|
145
213
|
const retry = useCallback(() => {
|
|
146
214
|
// console.log('retry:', muteRef.current);
|
|
147
215
|
console.log('重新拉流启动');
|
|
148
|
-
onlineStatus &&
|
|
149
|
-
|
|
216
|
+
phoneNetworkConnect && onlineStatus && privateState && !isLowPowerDevice && handleReWakeCamera();
|
|
217
|
+
phoneNetworkConnect && onlineStatus && !privateState && _retry();
|
|
218
|
+
}, [isLowPowerDevice, phoneNetworkConnect && playState.connectState, privateState, onlineStatus]);
|
|
150
219
|
|
|
151
220
|
// 创建ipc实例
|
|
152
221
|
const createIpcCtx = () => {
|
|
@@ -164,17 +233,18 @@ const Player = props => {
|
|
|
164
233
|
// console.log('建立连接前:', devId, Date.now());
|
|
165
234
|
(_ipcCtx$current = ipcCtx.current) === null || _ipcCtx$current === void 0 || _ipcCtx$current.connect({
|
|
166
235
|
success: () => {
|
|
167
|
-
|
|
236
|
+
ipcTTTOperatorLog("VID: create_p2p_connect_success");
|
|
168
237
|
setPlayState(d => {
|
|
169
238
|
d.connectState = true;
|
|
170
239
|
d.errorState = false;
|
|
171
240
|
d.errorMsg = '';
|
|
172
241
|
});
|
|
173
242
|
onChangeStreamStatus && onChangeStreamStatus(1001);
|
|
243
|
+
ipcTTTOperatorLog("VID: start_to_preview");
|
|
174
244
|
startPreview(params);
|
|
175
245
|
},
|
|
176
246
|
fail: () => {
|
|
177
|
-
|
|
247
|
+
ipcTTTOperatorLog("VID: create_p2p_connect_failure");
|
|
178
248
|
setPlayState(d => {
|
|
179
249
|
d.connectState = false;
|
|
180
250
|
d.errorState = true;
|
|
@@ -188,12 +258,15 @@ const Player = props => {
|
|
|
188
258
|
|
|
189
259
|
// 视图层准备就绪,开始建立连接
|
|
190
260
|
|
|
191
|
-
|
|
261
|
+
/*
|
|
262
|
+
* 开启预览
|
|
263
|
+
*/
|
|
192
264
|
const startPreview = params => {
|
|
193
265
|
var _ipcCtx$current2;
|
|
194
266
|
// console.log('开启预览前');
|
|
195
267
|
(_ipcCtx$current2 = ipcCtx.current) === null || _ipcCtx$current2 === void 0 || _ipcCtx$current2.startPreview({
|
|
196
268
|
success: () => {
|
|
269
|
+
ipcTTTOperatorLog('VID: start_preview_success');
|
|
197
270
|
// console.log('开启预览:', devId);
|
|
198
271
|
setPlayState(d => {
|
|
199
272
|
d.loadingState = false;
|
|
@@ -204,7 +277,9 @@ const Player = props => {
|
|
|
204
277
|
onChangeStreamStatus && onChangeStreamStatus(1002);
|
|
205
278
|
},
|
|
206
279
|
fail: async e => {
|
|
280
|
+
ipcTTTOperatorLog("VID: start_preview_fail: ".concat(JSON.stringify(e)));
|
|
207
281
|
const isOnPreview = await getIsOnPreview(ipcCtx.current);
|
|
282
|
+
ipcTTTOperatorLog("VID: get_is_on_preview_status_".concat(isOnPreview));
|
|
208
283
|
// console.error('开启失败:', e, devId, isOnPreview);
|
|
209
284
|
if (!isOnPreview || e !== null && e !== void 0 && e.errorMsg.includes('doing preview')) {
|
|
210
285
|
// 忽略重复预览异常的报错
|
|
@@ -230,41 +305,55 @@ const Player = props => {
|
|
|
230
305
|
});
|
|
231
306
|
};
|
|
232
307
|
|
|
233
|
-
|
|
308
|
+
/**
|
|
309
|
+
* 暂停预览
|
|
310
|
+
*/
|
|
234
311
|
const stopPreview = () => {
|
|
235
312
|
var _ipcCtx$current3;
|
|
313
|
+
ipcTTTOperatorLog("VID: begin_to_stop_preview");
|
|
236
314
|
(_ipcCtx$current3 = ipcCtx.current) === null || _ipcCtx$current3 === void 0 || _ipcCtx$current3.stopPreview({
|
|
237
|
-
success: () =>
|
|
238
|
-
|
|
315
|
+
success: () => {
|
|
316
|
+
ipcTTTOperatorLog("VID: stop_preview_success");
|
|
317
|
+
},
|
|
318
|
+
fail: e => {
|
|
319
|
+
ipcTTTOperatorLog("VID: stop_preview_failure: ".concat(JSON.stringify(e)));
|
|
320
|
+
},
|
|
239
321
|
complete: () => setMuted(true)
|
|
240
322
|
});
|
|
241
323
|
};
|
|
242
324
|
|
|
243
|
-
|
|
325
|
+
/**
|
|
326
|
+
* 设置声音
|
|
327
|
+
*/
|
|
244
328
|
const setMuted = val => {
|
|
245
329
|
var _ipcCtx$current4;
|
|
330
|
+
ipcTTTOperatorLog("VID: begin_to_set_mute");
|
|
246
331
|
(_ipcCtx$current4 = ipcCtx.current) === null || _ipcCtx$current4 === void 0 || _ipcCtx$current4.setMuted({
|
|
247
332
|
mute: val,
|
|
248
333
|
success: () => {
|
|
249
|
-
|
|
334
|
+
ipcTTTOperatorLog("VID: set_mute_success: ".concat(val));
|
|
250
335
|
},
|
|
251
336
|
fail: () => {
|
|
252
|
-
|
|
337
|
+
ipcTTTOperatorLog("VID: set_mute_failure: ".concat(val));
|
|
253
338
|
}
|
|
254
339
|
});
|
|
255
340
|
};
|
|
256
341
|
|
|
257
|
-
|
|
342
|
+
/**
|
|
343
|
+
* 获取当前是否静音
|
|
344
|
+
*/
|
|
258
345
|
const getCurMute = () => {
|
|
346
|
+
ipcTTTOperatorLog("VID: begin_to_get_cur_mute");
|
|
259
347
|
return new Promise((resolve, reject) => {
|
|
260
348
|
var _ipcCtx$current5;
|
|
261
349
|
(_ipcCtx$current5 = ipcCtx.current) === null || _ipcCtx$current5 === void 0 || _ipcCtx$current5.isMuted({
|
|
262
350
|
success: res => {
|
|
351
|
+
ipcTTTOperatorLog("VID: get_cur_mute_success: ".concat(res));
|
|
263
352
|
muteRef.current = res;
|
|
264
353
|
},
|
|
265
354
|
fail: e => {
|
|
355
|
+
ipcTTTOperatorLog("VID: get_cur_mute_failure: ".concat(JSON.stringify(e)));
|
|
266
356
|
reject(e);
|
|
267
|
-
// console.log(e);
|
|
268
357
|
},
|
|
269
358
|
complete: d => {
|
|
270
359
|
resolve(d);
|
|
@@ -275,18 +364,21 @@ const Player = props => {
|
|
|
275
364
|
|
|
276
365
|
// 异常事件
|
|
277
366
|
const onError = useCallback(e => {
|
|
278
|
-
|
|
367
|
+
ipcTTTOperatorLog("VID: player_event_on_error: ".concat(JSON.stringify(e)));
|
|
279
368
|
if (playState.errorState) {
|
|
280
369
|
return;
|
|
281
370
|
}
|
|
282
|
-
|
|
283
|
-
const
|
|
284
|
-
|
|
285
|
-
|
|
371
|
+
console.error('发生异常事件:', e);
|
|
372
|
+
const {
|
|
373
|
+
errCode
|
|
374
|
+
} = e === null || e === void 0 ? void 0 : e.detail;
|
|
375
|
+
setVideoErrCode(errCode);
|
|
376
|
+
if (IpcFailCode[errCode]) {
|
|
377
|
+
onChangeStreamStatus && onChangeStreamStatus(errCode);
|
|
286
378
|
setPlayState(d => {
|
|
287
379
|
d.loadingState = false;
|
|
288
380
|
d.errorState = true;
|
|
289
|
-
d.errorMsg = Strings.getLang(IpcFailCode[
|
|
381
|
+
d.errorMsg = Strings.getLang(IpcFailCode[errCode]);
|
|
290
382
|
d.connectState = false;
|
|
291
383
|
});
|
|
292
384
|
}
|
|
@@ -316,26 +408,211 @@ const Player = props => {
|
|
|
316
408
|
});
|
|
317
409
|
});
|
|
318
410
|
};
|
|
319
|
-
const handlePlayerClick = () => {
|
|
320
|
-
// console.log("videoTap:", devId);
|
|
321
|
-
onPlayerTap && onPlayerTap(devId);
|
|
322
|
-
};
|
|
323
411
|
|
|
324
|
-
|
|
412
|
+
/**
|
|
413
|
+
* 播放器容器点击事件
|
|
414
|
+
*/
|
|
325
415
|
|
|
326
|
-
|
|
416
|
+
/**
|
|
417
|
+
* 播放器画面点击事件
|
|
418
|
+
*/
|
|
419
|
+
const handleVideoTap = useCallback(() => {
|
|
420
|
+
if (!playState.loadingState && !playState.errorState && onlineStatus && !privateState) {
|
|
421
|
+
ipcTTTOperatorLog('VID: onVideoTap_event_send');
|
|
422
|
+
onPlayerTap && onPlayerTap(devId);
|
|
423
|
+
} else {
|
|
424
|
+
ipcTTTOperatorLog('VID: onVideoTap_event_trigger_not_send');
|
|
425
|
+
}
|
|
426
|
+
}, [playState.loadingState, playState.errorState, onlineStatus, privateState]);
|
|
427
|
+
|
|
428
|
+
/**
|
|
429
|
+
* 退出横屏
|
|
430
|
+
*/
|
|
431
|
+
|
|
432
|
+
/**
|
|
433
|
+
* 获取错误展示内容
|
|
434
|
+
*/
|
|
435
|
+
const getErrorContent = useCallback(() => {
|
|
436
|
+
if (!phoneNetworkConnect) {
|
|
437
|
+
return Strings.getLang('ipc_player_network_fail');
|
|
438
|
+
}
|
|
439
|
+
if (!onlineStatus) {
|
|
440
|
+
return Strings.getLang('ipc_player_device_offline');
|
|
441
|
+
}
|
|
442
|
+
if (!isLowPowerDevice && onlineStatus && privateState) {
|
|
443
|
+
return Strings.getLang('ipc_player_device_sleep');
|
|
444
|
+
}
|
|
445
|
+
if (isLowPowerDevice && lowPowerDeviceOnlineState && privateState) {
|
|
446
|
+
return Strings.getLang('ipc_player_device_sleep');
|
|
447
|
+
}
|
|
448
|
+
if (!isLowPowerDevice && device4GIsFreeze && onlineStatus && !privateState) {
|
|
449
|
+
return deviceFreezeReasonStore[deviceFreezeReason];
|
|
450
|
+
}
|
|
451
|
+
if (isLowPowerDevice && device4GIsFreeze && lowPowerDeviceOnlineState && !privateState) {
|
|
452
|
+
return deviceFreezeReasonStore[deviceFreezeReason];
|
|
453
|
+
}
|
|
454
|
+
if (onlineStatus && trafficLessOrEqualZero) {
|
|
455
|
+
return Strings.getLang('ipc_player_traffic_load_online_zero_tip');
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
// if (isLowPowerDevice && lowPowerDeviceOnlineState) {
|
|
459
|
+
// return Strings.getLang('ipc_player_traffic_load_online_zero_tip');
|
|
460
|
+
// }
|
|
461
|
+
|
|
462
|
+
if (!onlineStatus) {
|
|
463
|
+
return Strings.getLang('ipc_player_no_line');
|
|
464
|
+
}
|
|
465
|
+
if (videoErrCode !== '') {
|
|
466
|
+
if (Strings["ipc_player_error_".concat(codeCoverToInt(videoErrCode))]) {
|
|
467
|
+
return "".concat(Strings.getLang("ipc_player_error_".concat(codeCoverToInt(videoErrCode))), "(").concat(videoErrCode, ")");
|
|
468
|
+
}
|
|
469
|
+
return "".concat(Strings.getLang("ipc_player_error_common"), "(").concat(videoErrCode, ")");
|
|
470
|
+
}
|
|
471
|
+
return playState.errorMsg;
|
|
472
|
+
}, [phoneNetworkConnect, playState, videoErrCode, privateState, onlineStatus, isLowPowerDevice, lowPowerDeviceOnlineState, device4GIsFreeze, deviceFreezeReason]);
|
|
473
|
+
|
|
474
|
+
/**
|
|
475
|
+
* 根据自定义类型获取错误码展示内容
|
|
476
|
+
*/
|
|
477
|
+
const getErrorContentByType = useCallback((errCode, type) => {
|
|
478
|
+
console.log('___dashdjhasjhdjsahdjshajhdjsa');
|
|
479
|
+
const errContent = getErrCodeDetailDataByCode(String(errCode));
|
|
480
|
+
const contentEmpty = _isEmpty(errContent);
|
|
481
|
+
switch (type) {
|
|
482
|
+
// 是否展示建议文案
|
|
483
|
+
case 'suggestedFlag':
|
|
484
|
+
if (contentEmpty) {
|
|
485
|
+
return false;
|
|
486
|
+
}
|
|
487
|
+
return errContent.suggestedText !== '';
|
|
488
|
+
// 建议文案
|
|
489
|
+
case 'suggestedText':
|
|
490
|
+
if (contentEmpty) {
|
|
491
|
+
return '';
|
|
492
|
+
}
|
|
493
|
+
return errContent.suggestedText;
|
|
494
|
+
// 是否展示点我重试
|
|
495
|
+
case 'retry':
|
|
496
|
+
if (!phoneNetworkConnect) {
|
|
497
|
+
return false;
|
|
498
|
+
}
|
|
499
|
+
if (!isLowPowerDevice && !onlineStatus) {
|
|
500
|
+
return false;
|
|
501
|
+
}
|
|
502
|
+
if (isLowPowerDevice && !lowPowerDeviceOnlineState) {
|
|
503
|
+
return false;
|
|
504
|
+
}
|
|
505
|
+
if (privateState && !isShare && !device4GIsFreeze) {
|
|
506
|
+
return true;
|
|
507
|
+
}
|
|
508
|
+
if (privateState && isShare) {
|
|
509
|
+
return false;
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
// 设备4G冻结,冻结原因为特殊情况下,展示retry
|
|
513
|
+
if (device4GIsFreeze && onlineStatus && !privateState && deviceFreezeReason === 1) {
|
|
514
|
+
return true;
|
|
515
|
+
}
|
|
516
|
+
if (contentEmpty || privateState) {
|
|
517
|
+
return true;
|
|
518
|
+
}
|
|
519
|
+
return errContent.try;
|
|
520
|
+
// 是否展示点我重试
|
|
521
|
+
case 'retryText':
|
|
522
|
+
if (privateState) {
|
|
523
|
+
return Strings.getLang('ipc_player_re_wake_camera');
|
|
524
|
+
}
|
|
525
|
+
return Strings.getLang('ipc_player_retry');
|
|
526
|
+
case 'help':
|
|
527
|
+
if (!phoneNetworkConnect || privateState) {
|
|
528
|
+
return false;
|
|
529
|
+
}
|
|
530
|
+
if (isLowPowerDevice && lowPowerDeviceOnlineState) {
|
|
531
|
+
return false;
|
|
532
|
+
}
|
|
533
|
+
if (isLowPowerDevice && !lowPowerDeviceOnlineState) {
|
|
534
|
+
return true;
|
|
535
|
+
}
|
|
536
|
+
if (!isLowPowerDevice && !onlineStatus) {
|
|
537
|
+
return true;
|
|
538
|
+
}
|
|
539
|
+
if (privateState && isShare) {
|
|
540
|
+
return false;
|
|
541
|
+
}
|
|
542
|
+
if (contentEmpty) {
|
|
543
|
+
return false;
|
|
544
|
+
}
|
|
545
|
+
return errContent.help;
|
|
546
|
+
case 'helpNum':
|
|
547
|
+
if (privateState && isShare) {
|
|
548
|
+
return false;
|
|
549
|
+
}
|
|
550
|
+
return errContent.helpNum;
|
|
551
|
+
case 'feedBack':
|
|
552
|
+
if (!phoneNetworkConnect) {
|
|
553
|
+
return true;
|
|
554
|
+
}
|
|
555
|
+
if (privateState && isShare) {
|
|
556
|
+
return false;
|
|
557
|
+
}
|
|
558
|
+
if (contentEmpty) {
|
|
559
|
+
return false;
|
|
560
|
+
}
|
|
561
|
+
return errContent.feedBack;
|
|
562
|
+
default:
|
|
563
|
+
return false;
|
|
564
|
+
}
|
|
565
|
+
}, [phoneNetworkConnect, privateState, onlineStatus, isLowPowerDevice, lowPowerDeviceOnlineState, device4GIsFreeze, deviceFreezeReason]);
|
|
566
|
+
|
|
567
|
+
/**
|
|
568
|
+
* 跳转帮助小程序
|
|
569
|
+
*/
|
|
570
|
+
const handleGotoHelpMini = useCallback(async () => {
|
|
571
|
+
if (isLowPowerDevice && !lowPowerDeviceOnlineState || !onlineStatus) {
|
|
572
|
+
const realLanguage = await getLanguage();
|
|
573
|
+
const url = "godzilla://".concat(miniIdLabs.helpMini, "/pages/commonDetails/index?answer=/app-helpcenter/").concat(realLanguage, "/K94ow0gwu9bg2");
|
|
574
|
+
openTargetMinByShortLink(url);
|
|
575
|
+
return false;
|
|
576
|
+
}
|
|
577
|
+
const helpNum = getErrorContentByType(videoErrCode, 'helpNum');
|
|
578
|
+
const helpFeedBack = getErrorContentByType(videoErrCode, 'helpFeedBack');
|
|
579
|
+
const homeInfo = await getHomeInfo();
|
|
580
|
+
const devInfo = await getDeviceInfo(devId);
|
|
581
|
+
const url = "godzilla://".concat(miniIdLabs.ipcHelpMini, "?errCode=").concat(videoErrCode, "&deviceId=").concat(devId, "&homeId=").concat(homeInfo === null || homeInfo === void 0 ? void 0 : homeInfo.homeId, "&instanceId=").concat(devInfo === null || devInfo === void 0 ? void 0 : devInfo.uuid, "&helpNum=").concat(helpNum, "&helpFeedBack=").concat(helpFeedBack, "&themeColor=").concat(brandColor);
|
|
582
|
+
openTargetMinByShortLink(url);
|
|
583
|
+
return false;
|
|
584
|
+
}, [onlineStatus, isLowPowerDevice, lowPowerDeviceOnlineState]);
|
|
585
|
+
|
|
586
|
+
/**
|
|
587
|
+
* 跳转反馈小程序
|
|
588
|
+
*/
|
|
327
589
|
|
|
328
590
|
return /*#__PURE__*/React.createElement(View, {
|
|
329
591
|
className: Styles.ipc_player,
|
|
330
|
-
onClick:
|
|
592
|
+
onClick: () => {
|
|
593
|
+
onPlayerContainerTap && onPlayerContainerTap(devId);
|
|
594
|
+
}
|
|
331
595
|
}, /*#__PURE__*/React.createElement(IpcPlayer, _extends({
|
|
332
596
|
className: "".concat(Styles.player, " ").concat(playState.updateLy),
|
|
333
|
-
onVideoTap:
|
|
597
|
+
onVideoTap: handleVideoTap,
|
|
334
598
|
onZoomChange: onZoomChange,
|
|
335
|
-
onCameraPreviewFailure:
|
|
599
|
+
onCameraPreviewFailure: data => {
|
|
600
|
+
ipcTTTOperatorLog("cameraPreviewFailure_event_trigger_".concat(JSON.stringify(data)));
|
|
601
|
+
if (data.type === 'cameraPreviewFailure') {
|
|
602
|
+
const {
|
|
603
|
+
deviceId,
|
|
604
|
+
errCode
|
|
605
|
+
} = data === null || data === void 0 ? void 0 : data.detail;
|
|
606
|
+
if (deviceId === devId) {
|
|
607
|
+
setVideoErrCode(errCode);
|
|
608
|
+
props.onCameraPreviewFailure && props.onCameraPreviewFailure(errCode);
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
},
|
|
336
612
|
onCameraNotifyWeakNetwork: onCameraNotifyWeakNetwork,
|
|
337
613
|
onInitDone: () => {
|
|
338
614
|
console.log('视图层准备就绪~');
|
|
615
|
+
ipcTTTOperatorLog('VID: player_initDone_event_finish');
|
|
339
616
|
setPlayState(d => {
|
|
340
617
|
d.updateLy = Math.random();
|
|
341
618
|
d.initLy = true;
|
|
@@ -343,9 +620,10 @@ const Player = props => {
|
|
|
343
620
|
},
|
|
344
621
|
onError: onError,
|
|
345
622
|
onConnectChange: e => {
|
|
346
|
-
var _e$
|
|
623
|
+
var _e$detail;
|
|
624
|
+
ipcTTTOperatorLog("VID: player_event_connect_change: ".concat(JSON.stringify(e)));
|
|
347
625
|
console.log('连接状态发生变化', e);
|
|
348
|
-
const code = e === null || e === void 0 || (_e$
|
|
626
|
+
const code = e === null || e === void 0 || (_e$detail = e.detail) === null || _e$detail === void 0 ? void 0 : _e$detail.state;
|
|
349
627
|
onChangeStreamStatus && onChangeStreamStatus(code === 0 ? 1001 : -1001);
|
|
350
628
|
if (code === 0) {
|
|
351
629
|
setPlayState(d => {
|
|
@@ -395,35 +673,35 @@ const Player = props => {
|
|
|
395
673
|
style: {
|
|
396
674
|
borderRadius: "".concat(borderRadius)
|
|
397
675
|
},
|
|
398
|
-
className: clsx(Styles.bg_center, Styles.
|
|
676
|
+
className: clsx(Styles.bg_center, Styles.errorContainer, !playState.errorState && Styles.hide),
|
|
399
677
|
onClick: () => {
|
|
400
678
|
return false;
|
|
401
679
|
}
|
|
402
|
-
}, privateState && /*#__PURE__*/React.createElement(View, null, /*#__PURE__*/React.createElement(View, {
|
|
403
|
-
className: Styles.device_sleep
|
|
404
|
-
}, Strings.getLang('ipc_player_device_sleep')), /*#__PURE__*/React.createElement(View, {
|
|
405
|
-
className: Styles.re_wake_camera
|
|
406
|
-
// @ts-ignore
|
|
407
|
-
,
|
|
408
|
-
onClick: async () => {
|
|
409
|
-
await putDpData({
|
|
410
|
-
105: false
|
|
411
|
-
}, devId);
|
|
412
|
-
}
|
|
413
|
-
}, Strings.getLang('ipc_player_re_wake_camera'))), !privateState && /*#__PURE__*/React.createElement(View, {
|
|
414
|
-
className: clsx(Styles.err_container)
|
|
415
680
|
}, /*#__PURE__*/React.createElement(View, {
|
|
416
|
-
className: clsx(Styles.
|
|
417
|
-
}
|
|
418
|
-
className: Styles.
|
|
681
|
+
className: clsx(Styles.errIconContainer)
|
|
682
|
+
}, renderErrIcon ? renderErrIcon() : /*#__PURE__*/React.createElement(View, {
|
|
683
|
+
className: clsx(Styles.errIcon)
|
|
684
|
+
})), /*#__PURE__*/React.createElement(View, {
|
|
685
|
+
className: clsx(Styles.errTextContainer)
|
|
419
686
|
}, /*#__PURE__*/React.createElement(View, {
|
|
420
|
-
className: clsx(Styles.
|
|
421
|
-
},
|
|
422
|
-
|
|
423
|
-
, {
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
687
|
+
className: clsx(Styles.errContent)
|
|
688
|
+
}, getErrorContent()), getErrorContentByType(videoErrCode, 'suggestedFlag') && /*#__PURE__*/React.createElement(View, {
|
|
689
|
+
className: clsx(Styles.errDesc)
|
|
690
|
+
}, getErrorContentByType(videoErrCode, 'suggestedText'))), /*#__PURE__*/React.createElement(View, {
|
|
691
|
+
className: clsx(Styles.errOperatorContainer)
|
|
692
|
+
}, getErrorContentByType(videoErrCode, 'retry') && /*#__PURE__*/React.createElement(View, {
|
|
693
|
+
className: clsx(Styles.operatorBtn, Styles.operatorRetry),
|
|
694
|
+
onClick: retry
|
|
695
|
+
}, getErrorContentByType(videoErrCode, 'retryText')), getErrorContentByType(videoErrCode, 'help') && /*#__PURE__*/React.createElement(View, {
|
|
696
|
+
className: clsx(Styles.operatorBtn, Styles.operatorHelp),
|
|
697
|
+
onClick: handleGotoHelpMini
|
|
698
|
+
}, Strings.getLang('ipc_player_help')), getErrorContentByType(videoErrCode, 'feedBack') && /*#__PURE__*/React.createElement(View, {
|
|
699
|
+
className: clsx(Styles.operatorBtn, Styles.operatorFeedBack),
|
|
700
|
+
onClick: () => {
|
|
701
|
+
const url = "godzilla://".concat(miniIdLabs.helpMini, "/pages/v2/problemSubmit/index");
|
|
702
|
+
openTargetMinByShortLink(url);
|
|
703
|
+
}
|
|
704
|
+
}, Strings.getLang('ipc_player_feedback')))), screenType === 'landscape' && (playState.loadingState || playState.errorState) && /*#__PURE__*/React.createElement(CoverView, {
|
|
427
705
|
className: clsx(Styles.load_full_back_container),
|
|
428
706
|
onClick: () => {
|
|
429
707
|
setPageOrientation({
|