@ray-js/ray-ipc-player 2.0.31 → 2.1.0-beta.2
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 +320 -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 +221 -592
- 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,15 @@ 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
|
-
|
|
103
|
+
|
|
104
|
+
// 标记是否进入内存缓存/后台(onPause、onHide 设为 true,onShow 还原为 false),拉流时若为 true 则拦截
|
|
105
|
+
const isInBackgroundRef = useRef(false);
|
|
108
106
|
|
|
109
107
|
// 自定义计时老低功耗方案设备在线状态, 用于短暂时间报上下线的UI展示兼容 待实现
|
|
110
108
|
const [lowPowerDeviceOnlineState, setLowPowerDeviceOnlineState] = useState(onlineStatus);
|
|
@@ -114,8 +112,6 @@ const Player = props => {
|
|
|
114
112
|
const [device4GIsFreeze, setDevice4GIsFreeze] = useState(false);
|
|
115
113
|
// 4G设备冻结原因, 待实现
|
|
116
114
|
const [deviceFreezeReason, setDeviceFreezeReason] = useState(1);
|
|
117
|
-
// 4G设备流量是否不足
|
|
118
|
-
const [trafficLessOrEqualZero, setTrafficLessOrEqualZero] = useState(false);
|
|
119
115
|
// 手机连接网络状态
|
|
120
116
|
const [phoneNetworkConnect, setPhoneNetworkConnect] = useState(true);
|
|
121
117
|
const ipcCtx = useRef(null); // ipc实例
|
|
@@ -127,7 +123,56 @@ const Player = props => {
|
|
|
127
123
|
const retryCount = useRef(0); // 重试次数
|
|
128
124
|
const muteRef = useRef(defaultMute); // 静音
|
|
129
125
|
|
|
126
|
+
/**
|
|
127
|
+
* 设置声音
|
|
128
|
+
*/
|
|
129
|
+
|
|
130
|
+
// 使用连接相关的 hook
|
|
131
|
+
const {
|
|
132
|
+
_retry,
|
|
133
|
+
_reConnect,
|
|
134
|
+
stopPreview,
|
|
135
|
+
disconnect,
|
|
136
|
+
handleReWakeCamera,
|
|
137
|
+
handleReWakeCameraLowPowerDevice,
|
|
138
|
+
getPlayerRoute
|
|
139
|
+
} = usePlayerConnection({
|
|
140
|
+
devId,
|
|
141
|
+
ipcCtx,
|
|
142
|
+
playState,
|
|
143
|
+
setPlayState,
|
|
144
|
+
setVideoErrCode,
|
|
145
|
+
onChangeStreamStatus,
|
|
146
|
+
onInitPreview,
|
|
147
|
+
playerRoute,
|
|
148
|
+
privateState,
|
|
149
|
+
isLowPowerDevice,
|
|
150
|
+
awakeStatus,
|
|
151
|
+
wirelessFlag,
|
|
152
|
+
setEnableWakeUpInterval,
|
|
153
|
+
setLowPrivateOutTimeFlag,
|
|
154
|
+
setMqttPrivateFlag,
|
|
155
|
+
privateLowPowerDeviceTimeOutRef,
|
|
156
|
+
privateWakeOutTimeRef,
|
|
157
|
+
firstPreviewTimeRef,
|
|
158
|
+
retryCount,
|
|
159
|
+
muteRef,
|
|
160
|
+
setMuted: val => {
|
|
161
|
+
var _ipcCtx$current;
|
|
162
|
+
ipcTTTOperatorLog("VID: begin_to_set_mute");
|
|
163
|
+
(_ipcCtx$current = ipcCtx.current) === null || _ipcCtx$current === void 0 || _ipcCtx$current.setMuted({
|
|
164
|
+
mute: val,
|
|
165
|
+
success: () => {
|
|
166
|
+
ipcTTTOperatorLog("VID: set_mute_success: ".concat(val));
|
|
167
|
+
},
|
|
168
|
+
fail: () => {
|
|
169
|
+
ipcTTTOperatorLog("VID: set_mute_failure: ".concat(val));
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
});
|
|
130
174
|
usePageEvent('onShow', useMemoizedFn(async () => {
|
|
175
|
+
isInBackgroundRef.current = false;
|
|
131
176
|
getNetworkType({
|
|
132
177
|
success: res => {
|
|
133
178
|
console.log('网络类型', res);
|
|
@@ -143,7 +188,7 @@ const Player = props => {
|
|
|
143
188
|
return;
|
|
144
189
|
}
|
|
145
190
|
// 视图准备就绪
|
|
146
|
-
if (phoneNetworkConnect && playState.initLy && ipcCtx.current && onlineStatus && !privateState) {
|
|
191
|
+
if (phoneNetworkConnect && playState.initLy && ipcCtx.current && onlineStatus && !privateState && !limitFlow && autoPlay) {
|
|
147
192
|
ipcTTTOperatorLog('VID: onShow_event_to_retry');
|
|
148
193
|
retry();
|
|
149
194
|
}
|
|
@@ -162,6 +207,24 @@ const Player = props => {
|
|
|
162
207
|
setScreenType(type);
|
|
163
208
|
}
|
|
164
209
|
});
|
|
210
|
+
|
|
211
|
+
// 针对limitFlow
|
|
212
|
+
useEffect(() => {
|
|
213
|
+
if (limitFlow || !autoPlay) {
|
|
214
|
+
setPlayState(d => {
|
|
215
|
+
return _objectSpread(_objectSpread({}, d), {}, {
|
|
216
|
+
loadingState: false,
|
|
217
|
+
errorState: true,
|
|
218
|
+
errorMessage: ''
|
|
219
|
+
});
|
|
220
|
+
});
|
|
221
|
+
ipcTTTOperatorLog("limitFlow ~~~~ ".concat(limitFlow, " autoPlay ~~~ ").concat(autoPlay));
|
|
222
|
+
if (playState.initLy && ipcCtx.current) {
|
|
223
|
+
stopPreview();
|
|
224
|
+
disconnect();
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}, [limitFlow, autoPlay, playState.initLy, ipcCtx.current]);
|
|
165
228
|
useEffect(() => {
|
|
166
229
|
registerDeviceListListener({
|
|
167
230
|
deviceIdList: [devId],
|
|
@@ -192,6 +255,8 @@ const Player = props => {
|
|
|
192
255
|
onDpDataChange(handleDpDataChange);
|
|
193
256
|
}, []);
|
|
194
257
|
usePageEvent('onHide', useMemoizedFn(async () => {
|
|
258
|
+
isInBackgroundRef.current = true;
|
|
259
|
+
ipcTTTOperatorLog('VID: onHide event will go to stopPreview');
|
|
195
260
|
if (ignoreHideStopPreview) {
|
|
196
261
|
return;
|
|
197
262
|
}
|
|
@@ -203,27 +268,12 @@ const Player = props => {
|
|
|
203
268
|
// await getCurMute();
|
|
204
269
|
}));
|
|
205
270
|
useAppEvent('onPause', useMemoizedFn(async () => {
|
|
271
|
+
isInBackgroundRef.current = true;
|
|
206
272
|
console.log('onPause, 重新拉流');
|
|
207
273
|
ipcTTTOperatorLog('VID: onPause stopPreview');
|
|
208
274
|
stopPreview();
|
|
209
275
|
disconnect();
|
|
210
276
|
}));
|
|
211
|
-
useMount(() => {
|
|
212
|
-
onNetworkStatusChange(res => {
|
|
213
|
-
setPhoneNetworkConnect(res.isConnected);
|
|
214
|
-
if (!res.isConnected) {
|
|
215
|
-
// 断网,需要主动调用断流以及断开P2P
|
|
216
|
-
ipcTTTOperatorLog('VID: network is not connected, need stop preview and disconnect');
|
|
217
|
-
stopPreview();
|
|
218
|
-
disconnect();
|
|
219
|
-
}
|
|
220
|
-
});
|
|
221
|
-
});
|
|
222
|
-
useUnmount(() => {
|
|
223
|
-
offNetworkStatusChange(res => {
|
|
224
|
-
console.log(res);
|
|
225
|
-
});
|
|
226
|
-
});
|
|
227
277
|
const handleDpDataChange = useMemoizedFn(res => {
|
|
228
278
|
if (res.deviceId === devId) {
|
|
229
279
|
const dpsInfo = res.dps;
|
|
@@ -277,7 +327,8 @@ const Player = props => {
|
|
|
277
327
|
});
|
|
278
328
|
|
|
279
329
|
/**
|
|
280
|
-
* 监听mqtt
|
|
330
|
+
* 监听mqtt协议消息
|
|
331
|
+
* 主要用于低功耗设备的唤醒状态监听
|
|
281
332
|
*/
|
|
282
333
|
useEffect(() => {
|
|
283
334
|
registerMQTTProtocolListener({
|
|
@@ -299,6 +350,31 @@ const Player = props => {
|
|
|
299
350
|
};
|
|
300
351
|
}, []);
|
|
301
352
|
|
|
353
|
+
/**
|
|
354
|
+
* 监听网络状态变化
|
|
355
|
+
* 组件挂载时开始监听,网络断开时主动停流和断开连接
|
|
356
|
+
* 组件卸载时移除监听器
|
|
357
|
+
*/
|
|
358
|
+
useEffect(() => {
|
|
359
|
+
const handleNetworkStatusChange = res => {
|
|
360
|
+
setPhoneNetworkConnect(res.isConnected);
|
|
361
|
+
if (!res.isConnected) {
|
|
362
|
+
// 断网,需要主动调用断流以及断开P2P
|
|
363
|
+
ipcTTTOperatorLog('VID: network is not connected, need stop preview and disconnect');
|
|
364
|
+
stopPreview();
|
|
365
|
+
disconnect();
|
|
366
|
+
}
|
|
367
|
+
};
|
|
368
|
+
|
|
369
|
+
// 开始监听网络状态变化
|
|
370
|
+
onNetworkStatusChange(handleNetworkStatusChange);
|
|
371
|
+
|
|
372
|
+
// 清理函数:组件卸载时移除网络状态监听器
|
|
373
|
+
return () => {
|
|
374
|
+
offNetworkStatusChange(handleNetworkStatusChange);
|
|
375
|
+
};
|
|
376
|
+
}, [stopPreview, disconnect]);
|
|
377
|
+
|
|
302
378
|
/**
|
|
303
379
|
* 唤醒设备TTT能力
|
|
304
380
|
*/
|
|
@@ -307,13 +383,23 @@ const Player = props => {
|
|
|
307
383
|
enabled: enableWakeUpInterval,
|
|
308
384
|
intervalTime: 300
|
|
309
385
|
});
|
|
386
|
+
|
|
387
|
+
/**
|
|
388
|
+
* 监听设备休眠状态变化
|
|
389
|
+
* 当检测到设备上报休眠后,触发重新连接
|
|
390
|
+
*/
|
|
310
391
|
useEffect(() => {
|
|
311
|
-
if (wirelessFlag) {
|
|
392
|
+
if (wirelessFlag && !isInBackgroundRef.current) {
|
|
312
393
|
// 进入面板后,若监听到设备上报休眠后, 需进行重新连接
|
|
313
394
|
setWirelessFlag(false);
|
|
314
395
|
_reConnect();
|
|
315
396
|
}
|
|
316
|
-
}, [wirelessFlag]);
|
|
397
|
+
}, [wirelessFlag, _reConnect]);
|
|
398
|
+
|
|
399
|
+
/**
|
|
400
|
+
* 初始化获取网络类型
|
|
401
|
+
* 组件挂载时主动获取一次当前网络状态
|
|
402
|
+
*/
|
|
317
403
|
useEffect(() => {
|
|
318
404
|
getNetworkType({
|
|
319
405
|
success: res => {
|
|
@@ -326,18 +412,29 @@ const Player = props => {
|
|
|
326
412
|
}
|
|
327
413
|
});
|
|
328
414
|
}, []);
|
|
415
|
+
|
|
416
|
+
/**
|
|
417
|
+
* IPC实例生命周期管理
|
|
418
|
+
* 当设备在线且devId变化时创建IPC实例
|
|
419
|
+
* 组件卸载时断开连接并清理实例
|
|
420
|
+
*/
|
|
329
421
|
useEffect(() => {
|
|
330
422
|
onlineStatus && createIpcCtx();
|
|
331
423
|
return () => {
|
|
332
424
|
disconnect();
|
|
333
425
|
ipcCtx.current = null;
|
|
334
426
|
};
|
|
335
|
-
}, [devId, onlineStatus]);
|
|
427
|
+
}, [devId, onlineStatus, disconnect]);
|
|
428
|
+
|
|
429
|
+
/**
|
|
430
|
+
* 外部重连指令处理
|
|
431
|
+
* 当接收到外部重连指令且设备在线时,触发重新连接
|
|
432
|
+
*/
|
|
336
433
|
useEffect(() => {
|
|
337
|
-
if (reConnect && devId && onlineStatus) {
|
|
434
|
+
if (reConnect && devId && onlineStatus && !isInBackgroundRef.current) {
|
|
338
435
|
_reConnect();
|
|
339
436
|
}
|
|
340
|
-
}, [reConnect]);
|
|
437
|
+
}, [reConnect, devId, onlineStatus, _reConnect]);
|
|
341
438
|
useEffect(() => {
|
|
342
439
|
muteRef.current = defaultMute;
|
|
343
440
|
}, [defaultMute]);
|
|
@@ -361,10 +458,19 @@ const Player = props => {
|
|
|
361
458
|
console.log('监听到设备离线');
|
|
362
459
|
setPlayState(d => {
|
|
363
460
|
d.errorState = true;
|
|
364
|
-
d.errorMsg = Strings.getLang('ipc_player_device_offline');
|
|
461
|
+
d.errorMsg = limitFlow ? Strings.getLang('ipc_player_traffic_load_offline_limit_tip') : Strings.getLang('ipc_player_device_offline');
|
|
462
|
+
});
|
|
463
|
+
} else if (!autoPlay) {
|
|
464
|
+
setPlayState(d => {
|
|
465
|
+
d.errorState = true;
|
|
466
|
+
d.errorMsg = '设备处于休眠中';
|
|
467
|
+
});
|
|
468
|
+
} else if (limitFlow) {
|
|
469
|
+
setPlayState(d => {
|
|
470
|
+
d.errorState = true;
|
|
471
|
+
d.errorMsg = Strings.getLang('ipc_player_traffic_load_online_zero_tip');
|
|
365
472
|
});
|
|
366
473
|
} else if (playState.initLy && !privateState) {
|
|
367
|
-
console.log('sdhjsahdjshajdh');
|
|
368
474
|
ipcTTTOperatorLog("VID: privateState_status_change: ".concat(privateState));
|
|
369
475
|
retry();
|
|
370
476
|
} else if (playState.initLy && privateState) {
|
|
@@ -373,139 +479,10 @@ const Player = props => {
|
|
|
373
479
|
onChangeStreamStatus && onChangeStreamStatus(-1001);
|
|
374
480
|
}
|
|
375
481
|
}
|
|
376
|
-
}, [phoneNetworkConnect, onlineStatus, playState.initLy, privateState]);
|
|
377
|
-
|
|
378
|
-
// 重试
|
|
379
|
-
const _retry = async () => {
|
|
380
|
-
console.log('调用了重试');
|
|
381
|
-
const connectState = await getIsConnected(ipcCtx.current);
|
|
382
|
-
console.log('调用了重试--connectState');
|
|
383
|
-
const isOnPreview = await getIsOnPreview(ipcCtx.current);
|
|
384
|
-
console.log('调用了重试--isOnPreview');
|
|
385
|
-
setPlayState(d => {
|
|
386
|
-
d.connectState = connectState ? true : false;
|
|
387
|
-
d.errorMsg = '';
|
|
388
|
-
d.errorState = false;
|
|
389
|
-
d.loadingState = isOnPreview ? false : true;
|
|
390
|
-
});
|
|
391
|
-
setVideoErrCode('');
|
|
392
|
-
// !prePlayRef.current && connectState && (await disconnect());
|
|
393
|
-
// console.log(connectState, isOnPreview, '当前链接状态和预览状态');
|
|
394
|
-
ipcTTTOperatorLog("VID: start_create_p2p_connect");
|
|
395
|
-
ipcCtx.current && createConnect();
|
|
396
|
-
};
|
|
397
|
-
|
|
398
|
-
// 无需关心连接状态直接发起重新连接
|
|
399
|
-
const _reConnect = () => {
|
|
400
|
-
console.log('不在播放器路由内, 不进行标记');
|
|
401
|
-
// 排除默认值为"",不等于播放器路由时, 不进行连接操作
|
|
402
|
-
if (playerRoute !== '' && playerRoute !== getPlayerRoute()) {
|
|
403
|
-
return;
|
|
404
|
-
}
|
|
405
|
-
setPlayState(d => {
|
|
406
|
-
d.connectState = true;
|
|
407
|
-
d.loadingText = Strings.getLang('ipc_player_get_video_stream');
|
|
408
|
-
d.errorMsg = '';
|
|
409
|
-
d.errorState = false;
|
|
410
|
-
d.loadingState = true;
|
|
411
|
-
});
|
|
412
|
-
setVideoErrCode('');
|
|
413
|
-
// !prePlayRef.current && connectState && (await disconnect());
|
|
414
|
-
// console.log(connectState, isOnPreview, '当前链接状态和预览状态');
|
|
415
|
-
ipcTTTOperatorLog("VID: start_create_p2p_connect");
|
|
416
|
-
ipcCtx.current && createConnect();
|
|
417
|
-
};
|
|
418
|
-
|
|
419
|
-
/**
|
|
420
|
-
* 关闭隐私模式,重新拉流
|
|
421
|
-
*/
|
|
422
|
-
const handleReWakeCamera = async () => {
|
|
423
|
-
setPlayState(d => {
|
|
424
|
-
d.connectState = true;
|
|
425
|
-
d.errorMsg = '';
|
|
426
|
-
d.loadingText = Strings.getLang('ipc_player_private_open_stream');
|
|
427
|
-
d.errorState = false;
|
|
428
|
-
d.loadingState = true;
|
|
429
|
-
});
|
|
430
|
-
setVideoErrCode('');
|
|
431
|
-
const sendDpId = await getDpIdByDpCode(devId, 'basic_private');
|
|
432
|
-
if (sendDpId === -1) {
|
|
433
|
-
showToast(Strings.getLang('ipc_player_basic_private_not_exist'));
|
|
434
|
-
} else {
|
|
435
|
-
publishDps({
|
|
436
|
-
deviceId: devId,
|
|
437
|
-
dps: {
|
|
438
|
-
[sendDpId]: false
|
|
439
|
-
},
|
|
440
|
-
mode: 1,
|
|
441
|
-
pipelines: [0, 1, 2, 3, 4, 5, 6],
|
|
442
|
-
options: {},
|
|
443
|
-
success: () => {
|
|
444
|
-
console.log('下发隐私模式成功');
|
|
445
|
-
}
|
|
446
|
-
});
|
|
447
|
-
}
|
|
448
|
-
};
|
|
449
|
-
|
|
450
|
-
/**
|
|
451
|
-
*
|
|
452
|
-
* 低功耗设备关闭隐私模式,先判断设备是否唤醒,唤醒后才可下发隐私模式DP
|
|
453
|
-
*/
|
|
454
|
-
|
|
455
|
-
const handleReWakeCameraLowPowerDevice = useMemoizedFn(() => {
|
|
456
|
-
setVideoErrCode('');
|
|
457
|
-
setLowPrivateOutTimeFlag(false);
|
|
458
|
-
if (awakeStatus) {
|
|
459
|
-
setPlayState(d => {
|
|
460
|
-
d.connectState = true;
|
|
461
|
-
d.errorMsg = '';
|
|
462
|
-
d.loadingText = Strings.getLang('ipc_player_private_open_stream');
|
|
463
|
-
d.errorState = false;
|
|
464
|
-
d.loadingState = true;
|
|
465
|
-
});
|
|
466
|
-
// 如果值为true, 表示设备为唤醒状态,直接下发隐私模式DP
|
|
467
|
-
handleReWakeCamera();
|
|
468
|
-
} else {
|
|
469
|
-
setPlayState(d => {
|
|
470
|
-
d.connectState = true;
|
|
471
|
-
d.errorMsg = '';
|
|
472
|
-
d.loadingText = Strings.getLang('ipc_player_private_open_low_stream');
|
|
473
|
-
d.errorState = false;
|
|
474
|
-
d.loadingState = true;
|
|
475
|
-
});
|
|
476
|
-
// 如果值为false, 表示设备为睡眠状态,需要唤醒设备
|
|
477
|
-
setMqttPrivateFlag(true);
|
|
478
|
-
setEnableWakeUpInterval(true);
|
|
479
|
-
// 2秒后停止下发唤醒, 防止频繁唤醒, 此时若Mqtt监听到1协议,也会停止下发唤醒
|
|
480
|
-
privateLowPowerDeviceTimeOutRef.current = setTimeout(() => {
|
|
481
|
-
setEnableWakeUpInterval(false);
|
|
482
|
-
// 清除定时器
|
|
483
|
-
privateLowPowerDeviceTimeOutRef.current && clearTimeout(privateLowPowerDeviceTimeOutRef.current);
|
|
484
|
-
}, 2000);
|
|
485
|
-
|
|
486
|
-
// 15 秒后若设备还是未唤醒,未监听到Mqtt消息以及唤醒Dp上报, 则提示报错
|
|
487
|
-
privateWakeOutTimeRef.current = setTimeout(() => {
|
|
488
|
-
// 清除定时器
|
|
489
|
-
privateLowPowerDeviceTimeOutRef.current && clearTimeout(privateWakeOutTimeRef.current);
|
|
490
|
-
setPlayState(d => {
|
|
491
|
-
d.connectState = false;
|
|
492
|
-
d.errorMsg = Strings.getLang('ipc_player_private_open_low_stream_fail');
|
|
493
|
-
d.errorState = true;
|
|
494
|
-
d.loadingState = false;
|
|
495
|
-
});
|
|
496
|
-
setMqttPrivateFlag(false);
|
|
497
|
-
setLowPrivateOutTimeFlag(true);
|
|
498
|
-
}, 15000);
|
|
499
|
-
}
|
|
500
|
-
});
|
|
501
|
-
const getPlayerRoute = () => {
|
|
502
|
-
const pages = getCurrentPages(); // 获取当前页面栈
|
|
503
|
-
const currentPage = pages[pages.length - 1]; // 获取当前页面实例
|
|
504
|
-
return currentPage.route;
|
|
505
|
-
};
|
|
482
|
+
}, [phoneNetworkConnect, onlineStatus, playState.initLy, privateState, limitFlow, autoPlay]);
|
|
506
483
|
const retry = useMemoizedFn(() => {
|
|
507
484
|
console.log('重新拉流启动');
|
|
508
|
-
|
|
485
|
+
setAutoPlay(true);
|
|
509
486
|
// 任何重试拉流时, 将播放器状态还原为loading状态
|
|
510
487
|
setVideoErrCode('');
|
|
511
488
|
setPlayState(d => {
|
|
@@ -519,6 +496,11 @@ const Player = props => {
|
|
|
519
496
|
console.log('不在播放器路由内, 不进行拉流');
|
|
520
497
|
return;
|
|
521
498
|
}
|
|
499
|
+
if (isInBackgroundRef.current) {
|
|
500
|
+
console.log('处于后台/内存缓存,拦截拉流');
|
|
501
|
+
ipcTTTOperatorLog('VID: isInBackground, block retry');
|
|
502
|
+
return;
|
|
503
|
+
}
|
|
522
504
|
phoneNetworkConnect && onlineStatus && privateState && (!isLowPowerDevice || isVirtualDevice) && handleReWakeCamera();
|
|
523
505
|
|
|
524
506
|
// 低功耗设备隐私模式需单独处理,先进行下发唤醒, 唤醒后再进行下发DP
|
|
@@ -535,149 +517,8 @@ const Player = props => {
|
|
|
535
517
|
});
|
|
536
518
|
};
|
|
537
519
|
|
|
538
|
-
// 建立连接
|
|
539
|
-
const createConnect = useMemoizedFn(async params => {
|
|
540
|
-
var _ipcCtx$current;
|
|
541
|
-
if (playerRoute !== '' && playerRoute !== getPlayerRoute()) {
|
|
542
|
-
console.log('不在播放器路由内, 不进行连接操作');
|
|
543
|
-
return;
|
|
544
|
-
}
|
|
545
|
-
// console.log('建立连接前:', devId, Date.now());
|
|
546
|
-
// 若走到连接状态,需清除低功耗15秒超时定时
|
|
547
|
-
privateLowPowerDeviceTimeOutRef.current && clearTimeout(privateWakeOutTimeRef.current);
|
|
548
|
-
setLowPrivateOutTimeFlag(false);
|
|
549
|
-
// 表示为 149 低功耗设备, 唤醒设备
|
|
550
|
-
if (isLowPowerDevice) {
|
|
551
|
-
// 下发唤醒
|
|
552
|
-
setEnableWakeUpInterval(true);
|
|
553
|
-
}
|
|
554
|
-
(_ipcCtx$current = ipcCtx.current) === null || _ipcCtx$current === void 0 || _ipcCtx$current.connect({
|
|
555
|
-
success: () => {
|
|
556
|
-
ipcTTTOperatorLog("VID: create_p2p_connect_success");
|
|
557
|
-
// 清除唤醒定时器
|
|
558
|
-
setEnableWakeUpInterval(false);
|
|
559
|
-
setPlayState(d => {
|
|
560
|
-
d.connectState = true;
|
|
561
|
-
d.loadingText = Strings.getLang('ipc_player_get_video_stream');
|
|
562
|
-
d.errorState = false;
|
|
563
|
-
d.errorMsg = '';
|
|
564
|
-
});
|
|
565
|
-
onChangeStreamStatus && onChangeStreamStatus(1001);
|
|
566
|
-
ipcTTTOperatorLog("VID: start_to_preview");
|
|
567
|
-
startPreview(params);
|
|
568
|
-
},
|
|
569
|
-
fail: () => {
|
|
570
|
-
// 清除唤醒定时器
|
|
571
|
-
setEnableWakeUpInterval(false);
|
|
572
|
-
ipcTTTOperatorLog("VID: create_p2p_connect_failure");
|
|
573
|
-
// 针对进入面板上报149状态的为true的设备直接忽略
|
|
574
|
-
if (!wirelessFlag) {
|
|
575
|
-
setPlayState(d => {
|
|
576
|
-
d.connectState = false;
|
|
577
|
-
d.errorState = true;
|
|
578
|
-
d.errorMsg = Strings.getLang('ipc_player_connect_fail');
|
|
579
|
-
d.loadingState = false;
|
|
580
|
-
});
|
|
581
|
-
onChangeStreamStatus && onChangeStreamStatus(-1001);
|
|
582
|
-
}
|
|
583
|
-
}
|
|
584
|
-
});
|
|
585
|
-
});
|
|
586
|
-
|
|
587
520
|
// 视图层准备就绪,开始建立连接
|
|
588
521
|
|
|
589
|
-
/*
|
|
590
|
-
* 开启预览
|
|
591
|
-
*/
|
|
592
|
-
const startPreview = useMemoizedFn(params => {
|
|
593
|
-
var _ipcCtx$current2;
|
|
594
|
-
// console.log('开启预览前');
|
|
595
|
-
(_ipcCtx$current2 = ipcCtx.current) === null || _ipcCtx$current2 === void 0 || _ipcCtx$current2.startPreview({
|
|
596
|
-
success: () => {
|
|
597
|
-
ipcTTTOperatorLog('VID: start_preview_success');
|
|
598
|
-
if (typeof performanceEvent === 'function' && !firstPreviewTimeRef.current) {
|
|
599
|
-
performanceEvent({
|
|
600
|
-
launchData: '出流成功耗时',
|
|
601
|
-
success: () => {
|
|
602
|
-
firstPreviewTimeRef.current = true;
|
|
603
|
-
}
|
|
604
|
-
});
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
// console.log('开启预览:', devId);
|
|
608
|
-
setPlayState(d => {
|
|
609
|
-
d.loadingState = false;
|
|
610
|
-
d.errorState = false;
|
|
611
|
-
d.errorMsg = '';
|
|
612
|
-
});
|
|
613
|
-
setMuted(muteRef.current);
|
|
614
|
-
params && onInitPreview && onInitPreview(devId);
|
|
615
|
-
onChangeStreamStatus && onChangeStreamStatus(1002);
|
|
616
|
-
},
|
|
617
|
-
fail: async e => {
|
|
618
|
-
ipcTTTOperatorLog("VID: start_preview_fail: ".concat(JSON.stringify(e)));
|
|
619
|
-
const isOnPreview = await getIsOnPreview(ipcCtx.current);
|
|
620
|
-
ipcTTTOperatorLog("VID: get_is_on_preview_status_".concat(isOnPreview));
|
|
621
|
-
// console.error('开启失败:', e, devId, isOnPreview);
|
|
622
|
-
if (isOnPreview || e !== null && e !== void 0 && e.errorMsg.includes('doing preview')) {
|
|
623
|
-
// 忽略重复预览异常的报错
|
|
624
|
-
setPlayState(d => {
|
|
625
|
-
d.loadingState = false;
|
|
626
|
-
d.errorState = false;
|
|
627
|
-
d.errorMsg = '';
|
|
628
|
-
});
|
|
629
|
-
setMuted(muteRef.current);
|
|
630
|
-
onChangeStreamStatus && onChangeStreamStatus(1002);
|
|
631
|
-
return;
|
|
632
|
-
}
|
|
633
|
-
// 针对进入到面板,接收到上报为设备休眠的情况直接忽略
|
|
634
|
-
if (!wirelessFlag) {
|
|
635
|
-
setPlayState(d => {
|
|
636
|
-
d.errorState = true;
|
|
637
|
-
d.loadingState = false;
|
|
638
|
-
d.errorMsg = Strings.getLang('ipc_player_preview_fail');
|
|
639
|
-
});
|
|
640
|
-
onChangeStreamStatus && onChangeStreamStatus(-1002);
|
|
641
|
-
}
|
|
642
|
-
}
|
|
643
|
-
});
|
|
644
|
-
});
|
|
645
|
-
|
|
646
|
-
/**
|
|
647
|
-
* 暂停预览
|
|
648
|
-
*/
|
|
649
|
-
const stopPreview = () => {
|
|
650
|
-
var _ipcCtx$current3;
|
|
651
|
-
ipcTTTOperatorLog("VID: begin_to_stop_preview");
|
|
652
|
-
ipcTTTOperatorLog("VID: set_mute_is_true");
|
|
653
|
-
setMuted(true);
|
|
654
|
-
(_ipcCtx$current3 = ipcCtx.current) === null || _ipcCtx$current3 === void 0 || _ipcCtx$current3.stopPreview({
|
|
655
|
-
success: () => {
|
|
656
|
-
ipcTTTOperatorLog("VID: stop_preview_success");
|
|
657
|
-
},
|
|
658
|
-
fail: e => {
|
|
659
|
-
ipcTTTOperatorLog("VID: stop_preview_failure: ".concat(JSON.stringify(e)));
|
|
660
|
-
}
|
|
661
|
-
});
|
|
662
|
-
};
|
|
663
|
-
|
|
664
|
-
/**
|
|
665
|
-
* 设置声音
|
|
666
|
-
*/
|
|
667
|
-
const setMuted = val => {
|
|
668
|
-
var _ipcCtx$current4;
|
|
669
|
-
ipcTTTOperatorLog("VID: begin_to_set_mute");
|
|
670
|
-
(_ipcCtx$current4 = ipcCtx.current) === null || _ipcCtx$current4 === void 0 || _ipcCtx$current4.setMuted({
|
|
671
|
-
mute: val,
|
|
672
|
-
success: () => {
|
|
673
|
-
ipcTTTOperatorLog("VID: set_mute_success: ".concat(val));
|
|
674
|
-
},
|
|
675
|
-
fail: () => {
|
|
676
|
-
ipcTTTOperatorLog("VID: set_mute_failure: ".concat(val));
|
|
677
|
-
}
|
|
678
|
-
});
|
|
679
|
-
};
|
|
680
|
-
|
|
681
522
|
/**
|
|
682
523
|
* 获取当前是否静音
|
|
683
524
|
*/
|
|
@@ -745,29 +586,6 @@ const Player = props => {
|
|
|
745
586
|
}
|
|
746
587
|
});
|
|
747
588
|
|
|
748
|
-
// 断开连接
|
|
749
|
-
const disconnect = () => {
|
|
750
|
-
return new Promise((resolve, reject) => {
|
|
751
|
-
var _ipcCtx$current6;
|
|
752
|
-
// console.log('断开连接前');
|
|
753
|
-
(_ipcCtx$current6 = ipcCtx.current) === null || _ipcCtx$current6 === void 0 || _ipcCtx$current6.disconnect({
|
|
754
|
-
success: res => {
|
|
755
|
-
// console.log('断开连接成功:', devId);
|
|
756
|
-
resolve(res);
|
|
757
|
-
setPlayState(d => {
|
|
758
|
-
d.connectState = false;
|
|
759
|
-
});
|
|
760
|
-
onChangeStreamStatus && onChangeStreamStatus(1009);
|
|
761
|
-
},
|
|
762
|
-
fail: e => {
|
|
763
|
-
// console.error('断开连接失败:', devId);
|
|
764
|
-
reject(e);
|
|
765
|
-
onChangeStreamStatus && onChangeStreamStatus(-1009);
|
|
766
|
-
}
|
|
767
|
-
});
|
|
768
|
-
});
|
|
769
|
-
};
|
|
770
|
-
|
|
771
589
|
/**
|
|
772
590
|
* 播放器容器点击事件
|
|
773
591
|
*/
|
|
@@ -789,7 +607,7 @@ const Player = props => {
|
|
|
789
607
|
*/
|
|
790
608
|
|
|
791
609
|
const handleCameraPreviewFailure = useMemoizedFn(data => {
|
|
792
|
-
console.log(data, '
|
|
610
|
+
console.log(data, 'handleCameraPreviewFailure');
|
|
793
611
|
ipcTTTOperatorLog("cameraPreviewFailure_event_trigger_".concat(JSON.stringify(data)));
|
|
794
612
|
if (data.type === 'cameraPreviewFailure' && !privateState) {
|
|
795
613
|
// 隐私模式时不展示错误
|
|
@@ -811,181 +629,6 @@ const Player = props => {
|
|
|
811
629
|
}
|
|
812
630
|
}
|
|
813
631
|
});
|
|
814
|
-
|
|
815
|
-
/**
|
|
816
|
-
* 获取错误展示内容
|
|
817
|
-
*/
|
|
818
|
-
const getErrorContent = useMemoizedFn(() => {
|
|
819
|
-
if (!phoneNetworkConnect) {
|
|
820
|
-
return Strings.getLang('ipc_player_network_fail');
|
|
821
|
-
}
|
|
822
|
-
if (!onlineStatus) {
|
|
823
|
-
return Strings.getLang('ipc_player_device_offline');
|
|
824
|
-
}
|
|
825
|
-
if (!isLowPowerDevice && onlineStatus && privateState) {
|
|
826
|
-
return Strings.getLang('ipc_player_device_sleep');
|
|
827
|
-
}
|
|
828
|
-
|
|
829
|
-
// 低功耗隐私模式正常唤醒
|
|
830
|
-
if (isLowPowerDevice && lowPowerDeviceOnlineState && privateState && !lowPrivateOutTimeFlag) {
|
|
831
|
-
return Strings.getLang('ipc_player_device_sleep');
|
|
832
|
-
}
|
|
833
|
-
// 低功耗隐私模式正常唤醒,下发指令失败
|
|
834
|
-
if (isLowPowerDevice && lowPowerDeviceOnlineState && privateState && !lowPrivateOutTimeFlag) {
|
|
835
|
-
return Strings.getLang('ipc_player_private_open_low_stream_fail');
|
|
836
|
-
}
|
|
837
|
-
if (!isLowPowerDevice && device4GIsFreeze && onlineStatus && !privateState) {
|
|
838
|
-
return deviceFreezeReasonStore[deviceFreezeReason];
|
|
839
|
-
}
|
|
840
|
-
if (isLowPowerDevice && device4GIsFreeze && lowPowerDeviceOnlineState && !privateState) {
|
|
841
|
-
return deviceFreezeReasonStore[deviceFreezeReason];
|
|
842
|
-
}
|
|
843
|
-
if (onlineStatus && trafficLessOrEqualZero) {
|
|
844
|
-
return Strings.getLang('ipc_player_traffic_load_online_zero_tip');
|
|
845
|
-
}
|
|
846
|
-
|
|
847
|
-
// if (isLowPowerDevice && lowPowerDeviceOnlineState) {
|
|
848
|
-
// return Strings.getLang('ipc_player_traffic_load_online_zero_tip');
|
|
849
|
-
// }
|
|
850
|
-
|
|
851
|
-
if (!onlineStatus) {
|
|
852
|
-
return Strings.getLang('ipc_player_no_line');
|
|
853
|
-
}
|
|
854
|
-
if (videoErrCode !== '') {
|
|
855
|
-
if (Strings["ipc_player_error_".concat(codeCoverToInt(videoErrCode))]) {
|
|
856
|
-
return "".concat(Strings.getLang("ipc_player_error_".concat(codeCoverToInt(videoErrCode))), "(").concat(videoErrCode, ")");
|
|
857
|
-
}
|
|
858
|
-
return "".concat(Strings.getLang("ipc_player_error_common"), "(").concat(videoErrCode, ")");
|
|
859
|
-
}
|
|
860
|
-
return playState.errorMsg;
|
|
861
|
-
});
|
|
862
|
-
|
|
863
|
-
/**
|
|
864
|
-
* 根据自定义类型获取错误码展示内容
|
|
865
|
-
*/
|
|
866
|
-
|
|
867
|
-
const getErrorContentByType = useMemoizedFn((errCode, type) => {
|
|
868
|
-
const errContent = getErrCodeDetailDataByCode(String(errCode));
|
|
869
|
-
const contentEmpty = _isEmpty(errContent);
|
|
870
|
-
switch (type) {
|
|
871
|
-
// 是否展示建议文案
|
|
872
|
-
case 'suggestedFlag':
|
|
873
|
-
if (hideSuggestedText) {
|
|
874
|
-
return false;
|
|
875
|
-
}
|
|
876
|
-
if (contentEmpty) {
|
|
877
|
-
return false;
|
|
878
|
-
}
|
|
879
|
-
return errContent.suggestedText !== '';
|
|
880
|
-
|
|
881
|
-
// 建议文案
|
|
882
|
-
case 'suggestedText':
|
|
883
|
-
if (contentEmpty || privateState) {
|
|
884
|
-
return '';
|
|
885
|
-
}
|
|
886
|
-
return errContent.suggestedText;
|
|
887
|
-
// 是否展示点我重试
|
|
888
|
-
case 'retry':
|
|
889
|
-
if (!phoneNetworkConnect) {
|
|
890
|
-
return false;
|
|
891
|
-
}
|
|
892
|
-
if (!isLowPowerDevice && !onlineStatus) {
|
|
893
|
-
return false;
|
|
894
|
-
}
|
|
895
|
-
if (isLowPowerDevice && !lowPowerDeviceOnlineState) {
|
|
896
|
-
return false;
|
|
897
|
-
}
|
|
898
|
-
if (privateState && !isShare && !device4GIsFreeze) {
|
|
899
|
-
return true;
|
|
900
|
-
}
|
|
901
|
-
if (privateState && isShare) {
|
|
902
|
-
return false;
|
|
903
|
-
}
|
|
904
|
-
|
|
905
|
-
// 设备4G冻结,冻结原因为特殊情况下,展示retry
|
|
906
|
-
if (device4GIsFreeze && onlineStatus && !privateState && deviceFreezeReason === 1) {
|
|
907
|
-
return true;
|
|
908
|
-
}
|
|
909
|
-
if (contentEmpty || privateState) {
|
|
910
|
-
return true;
|
|
911
|
-
}
|
|
912
|
-
return errContent.try;
|
|
913
|
-
// 是否展示点我重试
|
|
914
|
-
case 'retryText':
|
|
915
|
-
if (privateState) {
|
|
916
|
-
return Strings.getLang('ipc_player_re_wake_camera');
|
|
917
|
-
}
|
|
918
|
-
return Strings.getLang('ipc_player_retry');
|
|
919
|
-
case 'help':
|
|
920
|
-
if (hideHelpButton) {
|
|
921
|
-
return false;
|
|
922
|
-
}
|
|
923
|
-
if (!phoneNetworkConnect || privateState) {
|
|
924
|
-
return false;
|
|
925
|
-
}
|
|
926
|
-
if (isLowPowerDevice && lowPowerDeviceOnlineState) {
|
|
927
|
-
return false;
|
|
928
|
-
}
|
|
929
|
-
if (isLowPowerDevice && !lowPowerDeviceOnlineState) {
|
|
930
|
-
return true;
|
|
931
|
-
}
|
|
932
|
-
if (!isLowPowerDevice && !onlineStatus) {
|
|
933
|
-
return true;
|
|
934
|
-
}
|
|
935
|
-
if (privateState && isShare) {
|
|
936
|
-
return false;
|
|
937
|
-
}
|
|
938
|
-
if (contentEmpty) {
|
|
939
|
-
return false;
|
|
940
|
-
}
|
|
941
|
-
return errContent.help;
|
|
942
|
-
case 'helpNum':
|
|
943
|
-
if (privateState && isShare) {
|
|
944
|
-
return false;
|
|
945
|
-
}
|
|
946
|
-
return errContent.helpNum;
|
|
947
|
-
case 'feedBack':
|
|
948
|
-
if (hideFeedBackButton) {
|
|
949
|
-
return false;
|
|
950
|
-
}
|
|
951
|
-
if (!phoneNetworkConnect) {
|
|
952
|
-
return true;
|
|
953
|
-
}
|
|
954
|
-
if (privateState) {
|
|
955
|
-
return false;
|
|
956
|
-
}
|
|
957
|
-
if (contentEmpty) {
|
|
958
|
-
return false;
|
|
959
|
-
}
|
|
960
|
-
return errContent.feedBack;
|
|
961
|
-
default:
|
|
962
|
-
return false;
|
|
963
|
-
}
|
|
964
|
-
});
|
|
965
|
-
|
|
966
|
-
/**
|
|
967
|
-
* 跳转帮助小程序
|
|
968
|
-
*/
|
|
969
|
-
const handleGotoHelpMini = useMemoizedFn(async () => {
|
|
970
|
-
if (isLowPowerDevice && !lowPowerDeviceOnlineState || !onlineStatus) {
|
|
971
|
-
const realLanguage = await getLanguage();
|
|
972
|
-
const url = "godzilla://".concat(miniIdLabs.helpMini, "/pages/commonDetails/index?answer=/app-helpcenter/").concat(realLanguage, "/K94ow0gwu9bg2");
|
|
973
|
-
openTargetMinByShortLink(url);
|
|
974
|
-
return false;
|
|
975
|
-
}
|
|
976
|
-
const helpNum = getErrorContentByType(videoErrCode, 'helpNum');
|
|
977
|
-
const helpFeedBack = getErrorContentByType(videoErrCode, 'helpFeedBack');
|
|
978
|
-
const homeInfo = await getHomeInfo();
|
|
979
|
-
const devInfo = await getDeviceInfo(devId);
|
|
980
|
-
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);
|
|
981
|
-
openTargetMinByShortLink(url);
|
|
982
|
-
return false;
|
|
983
|
-
});
|
|
984
|
-
|
|
985
|
-
/**
|
|
986
|
-
* 跳转反馈小程序
|
|
987
|
-
*/
|
|
988
|
-
|
|
989
632
|
return /*#__PURE__*/React.createElement(View, {
|
|
990
633
|
className: getClassName('ipc-player'),
|
|
991
634
|
onClick: () => {
|
|
@@ -1022,61 +665,47 @@ const Player = props => {
|
|
|
1022
665
|
borderColor: borderColor,
|
|
1023
666
|
borderWidth: borderWidth,
|
|
1024
667
|
backgroundColor: bgColor
|
|
1025
|
-
}, extend)), /*#__PURE__*/React.createElement(
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
className: clsx(getClassName('operator-btn'), getClassName('operator-retry')),
|
|
1059
|
-
style: {
|
|
1060
|
-
backgroundColor: "".concat(brandColor)
|
|
1061
|
-
},
|
|
1062
|
-
onClick: retry
|
|
1063
|
-
}, getErrorContentByType(videoErrCode, 'retryText')), getErrorContentByType(videoErrCode, 'help') && /*#__PURE__*/React.createElement(View, {
|
|
1064
|
-
className: clsx(getClassName('operator-btn'), getClassName('operator-help')),
|
|
1065
|
-
onClick: handleGotoHelpMini
|
|
1066
|
-
}, Strings.getLang('ipc_player_help')), getErrorContentByType(videoErrCode, 'feedBack') && /*#__PURE__*/React.createElement(View, {
|
|
1067
|
-
className: clsx(getClassName('operator-btn'), getClassName('operator-feedback')),
|
|
1068
|
-
onClick: () => {
|
|
1069
|
-
const url = "godzilla://".concat(miniIdLabs.helpMini, "/pages/v2/problemSubmit/index");
|
|
1070
|
-
openTargetMinByShortLink(url);
|
|
1071
|
-
}
|
|
1072
|
-
}, Strings.getLang('ipc_player_feedback')))), screenType === 'landscape' && (playState.loadingState || playState.errorState) && /*#__PURE__*/React.createElement(CoverView, {
|
|
1073
|
-
className: clsx(getClassName('load-full-back-container')),
|
|
1074
|
-
onClick: () => {
|
|
668
|
+
}, extend)), /*#__PURE__*/React.createElement(LoadingOverlay, {
|
|
669
|
+
isLoading: playState.loadingState,
|
|
670
|
+
loadingText: loadText || playState.loadingText,
|
|
671
|
+
borderRadius: borderRadius,
|
|
672
|
+
getClassName: getClassName
|
|
673
|
+
}), /*#__PURE__*/React.createElement(ErrorOverlay, {
|
|
674
|
+
devId: devId,
|
|
675
|
+
isError: playState.errorState,
|
|
676
|
+
videoErrCode: videoErrCode,
|
|
677
|
+
borderRadius: borderRadius,
|
|
678
|
+
brandColor: brandColor,
|
|
679
|
+
getClassName: getClassName,
|
|
680
|
+
renderErrIcon: renderErrIcon,
|
|
681
|
+
onRetry: retry,
|
|
682
|
+
phoneNetworkConnect: phoneNetworkConnect,
|
|
683
|
+
onlineStatus: onlineStatus,
|
|
684
|
+
privateState: privateState,
|
|
685
|
+
isLowPowerDevice: isLowPowerDevice,
|
|
686
|
+
lowPowerDeviceOnlineState: lowPowerDeviceOnlineState,
|
|
687
|
+
lowPrivateOutTimeFlag: lowPrivateOutTimeFlag,
|
|
688
|
+
device4GIsFreeze: device4GIsFreeze,
|
|
689
|
+
deviceFreezeReason: deviceFreezeReason,
|
|
690
|
+
playStateErrorMsg: playState.errorMsg,
|
|
691
|
+
hideSuggestedText: hideSuggestedText,
|
|
692
|
+
hideHelpButton: hideHelpButton,
|
|
693
|
+
hideFeedBackButton: hideFeedBackButton,
|
|
694
|
+
isShare: isShare,
|
|
695
|
+
limitFlow: limitFlow,
|
|
696
|
+
autoPlay: autoPlay
|
|
697
|
+
}), /*#__PURE__*/React.createElement(FullScreenBackButton, {
|
|
698
|
+
isVisible: screenType === 'landscape' && (playState.loadingState || playState.errorState),
|
|
699
|
+
getClassName: getClassName,
|
|
700
|
+
onBackFullScreen: () => {
|
|
1075
701
|
setScreenType('portrait');
|
|
1076
702
|
setPageOrientation({
|
|
1077
703
|
pageOrientation: 'portrait',
|
|
1078
704
|
success: () => {
|
|
1079
|
-
|
|
705
|
+
console.log('Landscape mode exited successfully');
|
|
706
|
+
},
|
|
707
|
+
fail: () => {
|
|
708
|
+
console.log('Failed to exit landscape mode');
|
|
1080
709
|
}
|
|
1081
710
|
});
|
|
1082
711
|
}
|