@ray-js/ray-ipc-player 2.0.30 → 2.1.0-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/components/ErrorOverlay.d.ts +28 -0
- package/lib/components/ErrorOverlay.js +293 -0
- package/lib/components/FullScreenBackButton.d.ts +8 -0
- package/lib/components/FullScreenBackButton.js +16 -0
- package/lib/components/LoadingOverlay.d.ts +9 -0
- package/lib/components/LoadingOverlay.js +27 -0
- package/lib/components/index.d.ts +3 -0
- package/lib/components/index.js +3 -0
- package/lib/hooks/index.d.ts +2 -1
- package/lib/hooks/index.js +3 -1
- package/lib/hooks/usePlayerConnection.d.ts +40 -0
- package/lib/hooks/usePlayerConnection.js +319 -0
- package/lib/hooks/usePlayerProps.d.ts +4 -0
- package/lib/hooks/usePlayerProps.js +108 -0
- package/lib/i18n/index.d.ts +16 -0
- package/lib/i18n/strings.d.ts +8 -0
- package/lib/i18n/strings.js +10 -2
- package/lib/index.js +229 -595
- package/lib/index.less +45 -3
- package/lib/svg/flowLimit.svg +1 -0
- package/lib/svg/rightArrow.svg +1 -0
- package/lib/svg/sleep.svg +1 -0
- package/lib/typings/index.d.ts +13 -1
- package/lib/utils.js +3 -2
- package/package.json +4 -3
package/lib/index.js
CHANGED
|
@@ -1,75 +1,68 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
3
|
import "core-js/modules/es.json.stringify.js";
|
|
3
4
|
import "core-js/modules/web.dom-collections.iterator.js";
|
|
4
5
|
/* eslint-disable no-unneeded-ternary */
|
|
5
6
|
import React, { useState, useEffect, useRef } from 'react';
|
|
6
7
|
import { useImmer } from 'use-immer';
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { setPageOrientation, usePageEvent, useAppEvent, getNetworkType, offNetworkStatusChange, onNetworkStatusChange, publishDps, showToast, getSystemInfoSync, onMqttMessageReceived, registerMQTTProtocolListener, offMqttMessageReceived, unregisterMQTTProtocolListener, registerDeviceListListener, onDpDataChange, onDeviceOnlineStatusUpdate, performanceEvent, getCurrentPages } from '@ray-js/ray';
|
|
11
|
-
import clsx from 'clsx';
|
|
8
|
+
import { IpcPlayer, View } from '@ray-js/components';
|
|
9
|
+
import { useMemoizedFn } from 'ahooks';
|
|
10
|
+
import { setPageOrientation, usePageEvent, useAppEvent, getNetworkType, offNetworkStatusChange, onNetworkStatusChange, publishDps, showToast, getSystemInfoSync, onMqttMessageReceived, registerMQTTProtocolListener, offMqttMessageReceived, unregisterMQTTProtocolListener, registerDeviceListListener, onDpDataChange, onDeviceOnlineStatusUpdate } from '@ray-js/ray';
|
|
12
11
|
import Strings from './i18n';
|
|
13
12
|
import { IpcFailCode } from './constant';
|
|
14
|
-
import { useWakeUpDevice } from './hooks';
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import { deviceFreezeReasonStore, miniIdLabs } from './config';
|
|
13
|
+
import { useWakeUpDevice, usePlayerProps, usePlayerConnection } from './hooks';
|
|
14
|
+
import { getDpIdByDpCode, ipcTTTOperatorLog } from './utils';
|
|
15
|
+
import { LoadingOverlay, ErrorOverlay, FullScreenBackButton } from './components';
|
|
18
16
|
import './index.less';
|
|
19
17
|
const CSS_PREFIX = 'ray-ipc-player';
|
|
20
18
|
|
|
21
19
|
// 生成带前缀的类名
|
|
22
20
|
const getClassName = className => "".concat(CSS_PREFIX, "-").concat(className);
|
|
23
21
|
const Player = props => {
|
|
22
|
+
// 使用自定义 hook 处理 props 解构
|
|
24
23
|
const {
|
|
25
|
-
updateLayout
|
|
26
|
-
devId
|
|
27
|
-
objectFit
|
|
24
|
+
updateLayout,
|
|
25
|
+
devId,
|
|
26
|
+
objectFit,
|
|
28
27
|
onChangeStreamStatus,
|
|
29
28
|
onPlayerTap,
|
|
30
29
|
onZoomChange,
|
|
31
30
|
onCameraPreviewFailure,
|
|
32
31
|
onCameraNotifyWeakNetwork,
|
|
33
32
|
onInitPreview,
|
|
34
|
-
defaultMute
|
|
35
|
-
onlineStatus
|
|
36
|
-
loadText
|
|
37
|
-
rotateZ
|
|
38
|
-
scalable
|
|
39
|
-
scaleMultiple
|
|
40
|
-
ptzControllable
|
|
41
|
-
clarity
|
|
33
|
+
defaultMute,
|
|
34
|
+
onlineStatus,
|
|
35
|
+
loadText,
|
|
36
|
+
rotateZ,
|
|
37
|
+
scalable,
|
|
38
|
+
scaleMultiple,
|
|
39
|
+
ptzControllable,
|
|
40
|
+
clarity,
|
|
42
41
|
ipcPlayerContext,
|
|
43
42
|
onCtx,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
borderStyle: 'solid',
|
|
48
|
-
borderColor: '',
|
|
49
|
-
borderWidth: 0
|
|
50
|
-
},
|
|
51
|
-
privateState = false,
|
|
52
|
-
extend = {},
|
|
53
|
-
brandColor = '#FF592A',
|
|
43
|
+
privateState,
|
|
44
|
+
extend,
|
|
45
|
+
brandColor,
|
|
54
46
|
renderErrIcon,
|
|
55
|
-
isShare
|
|
47
|
+
isShare,
|
|
56
48
|
onPlayerContainerTap,
|
|
57
|
-
reConnect
|
|
58
|
-
awakeStatus
|
|
59
|
-
ignoreHideStopPreview
|
|
49
|
+
reConnect,
|
|
50
|
+
awakeStatus,
|
|
51
|
+
ignoreHideStopPreview,
|
|
60
52
|
onChangeIgnoreHideStopPreview,
|
|
61
|
-
hideSuggestedText
|
|
62
|
-
hideHelpButton
|
|
63
|
-
hideFeedBackButton
|
|
64
|
-
playerRoute
|
|
65
|
-
|
|
66
|
-
|
|
53
|
+
hideSuggestedText,
|
|
54
|
+
hideHelpButton,
|
|
55
|
+
hideFeedBackButton,
|
|
56
|
+
playerRoute,
|
|
57
|
+
defaultAutoPlay,
|
|
58
|
+
limitFlow,
|
|
67
59
|
borderRadius,
|
|
68
60
|
bgColor,
|
|
69
61
|
borderStyle,
|
|
70
62
|
borderColor,
|
|
71
|
-
borderWidth
|
|
72
|
-
|
|
63
|
+
borderWidth,
|
|
64
|
+
isLowPowerDevice
|
|
65
|
+
} = usePlayerProps(props);
|
|
73
66
|
const [playState, setPlayState] = useImmer({
|
|
74
67
|
connectState: false,
|
|
75
68
|
// 连接状态
|
|
@@ -101,10 +94,12 @@ const Player = props => {
|
|
|
101
94
|
const privateLowPowerDeviceTimeOutRef = useRef(null);
|
|
102
95
|
const privateWakeOutTimeRef = useRef(null);
|
|
103
96
|
const privateDeviceWakeNeedPublishTimeRef = useRef(null);
|
|
97
|
+
// 内部维护首次组件渲染时,自动播放状态,一旦调用重试,触发拉流后,将其状态设为true
|
|
98
|
+
const [autoPlay, setAutoPlay] = useState(defaultAutoPlay);
|
|
99
|
+
|
|
104
100
|
// connectChangeRef
|
|
105
101
|
useRef(null);
|
|
106
102
|
const firstPreviewTimeRef = useRef(false);
|
|
107
|
-
const [isLowPowerDevice] = useState(awakeStatus !== undefined);
|
|
108
103
|
|
|
109
104
|
// 自定义计时老低功耗方案设备在线状态, 用于短暂时间报上下线的UI展示兼容 待实现
|
|
110
105
|
const [lowPowerDeviceOnlineState, setLowPowerDeviceOnlineState] = useState(onlineStatus);
|
|
@@ -114,8 +109,6 @@ const Player = props => {
|
|
|
114
109
|
const [device4GIsFreeze, setDevice4GIsFreeze] = useState(false);
|
|
115
110
|
// 4G设备冻结原因, 待实现
|
|
116
111
|
const [deviceFreezeReason, setDeviceFreezeReason] = useState(1);
|
|
117
|
-
// 4G设备流量是否不足
|
|
118
|
-
const [trafficLessOrEqualZero, setTrafficLessOrEqualZero] = useState(false);
|
|
119
112
|
// 手机连接网络状态
|
|
120
113
|
const [phoneNetworkConnect, setPhoneNetworkConnect] = useState(true);
|
|
121
114
|
const ipcCtx = useRef(null); // ipc实例
|
|
@@ -127,18 +120,71 @@ const Player = props => {
|
|
|
127
120
|
const retryCount = useRef(0); // 重试次数
|
|
128
121
|
const muteRef = useRef(defaultMute); // 静音
|
|
129
122
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
123
|
+
/**
|
|
124
|
+
* 设置声音
|
|
125
|
+
*/
|
|
126
|
+
|
|
127
|
+
// 使用连接相关的 hook
|
|
128
|
+
const {
|
|
129
|
+
_retry,
|
|
130
|
+
_reConnect,
|
|
131
|
+
stopPreview,
|
|
132
|
+
disconnect,
|
|
133
|
+
handleReWakeCamera,
|
|
134
|
+
handleReWakeCameraLowPowerDevice,
|
|
135
|
+
getPlayerRoute
|
|
136
|
+
} = usePlayerConnection({
|
|
137
|
+
devId,
|
|
138
|
+
ipcCtx,
|
|
139
|
+
playState,
|
|
140
|
+
setPlayState,
|
|
141
|
+
setVideoErrCode,
|
|
142
|
+
onChangeStreamStatus,
|
|
143
|
+
onInitPreview,
|
|
144
|
+
playerRoute,
|
|
145
|
+
privateState,
|
|
146
|
+
isLowPowerDevice,
|
|
147
|
+
awakeStatus,
|
|
148
|
+
wirelessFlag,
|
|
149
|
+
setEnableWakeUpInterval,
|
|
150
|
+
setLowPrivateOutTimeFlag,
|
|
151
|
+
setMqttPrivateFlag,
|
|
152
|
+
privateLowPowerDeviceTimeOutRef,
|
|
153
|
+
privateWakeOutTimeRef,
|
|
154
|
+
firstPreviewTimeRef,
|
|
155
|
+
retryCount,
|
|
156
|
+
muteRef,
|
|
157
|
+
setMuted: val => {
|
|
158
|
+
var _ipcCtx$current;
|
|
159
|
+
ipcTTTOperatorLog("VID: begin_to_set_mute");
|
|
160
|
+
(_ipcCtx$current = ipcCtx.current) === null || _ipcCtx$current === void 0 || _ipcCtx$current.setMuted({
|
|
161
|
+
mute: val,
|
|
162
|
+
success: () => {
|
|
163
|
+
ipcTTTOperatorLog("VID: set_mute_success: ".concat(val));
|
|
164
|
+
},
|
|
165
|
+
fail: () => {
|
|
166
|
+
ipcTTTOperatorLog("VID: set_mute_failure: ".concat(val));
|
|
167
|
+
}
|
|
168
|
+
});
|
|
134
169
|
}
|
|
170
|
+
});
|
|
171
|
+
usePageEvent('onShow', useMemoizedFn(async () => {
|
|
135
172
|
getNetworkType({
|
|
136
173
|
success: res => {
|
|
174
|
+
console.log('网络类型', res);
|
|
137
175
|
setPhoneNetworkConnect(res.networkType !== 'none');
|
|
176
|
+
},
|
|
177
|
+
fail: err => {
|
|
178
|
+
console.log('网络类型获取失败', err);
|
|
179
|
+
setPhoneNetworkConnect(false);
|
|
138
180
|
}
|
|
139
181
|
});
|
|
182
|
+
if (ignoreHideStopPreview) {
|
|
183
|
+
onChangeIgnoreHideStopPreview && onChangeIgnoreHideStopPreview(false);
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
140
186
|
// 视图准备就绪
|
|
141
|
-
if (phoneNetworkConnect && playState.initLy && ipcCtx.current && onlineStatus && !privateState) {
|
|
187
|
+
if (phoneNetworkConnect && playState.initLy && ipcCtx.current && onlineStatus && !privateState && !limitFlow && autoPlay) {
|
|
142
188
|
ipcTTTOperatorLog('VID: onShow_event_to_retry');
|
|
143
189
|
retry();
|
|
144
190
|
}
|
|
@@ -157,6 +203,24 @@ const Player = props => {
|
|
|
157
203
|
setScreenType(type);
|
|
158
204
|
}
|
|
159
205
|
});
|
|
206
|
+
|
|
207
|
+
// 针对limitFlow
|
|
208
|
+
useEffect(() => {
|
|
209
|
+
if (limitFlow || !autoPlay) {
|
|
210
|
+
setPlayState(d => {
|
|
211
|
+
return _objectSpread(_objectSpread({}, d), {}, {
|
|
212
|
+
loadingState: false,
|
|
213
|
+
errorState: true,
|
|
214
|
+
errorMessage: ''
|
|
215
|
+
});
|
|
216
|
+
});
|
|
217
|
+
ipcTTTOperatorLog("limitFlow ~~~~ ".concat(limitFlow, " autoPlay ~~~ ").concat(autoPlay));
|
|
218
|
+
if (playState.initLy && ipcCtx.current) {
|
|
219
|
+
stopPreview();
|
|
220
|
+
disconnect();
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}, [limitFlow, autoPlay, playState.initLy, ipcCtx.current]);
|
|
160
224
|
useEffect(() => {
|
|
161
225
|
registerDeviceListListener({
|
|
162
226
|
deviceIdList: [devId],
|
|
@@ -187,6 +251,7 @@ const Player = props => {
|
|
|
187
251
|
onDpDataChange(handleDpDataChange);
|
|
188
252
|
}, []);
|
|
189
253
|
usePageEvent('onHide', useMemoizedFn(async () => {
|
|
254
|
+
ipcTTTOperatorLog('VID: onHide event will go to stopPreview');
|
|
190
255
|
if (ignoreHideStopPreview) {
|
|
191
256
|
return;
|
|
192
257
|
}
|
|
@@ -203,22 +268,6 @@ const Player = props => {
|
|
|
203
268
|
stopPreview();
|
|
204
269
|
disconnect();
|
|
205
270
|
}));
|
|
206
|
-
useMount(() => {
|
|
207
|
-
onNetworkStatusChange(res => {
|
|
208
|
-
setPhoneNetworkConnect(res.isConnected);
|
|
209
|
-
if (!res.isConnected) {
|
|
210
|
-
// 断网,需要主动调用断流以及断开P2P
|
|
211
|
-
ipcTTTOperatorLog('VID: network is not connected, need stop preview and disconnect');
|
|
212
|
-
stopPreview();
|
|
213
|
-
disconnect();
|
|
214
|
-
}
|
|
215
|
-
});
|
|
216
|
-
});
|
|
217
|
-
useUnmount(() => {
|
|
218
|
-
offNetworkStatusChange(res => {
|
|
219
|
-
console.log(res);
|
|
220
|
-
});
|
|
221
|
-
});
|
|
222
271
|
const handleDpDataChange = useMemoizedFn(res => {
|
|
223
272
|
if (res.deviceId === devId) {
|
|
224
273
|
const dpsInfo = res.dps;
|
|
@@ -272,7 +321,8 @@ const Player = props => {
|
|
|
272
321
|
});
|
|
273
322
|
|
|
274
323
|
/**
|
|
275
|
-
* 监听mqtt
|
|
324
|
+
* 监听mqtt协议消息
|
|
325
|
+
* 主要用于低功耗设备的唤醒状态监听
|
|
276
326
|
*/
|
|
277
327
|
useEffect(() => {
|
|
278
328
|
registerMQTTProtocolListener({
|
|
@@ -294,6 +344,31 @@ const Player = props => {
|
|
|
294
344
|
};
|
|
295
345
|
}, []);
|
|
296
346
|
|
|
347
|
+
/**
|
|
348
|
+
* 监听网络状态变化
|
|
349
|
+
* 组件挂载时开始监听,网络断开时主动停流和断开连接
|
|
350
|
+
* 组件卸载时移除监听器
|
|
351
|
+
*/
|
|
352
|
+
useEffect(() => {
|
|
353
|
+
const handleNetworkStatusChange = res => {
|
|
354
|
+
setPhoneNetworkConnect(res.isConnected);
|
|
355
|
+
if (!res.isConnected) {
|
|
356
|
+
// 断网,需要主动调用断流以及断开P2P
|
|
357
|
+
ipcTTTOperatorLog('VID: network is not connected, need stop preview and disconnect');
|
|
358
|
+
stopPreview();
|
|
359
|
+
disconnect();
|
|
360
|
+
}
|
|
361
|
+
};
|
|
362
|
+
|
|
363
|
+
// 开始监听网络状态变化
|
|
364
|
+
onNetworkStatusChange(handleNetworkStatusChange);
|
|
365
|
+
|
|
366
|
+
// 清理函数:组件卸载时移除网络状态监听器
|
|
367
|
+
return () => {
|
|
368
|
+
offNetworkStatusChange(handleNetworkStatusChange);
|
|
369
|
+
};
|
|
370
|
+
}, [stopPreview, disconnect]);
|
|
371
|
+
|
|
297
372
|
/**
|
|
298
373
|
* 唤醒设备TTT能力
|
|
299
374
|
*/
|
|
@@ -302,25 +377,58 @@ const Player = props => {
|
|
|
302
377
|
enabled: enableWakeUpInterval,
|
|
303
378
|
intervalTime: 300
|
|
304
379
|
});
|
|
380
|
+
|
|
381
|
+
/**
|
|
382
|
+
* 监听设备休眠状态变化
|
|
383
|
+
* 当检测到设备上报休眠后,触发重新连接
|
|
384
|
+
*/
|
|
305
385
|
useEffect(() => {
|
|
306
386
|
if (wirelessFlag) {
|
|
307
387
|
// 进入面板后,若监听到设备上报休眠后, 需进行重新连接
|
|
308
388
|
setWirelessFlag(false);
|
|
309
389
|
_reConnect();
|
|
310
390
|
}
|
|
311
|
-
}, [wirelessFlag]);
|
|
391
|
+
}, [wirelessFlag, _reConnect]);
|
|
392
|
+
|
|
393
|
+
/**
|
|
394
|
+
* 初始化获取网络类型
|
|
395
|
+
* 组件挂载时主动获取一次当前网络状态
|
|
396
|
+
*/
|
|
397
|
+
useEffect(() => {
|
|
398
|
+
getNetworkType({
|
|
399
|
+
success: res => {
|
|
400
|
+
console.log('首次获取网络类型', res);
|
|
401
|
+
setPhoneNetworkConnect(res.networkType !== 'none');
|
|
402
|
+
},
|
|
403
|
+
fail: err => {
|
|
404
|
+
console.log('首次网络类型获取失败', err);
|
|
405
|
+
setPhoneNetworkConnect(false);
|
|
406
|
+
}
|
|
407
|
+
});
|
|
408
|
+
}, []);
|
|
409
|
+
|
|
410
|
+
/**
|
|
411
|
+
* IPC实例生命周期管理
|
|
412
|
+
* 当设备在线且devId变化时创建IPC实例
|
|
413
|
+
* 组件卸载时断开连接并清理实例
|
|
414
|
+
*/
|
|
312
415
|
useEffect(() => {
|
|
313
416
|
onlineStatus && createIpcCtx();
|
|
314
417
|
return () => {
|
|
315
418
|
disconnect();
|
|
316
419
|
ipcCtx.current = null;
|
|
317
420
|
};
|
|
318
|
-
}, [devId, onlineStatus]);
|
|
421
|
+
}, [devId, onlineStatus, disconnect]);
|
|
422
|
+
|
|
423
|
+
/**
|
|
424
|
+
* 外部重连指令处理
|
|
425
|
+
* 当接收到外部重连指令且设备在线时,触发重新连接
|
|
426
|
+
*/
|
|
319
427
|
useEffect(() => {
|
|
320
428
|
if (reConnect && devId && onlineStatus) {
|
|
321
429
|
_reConnect();
|
|
322
430
|
}
|
|
323
|
-
}, [reConnect]);
|
|
431
|
+
}, [reConnect, devId, onlineStatus, _reConnect]);
|
|
324
432
|
useEffect(() => {
|
|
325
433
|
muteRef.current = defaultMute;
|
|
326
434
|
}, [defaultMute]);
|
|
@@ -344,10 +452,19 @@ const Player = props => {
|
|
|
344
452
|
console.log('监听到设备离线');
|
|
345
453
|
setPlayState(d => {
|
|
346
454
|
d.errorState = true;
|
|
347
|
-
d.errorMsg = Strings.getLang('ipc_player_device_offline');
|
|
455
|
+
d.errorMsg = limitFlow ? Strings.getLang('ipc_player_traffic_load_offline_limit_tip') : Strings.getLang('ipc_player_device_offline');
|
|
456
|
+
});
|
|
457
|
+
} else if (!autoPlay) {
|
|
458
|
+
setPlayState(d => {
|
|
459
|
+
d.errorState = true;
|
|
460
|
+
d.errorMsg = '设备处于休眠中';
|
|
461
|
+
});
|
|
462
|
+
} else if (limitFlow) {
|
|
463
|
+
setPlayState(d => {
|
|
464
|
+
d.errorState = true;
|
|
465
|
+
d.errorMsg = Strings.getLang('ipc_player_traffic_load_online_zero_tip');
|
|
348
466
|
});
|
|
349
467
|
} else if (playState.initLy && !privateState) {
|
|
350
|
-
console.log('sdhjsahdjshajdh');
|
|
351
468
|
ipcTTTOperatorLog("VID: privateState_status_change: ".concat(privateState));
|
|
352
469
|
retry();
|
|
353
470
|
} else if (playState.initLy && privateState) {
|
|
@@ -356,139 +473,10 @@ const Player = props => {
|
|
|
356
473
|
onChangeStreamStatus && onChangeStreamStatus(-1001);
|
|
357
474
|
}
|
|
358
475
|
}
|
|
359
|
-
}, [phoneNetworkConnect, onlineStatus, playState.initLy, privateState]);
|
|
360
|
-
|
|
361
|
-
// 重试
|
|
362
|
-
const _retry = async () => {
|
|
363
|
-
console.log('调用了重试');
|
|
364
|
-
const connectState = await getIsConnected(ipcCtx.current);
|
|
365
|
-
console.log('调用了重试--connectState');
|
|
366
|
-
const isOnPreview = await getIsOnPreview(ipcCtx.current);
|
|
367
|
-
console.log('调用了重试--isOnPreview');
|
|
368
|
-
setPlayState(d => {
|
|
369
|
-
d.connectState = connectState ? true : false;
|
|
370
|
-
d.errorMsg = '';
|
|
371
|
-
d.errorState = false;
|
|
372
|
-
d.loadingState = isOnPreview ? false : true;
|
|
373
|
-
});
|
|
374
|
-
setVideoErrCode('');
|
|
375
|
-
// !prePlayRef.current && connectState && (await disconnect());
|
|
376
|
-
// console.log(connectState, isOnPreview, '当前链接状态和预览状态');
|
|
377
|
-
ipcTTTOperatorLog("VID: start_create_p2p_connect");
|
|
378
|
-
ipcCtx.current && createConnect();
|
|
379
|
-
};
|
|
380
|
-
|
|
381
|
-
// 无需关心连接状态直接发起重新连接
|
|
382
|
-
const _reConnect = () => {
|
|
383
|
-
console.log('不在播放器路由内, 不进行标记');
|
|
384
|
-
// 排除默认值为"",不等于播放器路由时, 不进行连接操作
|
|
385
|
-
if (playerRoute !== '' && playerRoute !== getPlayerRoute()) {
|
|
386
|
-
return;
|
|
387
|
-
}
|
|
388
|
-
setPlayState(d => {
|
|
389
|
-
d.connectState = true;
|
|
390
|
-
d.loadingText = Strings.getLang('ipc_player_get_video_stream');
|
|
391
|
-
d.errorMsg = '';
|
|
392
|
-
d.errorState = false;
|
|
393
|
-
d.loadingState = true;
|
|
394
|
-
});
|
|
395
|
-
setVideoErrCode('');
|
|
396
|
-
// !prePlayRef.current && connectState && (await disconnect());
|
|
397
|
-
// console.log(connectState, isOnPreview, '当前链接状态和预览状态');
|
|
398
|
-
ipcTTTOperatorLog("VID: start_create_p2p_connect");
|
|
399
|
-
ipcCtx.current && createConnect();
|
|
400
|
-
};
|
|
401
|
-
|
|
402
|
-
/**
|
|
403
|
-
* 关闭隐私模式,重新拉流
|
|
404
|
-
*/
|
|
405
|
-
const handleReWakeCamera = async () => {
|
|
406
|
-
setPlayState(d => {
|
|
407
|
-
d.connectState = true;
|
|
408
|
-
d.errorMsg = '';
|
|
409
|
-
d.loadingText = Strings.getLang('ipc_player_private_open_stream');
|
|
410
|
-
d.errorState = false;
|
|
411
|
-
d.loadingState = true;
|
|
412
|
-
});
|
|
413
|
-
setVideoErrCode('');
|
|
414
|
-
const sendDpId = await getDpIdByDpCode(devId, 'basic_private');
|
|
415
|
-
if (sendDpId === -1) {
|
|
416
|
-
showToast(Strings.getLang('ipc_player_basic_private_not_exist'));
|
|
417
|
-
} else {
|
|
418
|
-
publishDps({
|
|
419
|
-
deviceId: devId,
|
|
420
|
-
dps: {
|
|
421
|
-
[sendDpId]: false
|
|
422
|
-
},
|
|
423
|
-
mode: 1,
|
|
424
|
-
pipelines: [0, 1, 2, 3, 4, 5, 6],
|
|
425
|
-
options: {},
|
|
426
|
-
success: () => {
|
|
427
|
-
console.log('下发隐私模式成功');
|
|
428
|
-
}
|
|
429
|
-
});
|
|
430
|
-
}
|
|
431
|
-
};
|
|
432
|
-
|
|
433
|
-
/**
|
|
434
|
-
*
|
|
435
|
-
* 低功耗设备关闭隐私模式,先判断设备是否唤醒,唤醒后才可下发隐私模式DP
|
|
436
|
-
*/
|
|
437
|
-
|
|
438
|
-
const handleReWakeCameraLowPowerDevice = useMemoizedFn(() => {
|
|
439
|
-
setVideoErrCode('');
|
|
440
|
-
setLowPrivateOutTimeFlag(false);
|
|
441
|
-
if (awakeStatus) {
|
|
442
|
-
setPlayState(d => {
|
|
443
|
-
d.connectState = true;
|
|
444
|
-
d.errorMsg = '';
|
|
445
|
-
d.loadingText = Strings.getLang('ipc_player_private_open_stream');
|
|
446
|
-
d.errorState = false;
|
|
447
|
-
d.loadingState = true;
|
|
448
|
-
});
|
|
449
|
-
// 如果值为true, 表示设备为唤醒状态,直接下发隐私模式DP
|
|
450
|
-
handleReWakeCamera();
|
|
451
|
-
} else {
|
|
452
|
-
setPlayState(d => {
|
|
453
|
-
d.connectState = true;
|
|
454
|
-
d.errorMsg = '';
|
|
455
|
-
d.loadingText = Strings.getLang('ipc_player_private_open_low_stream');
|
|
456
|
-
d.errorState = false;
|
|
457
|
-
d.loadingState = true;
|
|
458
|
-
});
|
|
459
|
-
// 如果值为false, 表示设备为睡眠状态,需要唤醒设备
|
|
460
|
-
setMqttPrivateFlag(true);
|
|
461
|
-
setEnableWakeUpInterval(true);
|
|
462
|
-
// 2秒后停止下发唤醒, 防止频繁唤醒, 此时若Mqtt监听到1协议,也会停止下发唤醒
|
|
463
|
-
privateLowPowerDeviceTimeOutRef.current = setTimeout(() => {
|
|
464
|
-
setEnableWakeUpInterval(false);
|
|
465
|
-
// 清除定时器
|
|
466
|
-
privateLowPowerDeviceTimeOutRef.current && clearTimeout(privateLowPowerDeviceTimeOutRef.current);
|
|
467
|
-
}, 2000);
|
|
468
|
-
|
|
469
|
-
// 15 秒后若设备还是未唤醒,未监听到Mqtt消息以及唤醒Dp上报, 则提示报错
|
|
470
|
-
privateWakeOutTimeRef.current = setTimeout(() => {
|
|
471
|
-
// 清除定时器
|
|
472
|
-
privateLowPowerDeviceTimeOutRef.current && clearTimeout(privateWakeOutTimeRef.current);
|
|
473
|
-
setPlayState(d => {
|
|
474
|
-
d.connectState = false;
|
|
475
|
-
d.errorMsg = Strings.getLang('ipc_player_private_open_low_stream_fail');
|
|
476
|
-
d.errorState = true;
|
|
477
|
-
d.loadingState = false;
|
|
478
|
-
});
|
|
479
|
-
setMqttPrivateFlag(false);
|
|
480
|
-
setLowPrivateOutTimeFlag(true);
|
|
481
|
-
}, 15000);
|
|
482
|
-
}
|
|
483
|
-
});
|
|
484
|
-
const getPlayerRoute = () => {
|
|
485
|
-
const pages = getCurrentPages(); // 获取当前页面栈
|
|
486
|
-
const currentPage = pages[pages.length - 1]; // 获取当前页面实例
|
|
487
|
-
return currentPage.route;
|
|
488
|
-
};
|
|
476
|
+
}, [phoneNetworkConnect, onlineStatus, playState.initLy, privateState, limitFlow, autoPlay]);
|
|
489
477
|
const retry = useMemoizedFn(() => {
|
|
490
478
|
console.log('重新拉流启动');
|
|
491
|
-
|
|
479
|
+
setAutoPlay(true);
|
|
492
480
|
// 任何重试拉流时, 将播放器状态还原为loading状态
|
|
493
481
|
setVideoErrCode('');
|
|
494
482
|
setPlayState(d => {
|
|
@@ -512,156 +500,14 @@ const Player = props => {
|
|
|
512
500
|
|
|
513
501
|
// 创建ipc实例
|
|
514
502
|
const createIpcCtx = () => {
|
|
515
|
-
console.log('创建ipc实例');
|
|
516
503
|
onCtx && onCtx({
|
|
517
504
|
ctx: ipcCtx.current,
|
|
518
505
|
retry
|
|
519
506
|
});
|
|
520
507
|
};
|
|
521
508
|
|
|
522
|
-
// 建立连接
|
|
523
|
-
const createConnect = useMemoizedFn(async params => {
|
|
524
|
-
var _ipcCtx$current;
|
|
525
|
-
if (playerRoute !== '' && playerRoute !== getPlayerRoute()) {
|
|
526
|
-
console.log('不在播放器路由内, 不进行连接操作');
|
|
527
|
-
return;
|
|
528
|
-
}
|
|
529
|
-
// console.log('建立连接前:', devId, Date.now());
|
|
530
|
-
// 若走到连接状态,需清除低功耗15秒超时定时
|
|
531
|
-
privateLowPowerDeviceTimeOutRef.current && clearTimeout(privateWakeOutTimeRef.current);
|
|
532
|
-
setLowPrivateOutTimeFlag(false);
|
|
533
|
-
// 表示为 149 低功耗设备, 唤醒设备
|
|
534
|
-
if (isLowPowerDevice) {
|
|
535
|
-
// 下发唤醒
|
|
536
|
-
setEnableWakeUpInterval(true);
|
|
537
|
-
}
|
|
538
|
-
(_ipcCtx$current = ipcCtx.current) === null || _ipcCtx$current === void 0 || _ipcCtx$current.connect({
|
|
539
|
-
success: () => {
|
|
540
|
-
ipcTTTOperatorLog("VID: create_p2p_connect_success");
|
|
541
|
-
// 清除唤醒定时器
|
|
542
|
-
setEnableWakeUpInterval(false);
|
|
543
|
-
setPlayState(d => {
|
|
544
|
-
d.connectState = true;
|
|
545
|
-
d.loadingText = Strings.getLang('ipc_player_get_video_stream');
|
|
546
|
-
d.errorState = false;
|
|
547
|
-
d.errorMsg = '';
|
|
548
|
-
});
|
|
549
|
-
onChangeStreamStatus && onChangeStreamStatus(1001);
|
|
550
|
-
ipcTTTOperatorLog("VID: start_to_preview");
|
|
551
|
-
startPreview(params);
|
|
552
|
-
},
|
|
553
|
-
fail: () => {
|
|
554
|
-
// 清除唤醒定时器
|
|
555
|
-
setEnableWakeUpInterval(false);
|
|
556
|
-
ipcTTTOperatorLog("VID: create_p2p_connect_failure");
|
|
557
|
-
// 针对进入面板上报149状态的为true的设备直接忽略
|
|
558
|
-
if (!wirelessFlag) {
|
|
559
|
-
setPlayState(d => {
|
|
560
|
-
d.connectState = false;
|
|
561
|
-
d.errorState = true;
|
|
562
|
-
d.errorMsg = Strings.getLang('ipc_player_connect_fail');
|
|
563
|
-
d.loadingState = false;
|
|
564
|
-
});
|
|
565
|
-
onChangeStreamStatus && onChangeStreamStatus(-1001);
|
|
566
|
-
}
|
|
567
|
-
}
|
|
568
|
-
});
|
|
569
|
-
});
|
|
570
|
-
|
|
571
509
|
// 视图层准备就绪,开始建立连接
|
|
572
510
|
|
|
573
|
-
/*
|
|
574
|
-
* 开启预览
|
|
575
|
-
*/
|
|
576
|
-
const startPreview = useMemoizedFn(params => {
|
|
577
|
-
var _ipcCtx$current2;
|
|
578
|
-
// console.log('开启预览前');
|
|
579
|
-
(_ipcCtx$current2 = ipcCtx.current) === null || _ipcCtx$current2 === void 0 || _ipcCtx$current2.startPreview({
|
|
580
|
-
success: () => {
|
|
581
|
-
ipcTTTOperatorLog('VID: start_preview_success');
|
|
582
|
-
if (typeof performanceEvent === 'function' && !firstPreviewTimeRef.current) {
|
|
583
|
-
performanceEvent({
|
|
584
|
-
launchData: '出流成功耗时',
|
|
585
|
-
success: () => {
|
|
586
|
-
firstPreviewTimeRef.current = true;
|
|
587
|
-
}
|
|
588
|
-
});
|
|
589
|
-
}
|
|
590
|
-
|
|
591
|
-
// console.log('开启预览:', devId);
|
|
592
|
-
setPlayState(d => {
|
|
593
|
-
d.loadingState = false;
|
|
594
|
-
d.errorState = false;
|
|
595
|
-
d.errorMsg = '';
|
|
596
|
-
});
|
|
597
|
-
setMuted(muteRef.current);
|
|
598
|
-
params && onInitPreview && onInitPreview(devId);
|
|
599
|
-
onChangeStreamStatus && onChangeStreamStatus(1002);
|
|
600
|
-
},
|
|
601
|
-
fail: async e => {
|
|
602
|
-
ipcTTTOperatorLog("VID: start_preview_fail: ".concat(JSON.stringify(e)));
|
|
603
|
-
const isOnPreview = await getIsOnPreview(ipcCtx.current);
|
|
604
|
-
ipcTTTOperatorLog("VID: get_is_on_preview_status_".concat(isOnPreview));
|
|
605
|
-
// console.error('开启失败:', e, devId, isOnPreview);
|
|
606
|
-
if (isOnPreview || e !== null && e !== void 0 && e.errorMsg.includes('doing preview')) {
|
|
607
|
-
// 忽略重复预览异常的报错
|
|
608
|
-
setPlayState(d => {
|
|
609
|
-
d.loadingState = false;
|
|
610
|
-
d.errorState = false;
|
|
611
|
-
d.errorMsg = '';
|
|
612
|
-
});
|
|
613
|
-
setMuted(muteRef.current);
|
|
614
|
-
onChangeStreamStatus && onChangeStreamStatus(1002);
|
|
615
|
-
return;
|
|
616
|
-
}
|
|
617
|
-
// 针对进入到面板,接收到上报为设备休眠的情况直接忽略
|
|
618
|
-
if (!wirelessFlag) {
|
|
619
|
-
setPlayState(d => {
|
|
620
|
-
d.errorState = true;
|
|
621
|
-
d.loadingState = false;
|
|
622
|
-
d.errorMsg = Strings.getLang('ipc_player_preview_fail');
|
|
623
|
-
});
|
|
624
|
-
onChangeStreamStatus && onChangeStreamStatus(-1002);
|
|
625
|
-
}
|
|
626
|
-
}
|
|
627
|
-
});
|
|
628
|
-
});
|
|
629
|
-
|
|
630
|
-
/**
|
|
631
|
-
* 暂停预览
|
|
632
|
-
*/
|
|
633
|
-
const stopPreview = () => {
|
|
634
|
-
var _ipcCtx$current3;
|
|
635
|
-
ipcTTTOperatorLog("VID: begin_to_stop_preview");
|
|
636
|
-
ipcTTTOperatorLog("VID: set_mute_is_true");
|
|
637
|
-
setMuted(true);
|
|
638
|
-
(_ipcCtx$current3 = ipcCtx.current) === null || _ipcCtx$current3 === void 0 || _ipcCtx$current3.stopPreview({
|
|
639
|
-
success: () => {
|
|
640
|
-
ipcTTTOperatorLog("VID: stop_preview_success");
|
|
641
|
-
},
|
|
642
|
-
fail: e => {
|
|
643
|
-
ipcTTTOperatorLog("VID: stop_preview_failure: ".concat(JSON.stringify(e)));
|
|
644
|
-
}
|
|
645
|
-
});
|
|
646
|
-
};
|
|
647
|
-
|
|
648
|
-
/**
|
|
649
|
-
* 设置声音
|
|
650
|
-
*/
|
|
651
|
-
const setMuted = val => {
|
|
652
|
-
var _ipcCtx$current4;
|
|
653
|
-
ipcTTTOperatorLog("VID: begin_to_set_mute");
|
|
654
|
-
(_ipcCtx$current4 = ipcCtx.current) === null || _ipcCtx$current4 === void 0 || _ipcCtx$current4.setMuted({
|
|
655
|
-
mute: val,
|
|
656
|
-
success: () => {
|
|
657
|
-
ipcTTTOperatorLog("VID: set_mute_success: ".concat(val));
|
|
658
|
-
},
|
|
659
|
-
fail: () => {
|
|
660
|
-
ipcTTTOperatorLog("VID: set_mute_failure: ".concat(val));
|
|
661
|
-
}
|
|
662
|
-
});
|
|
663
|
-
};
|
|
664
|
-
|
|
665
511
|
/**
|
|
666
512
|
* 获取当前是否静音
|
|
667
513
|
*/
|
|
@@ -729,29 +575,6 @@ const Player = props => {
|
|
|
729
575
|
}
|
|
730
576
|
});
|
|
731
577
|
|
|
732
|
-
// 断开连接
|
|
733
|
-
const disconnect = () => {
|
|
734
|
-
return new Promise((resolve, reject) => {
|
|
735
|
-
var _ipcCtx$current6;
|
|
736
|
-
// console.log('断开连接前');
|
|
737
|
-
(_ipcCtx$current6 = ipcCtx.current) === null || _ipcCtx$current6 === void 0 || _ipcCtx$current6.disconnect({
|
|
738
|
-
success: res => {
|
|
739
|
-
// console.log('断开连接成功:', devId);
|
|
740
|
-
resolve(res);
|
|
741
|
-
setPlayState(d => {
|
|
742
|
-
d.connectState = false;
|
|
743
|
-
});
|
|
744
|
-
onChangeStreamStatus && onChangeStreamStatus(1009);
|
|
745
|
-
},
|
|
746
|
-
fail: e => {
|
|
747
|
-
// console.error('断开连接失败:', devId);
|
|
748
|
-
reject(e);
|
|
749
|
-
onChangeStreamStatus && onChangeStreamStatus(-1009);
|
|
750
|
-
}
|
|
751
|
-
});
|
|
752
|
-
});
|
|
753
|
-
};
|
|
754
|
-
|
|
755
578
|
/**
|
|
756
579
|
* 播放器容器点击事件
|
|
757
580
|
*/
|
|
@@ -773,7 +596,7 @@ const Player = props => {
|
|
|
773
596
|
*/
|
|
774
597
|
|
|
775
598
|
const handleCameraPreviewFailure = useMemoizedFn(data => {
|
|
776
|
-
console.log(data, '
|
|
599
|
+
console.log(data, 'handleCameraPreviewFailure');
|
|
777
600
|
ipcTTTOperatorLog("cameraPreviewFailure_event_trigger_".concat(JSON.stringify(data)));
|
|
778
601
|
if (data.type === 'cameraPreviewFailure' && !privateState) {
|
|
779
602
|
// 隐私模式时不展示错误
|
|
@@ -795,181 +618,6 @@ const Player = props => {
|
|
|
795
618
|
}
|
|
796
619
|
}
|
|
797
620
|
});
|
|
798
|
-
|
|
799
|
-
/**
|
|
800
|
-
* 获取错误展示内容
|
|
801
|
-
*/
|
|
802
|
-
const getErrorContent = useMemoizedFn(() => {
|
|
803
|
-
if (!phoneNetworkConnect) {
|
|
804
|
-
return Strings.getLang('ipc_player_network_fail');
|
|
805
|
-
}
|
|
806
|
-
if (!onlineStatus) {
|
|
807
|
-
return Strings.getLang('ipc_player_device_offline');
|
|
808
|
-
}
|
|
809
|
-
if (!isLowPowerDevice && onlineStatus && privateState) {
|
|
810
|
-
return Strings.getLang('ipc_player_device_sleep');
|
|
811
|
-
}
|
|
812
|
-
|
|
813
|
-
// 低功耗隐私模式正常唤醒
|
|
814
|
-
if (isLowPowerDevice && lowPowerDeviceOnlineState && privateState && !lowPrivateOutTimeFlag) {
|
|
815
|
-
return Strings.getLang('ipc_player_device_sleep');
|
|
816
|
-
}
|
|
817
|
-
// 低功耗隐私模式正常唤醒,下发指令失败
|
|
818
|
-
if (isLowPowerDevice && lowPowerDeviceOnlineState && privateState && !lowPrivateOutTimeFlag) {
|
|
819
|
-
return Strings.getLang('ipc_player_private_open_low_stream_fail');
|
|
820
|
-
}
|
|
821
|
-
if (!isLowPowerDevice && device4GIsFreeze && onlineStatus && !privateState) {
|
|
822
|
-
return deviceFreezeReasonStore[deviceFreezeReason];
|
|
823
|
-
}
|
|
824
|
-
if (isLowPowerDevice && device4GIsFreeze && lowPowerDeviceOnlineState && !privateState) {
|
|
825
|
-
return deviceFreezeReasonStore[deviceFreezeReason];
|
|
826
|
-
}
|
|
827
|
-
if (onlineStatus && trafficLessOrEqualZero) {
|
|
828
|
-
return Strings.getLang('ipc_player_traffic_load_online_zero_tip');
|
|
829
|
-
}
|
|
830
|
-
|
|
831
|
-
// if (isLowPowerDevice && lowPowerDeviceOnlineState) {
|
|
832
|
-
// return Strings.getLang('ipc_player_traffic_load_online_zero_tip');
|
|
833
|
-
// }
|
|
834
|
-
|
|
835
|
-
if (!onlineStatus) {
|
|
836
|
-
return Strings.getLang('ipc_player_no_line');
|
|
837
|
-
}
|
|
838
|
-
if (videoErrCode !== '') {
|
|
839
|
-
if (Strings["ipc_player_error_".concat(codeCoverToInt(videoErrCode))]) {
|
|
840
|
-
return "".concat(Strings.getLang("ipc_player_error_".concat(codeCoverToInt(videoErrCode))), "(").concat(videoErrCode, ")");
|
|
841
|
-
}
|
|
842
|
-
return "".concat(Strings.getLang("ipc_player_error_common"), "(").concat(videoErrCode, ")");
|
|
843
|
-
}
|
|
844
|
-
return playState.errorMsg;
|
|
845
|
-
});
|
|
846
|
-
|
|
847
|
-
/**
|
|
848
|
-
* 根据自定义类型获取错误码展示内容
|
|
849
|
-
*/
|
|
850
|
-
|
|
851
|
-
const getErrorContentByType = useMemoizedFn((errCode, type) => {
|
|
852
|
-
const errContent = getErrCodeDetailDataByCode(String(errCode));
|
|
853
|
-
const contentEmpty = _isEmpty(errContent);
|
|
854
|
-
switch (type) {
|
|
855
|
-
// 是否展示建议文案
|
|
856
|
-
case 'suggestedFlag':
|
|
857
|
-
if (hideSuggestedText) {
|
|
858
|
-
return false;
|
|
859
|
-
}
|
|
860
|
-
if (contentEmpty) {
|
|
861
|
-
return false;
|
|
862
|
-
}
|
|
863
|
-
return errContent.suggestedText !== '';
|
|
864
|
-
|
|
865
|
-
// 建议文案
|
|
866
|
-
case 'suggestedText':
|
|
867
|
-
if (contentEmpty || privateState) {
|
|
868
|
-
return '';
|
|
869
|
-
}
|
|
870
|
-
return errContent.suggestedText;
|
|
871
|
-
// 是否展示点我重试
|
|
872
|
-
case 'retry':
|
|
873
|
-
if (!phoneNetworkConnect) {
|
|
874
|
-
return false;
|
|
875
|
-
}
|
|
876
|
-
if (!isLowPowerDevice && !onlineStatus) {
|
|
877
|
-
return false;
|
|
878
|
-
}
|
|
879
|
-
if (isLowPowerDevice && !lowPowerDeviceOnlineState) {
|
|
880
|
-
return false;
|
|
881
|
-
}
|
|
882
|
-
if (privateState && !isShare && !device4GIsFreeze) {
|
|
883
|
-
return true;
|
|
884
|
-
}
|
|
885
|
-
if (privateState && isShare) {
|
|
886
|
-
return false;
|
|
887
|
-
}
|
|
888
|
-
|
|
889
|
-
// 设备4G冻结,冻结原因为特殊情况下,展示retry
|
|
890
|
-
if (device4GIsFreeze && onlineStatus && !privateState && deviceFreezeReason === 1) {
|
|
891
|
-
return true;
|
|
892
|
-
}
|
|
893
|
-
if (contentEmpty || privateState) {
|
|
894
|
-
return true;
|
|
895
|
-
}
|
|
896
|
-
return errContent.try;
|
|
897
|
-
// 是否展示点我重试
|
|
898
|
-
case 'retryText':
|
|
899
|
-
if (privateState) {
|
|
900
|
-
return Strings.getLang('ipc_player_re_wake_camera');
|
|
901
|
-
}
|
|
902
|
-
return Strings.getLang('ipc_player_retry');
|
|
903
|
-
case 'help':
|
|
904
|
-
if (hideHelpButton) {
|
|
905
|
-
return false;
|
|
906
|
-
}
|
|
907
|
-
if (!phoneNetworkConnect || privateState) {
|
|
908
|
-
return false;
|
|
909
|
-
}
|
|
910
|
-
if (isLowPowerDevice && lowPowerDeviceOnlineState) {
|
|
911
|
-
return false;
|
|
912
|
-
}
|
|
913
|
-
if (isLowPowerDevice && !lowPowerDeviceOnlineState) {
|
|
914
|
-
return true;
|
|
915
|
-
}
|
|
916
|
-
if (!isLowPowerDevice && !onlineStatus) {
|
|
917
|
-
return true;
|
|
918
|
-
}
|
|
919
|
-
if (privateState && isShare) {
|
|
920
|
-
return false;
|
|
921
|
-
}
|
|
922
|
-
if (contentEmpty) {
|
|
923
|
-
return false;
|
|
924
|
-
}
|
|
925
|
-
return errContent.help;
|
|
926
|
-
case 'helpNum':
|
|
927
|
-
if (privateState && isShare) {
|
|
928
|
-
return false;
|
|
929
|
-
}
|
|
930
|
-
return errContent.helpNum;
|
|
931
|
-
case 'feedBack':
|
|
932
|
-
if (hideFeedBackButton) {
|
|
933
|
-
return false;
|
|
934
|
-
}
|
|
935
|
-
if (!phoneNetworkConnect) {
|
|
936
|
-
return true;
|
|
937
|
-
}
|
|
938
|
-
if (privateState) {
|
|
939
|
-
return false;
|
|
940
|
-
}
|
|
941
|
-
if (contentEmpty) {
|
|
942
|
-
return false;
|
|
943
|
-
}
|
|
944
|
-
return errContent.feedBack;
|
|
945
|
-
default:
|
|
946
|
-
return false;
|
|
947
|
-
}
|
|
948
|
-
});
|
|
949
|
-
|
|
950
|
-
/**
|
|
951
|
-
* 跳转帮助小程序
|
|
952
|
-
*/
|
|
953
|
-
const handleGotoHelpMini = useMemoizedFn(async () => {
|
|
954
|
-
if (isLowPowerDevice && !lowPowerDeviceOnlineState || !onlineStatus) {
|
|
955
|
-
const realLanguage = await getLanguage();
|
|
956
|
-
const url = "godzilla://".concat(miniIdLabs.helpMini, "/pages/commonDetails/index?answer=/app-helpcenter/").concat(realLanguage, "/K94ow0gwu9bg2");
|
|
957
|
-
openTargetMinByShortLink(url);
|
|
958
|
-
return false;
|
|
959
|
-
}
|
|
960
|
-
const helpNum = getErrorContentByType(videoErrCode, 'helpNum');
|
|
961
|
-
const helpFeedBack = getErrorContentByType(videoErrCode, 'helpFeedBack');
|
|
962
|
-
const homeInfo = await getHomeInfo();
|
|
963
|
-
const devInfo = await getDeviceInfo(devId);
|
|
964
|
-
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);
|
|
965
|
-
openTargetMinByShortLink(url);
|
|
966
|
-
return false;
|
|
967
|
-
});
|
|
968
|
-
|
|
969
|
-
/**
|
|
970
|
-
* 跳转反馈小程序
|
|
971
|
-
*/
|
|
972
|
-
|
|
973
621
|
return /*#__PURE__*/React.createElement(View, {
|
|
974
622
|
className: getClassName('ipc-player'),
|
|
975
623
|
onClick: () => {
|
|
@@ -1006,61 +654,47 @@ const Player = props => {
|
|
|
1006
654
|
borderColor: borderColor,
|
|
1007
655
|
borderWidth: borderWidth,
|
|
1008
656
|
backgroundColor: bgColor
|
|
1009
|
-
}, extend)), /*#__PURE__*/React.createElement(
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
className: clsx(getClassName('operator-btn'), getClassName('operator-retry')),
|
|
1043
|
-
style: {
|
|
1044
|
-
backgroundColor: "".concat(brandColor)
|
|
1045
|
-
},
|
|
1046
|
-
onClick: retry
|
|
1047
|
-
}, getErrorContentByType(videoErrCode, 'retryText')), getErrorContentByType(videoErrCode, 'help') && /*#__PURE__*/React.createElement(View, {
|
|
1048
|
-
className: clsx(getClassName('operator-btn'), getClassName('operator-help')),
|
|
1049
|
-
onClick: handleGotoHelpMini
|
|
1050
|
-
}, Strings.getLang('ipc_player_help')), getErrorContentByType(videoErrCode, 'feedBack') && /*#__PURE__*/React.createElement(View, {
|
|
1051
|
-
className: clsx(getClassName('operator-btn'), getClassName('operator-feedback')),
|
|
1052
|
-
onClick: () => {
|
|
1053
|
-
const url = "godzilla://".concat(miniIdLabs.helpMini, "/pages/v2/problemSubmit/index");
|
|
1054
|
-
openTargetMinByShortLink(url);
|
|
1055
|
-
}
|
|
1056
|
-
}, Strings.getLang('ipc_player_feedback')))), screenType === 'landscape' && (playState.loadingState || playState.errorState) && /*#__PURE__*/React.createElement(CoverView, {
|
|
1057
|
-
className: clsx(getClassName('load-full-back-container')),
|
|
1058
|
-
onClick: () => {
|
|
657
|
+
}, extend)), /*#__PURE__*/React.createElement(LoadingOverlay, {
|
|
658
|
+
isLoading: playState.loadingState,
|
|
659
|
+
loadingText: loadText || playState.loadingText,
|
|
660
|
+
borderRadius: borderRadius,
|
|
661
|
+
getClassName: getClassName
|
|
662
|
+
}), /*#__PURE__*/React.createElement(ErrorOverlay, {
|
|
663
|
+
devId: devId,
|
|
664
|
+
isError: playState.errorState,
|
|
665
|
+
videoErrCode: videoErrCode,
|
|
666
|
+
borderRadius: borderRadius,
|
|
667
|
+
brandColor: brandColor,
|
|
668
|
+
getClassName: getClassName,
|
|
669
|
+
renderErrIcon: renderErrIcon,
|
|
670
|
+
onRetry: retry,
|
|
671
|
+
phoneNetworkConnect: phoneNetworkConnect,
|
|
672
|
+
onlineStatus: onlineStatus,
|
|
673
|
+
privateState: privateState,
|
|
674
|
+
isLowPowerDevice: isLowPowerDevice,
|
|
675
|
+
lowPowerDeviceOnlineState: lowPowerDeviceOnlineState,
|
|
676
|
+
lowPrivateOutTimeFlag: lowPrivateOutTimeFlag,
|
|
677
|
+
device4GIsFreeze: device4GIsFreeze,
|
|
678
|
+
deviceFreezeReason: deviceFreezeReason,
|
|
679
|
+
playStateErrorMsg: playState.errorMsg,
|
|
680
|
+
hideSuggestedText: hideSuggestedText,
|
|
681
|
+
hideHelpButton: hideHelpButton,
|
|
682
|
+
hideFeedBackButton: hideFeedBackButton,
|
|
683
|
+
isShare: isShare,
|
|
684
|
+
limitFlow: limitFlow,
|
|
685
|
+
autoPlay: autoPlay
|
|
686
|
+
}), /*#__PURE__*/React.createElement(FullScreenBackButton, {
|
|
687
|
+
isVisible: screenType === 'landscape' && (playState.loadingState || playState.errorState),
|
|
688
|
+
getClassName: getClassName,
|
|
689
|
+
onBackFullScreen: () => {
|
|
1059
690
|
setScreenType('portrait');
|
|
1060
691
|
setPageOrientation({
|
|
1061
692
|
pageOrientation: 'portrait',
|
|
1062
693
|
success: () => {
|
|
1063
|
-
|
|
694
|
+
console.log('Landscape mode exited successfully');
|
|
695
|
+
},
|
|
696
|
+
fail: () => {
|
|
697
|
+
console.log('Failed to exit landscape mode');
|
|
1064
698
|
}
|
|
1065
699
|
});
|
|
1066
700
|
}
|