@ray-js/ray-ipc-player 2.0.20-beta-2 → 2.0.20-beta-4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.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 { setPageOrientation, usePageEvent } from '@ray-js/ray';
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 { putDpData, getIsConnected, getIsOnPreview } from './utils';
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,24 +96,41 @@ const Player = props => {
75
96
 
76
97
  usePageEvent('onShow', useCallback(async () => {
77
98
  // 视图准备就绪
78
- if (playState.initLy && ipcCtx.current) {
79
- console.log('retry连接');
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;
92
130
  });
93
131
  // 先停流
94
132
  stopPreview();
95
- await getCurMute();
133
+ // await getCurMute();
96
134
  });
97
135
  useEffect(() => {
98
136
  onlineStatus && createIpcCtx();
@@ -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
- if (!onlineStatus) {
121
- console.log('监听到设备离线');
122
- setPlayState(d => {
123
- d.errorState = true;
124
- d.errorMsg = Strings.getLang('ipc_player_no_line');
125
- });
126
- } else if (playState.initLy && !privateState) {
127
- retry();
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,20 +181,45 @@ 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 && !privateState && _retry();
149
- }, [playState.connectState, privateState, onlineStatus]);
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 = () => {
153
222
  console.log('创建ipc实例');
154
- console.log(onCtx, 'onCtx');
155
223
  onCtx && onCtx({
156
224
  ctx: ipcCtx.current,
157
225
  retry
@@ -164,17 +232,18 @@ const Player = props => {
164
232
  // console.log('建立连接前:', devId, Date.now());
165
233
  (_ipcCtx$current = ipcCtx.current) === null || _ipcCtx$current === void 0 || _ipcCtx$current.connect({
166
234
  success: () => {
167
- // console.log('建立连接成功:', devId, Date.now());
235
+ ipcTTTOperatorLog("VID: create_p2p_connect_success");
168
236
  setPlayState(d => {
169
237
  d.connectState = true;
170
238
  d.errorState = false;
171
239
  d.errorMsg = '';
172
240
  });
173
241
  onChangeStreamStatus && onChangeStreamStatus(1001);
242
+ ipcTTTOperatorLog("VID: start_to_preview");
174
243
  startPreview(params);
175
244
  },
176
245
  fail: () => {
177
- // console.error('建立连接失败---------:', e, devId, Date.now());
246
+ ipcTTTOperatorLog("VID: create_p2p_connect_failure");
178
247
  setPlayState(d => {
179
248
  d.connectState = false;
180
249
  d.errorState = true;
@@ -188,23 +257,29 @@ const Player = props => {
188
257
 
189
258
  // 视图层准备就绪,开始建立连接
190
259
 
191
- // 开启预览
260
+ /*
261
+ * 开启预览
262
+ */
192
263
  const startPreview = params => {
193
264
  var _ipcCtx$current2;
194
265
  // console.log('开启预览前');
195
266
  (_ipcCtx$current2 = ipcCtx.current) === null || _ipcCtx$current2 === void 0 || _ipcCtx$current2.startPreview({
196
267
  success: () => {
268
+ ipcTTTOperatorLog('VID: start_preview_success');
197
269
  // console.log('开启预览:', devId);
198
270
  setPlayState(d => {
199
271
  d.loadingState = false;
200
272
  d.errorState = false;
201
273
  d.errorMsg = '';
202
274
  });
275
+ setMuted(muteRef.current);
203
276
  params && onInitPreview && onInitPreview(devId);
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
  // 忽略重复预览异常的报错
@@ -213,6 +288,7 @@ const Player = props => {
213
288
  d.errorState = false;
214
289
  d.errorMsg = '';
215
290
  });
291
+ setMuted(muteRef.current);
216
292
  onChangeStreamStatus && onChangeStreamStatus(1002);
217
293
  return;
218
294
  }
@@ -222,71 +298,66 @@ const Player = props => {
222
298
  d.errorMsg = Strings.getLang('ipc_player_preview_fail');
223
299
  });
224
300
  onChangeStreamStatus && onChangeStreamStatus(-1002);
225
- },
226
- complete: () => {
227
- // console.log('startPreview:', muteRef.current);
228
- setMuted(muteRef.current);
229
301
  }
230
302
  });
231
303
  };
232
304
 
233
- // 暂停预览
305
+ /**
306
+ * 暂停预览
307
+ */
234
308
  const stopPreview = () => {
235
309
  var _ipcCtx$current3;
310
+ ipcTTTOperatorLog("VID: begin_to_stop_preview");
311
+ ipcTTTOperatorLog("VID: set_mute_is_true");
312
+ setMuted(true);
236
313
  (_ipcCtx$current3 = ipcCtx.current) === null || _ipcCtx$current3 === void 0 || _ipcCtx$current3.stopPreview({
237
- success: () => null,
238
- fail: () => null,
239
- complete: () => setMuted(true)
314
+ success: () => {
315
+ ipcTTTOperatorLog("VID: stop_preview_success");
316
+ },
317
+ fail: e => {
318
+ ipcTTTOperatorLog("VID: stop_preview_failure: ".concat(JSON.stringify(e)));
319
+ }
240
320
  });
241
321
  };
242
322
 
243
- // 设置静音
323
+ /**
324
+ * 设置声音
325
+ */
244
326
  const setMuted = val => {
245
327
  var _ipcCtx$current4;
328
+ ipcTTTOperatorLog("VID: begin_to_set_mute");
246
329
  (_ipcCtx$current4 = ipcCtx.current) === null || _ipcCtx$current4 === void 0 || _ipcCtx$current4.setMuted({
247
330
  mute: val,
248
331
  success: () => {
249
- // console.log('设置声音成功', val);
332
+ ipcTTTOperatorLog("VID: set_mute_success: ".concat(val));
250
333
  },
251
334
  fail: () => {
252
- // console.log('设置声音失败');
335
+ ipcTTTOperatorLog("VID: set_mute_failure: ".concat(val));
253
336
  }
254
337
  });
255
338
  };
256
339
 
257
- // 获取当前是否静音
258
- const getCurMute = () => {
259
- return new Promise((resolve, reject) => {
260
- var _ipcCtx$current5;
261
- (_ipcCtx$current5 = ipcCtx.current) === null || _ipcCtx$current5 === void 0 || _ipcCtx$current5.isMuted({
262
- success: res => {
263
- muteRef.current = res;
264
- },
265
- fail: e => {
266
- reject(e);
267
- // console.log(e);
268
- },
269
- complete: d => {
270
- resolve(d);
271
- }
272
- });
273
- });
274
- };
340
+ /**
341
+ * 获取当前是否静音
342
+ */
275
343
 
276
344
  // 异常事件
277
345
  const onError = useCallback(e => {
278
- var _e$detail;
346
+ ipcTTTOperatorLog("VID: player_event_on_error: ".concat(JSON.stringify(e)));
279
347
  if (playState.errorState) {
280
348
  return;
281
349
  }
282
- // console.error('发生错误:', e);
283
- const type = e === null || e === void 0 || (_e$detail = e.detail) === null || _e$detail === void 0 ? void 0 : _e$detail.errCode;
284
- if (IpcFailCode[type]) {
285
- onChangeStreamStatus && onChangeStreamStatus(type);
350
+ console.error('发生异常事件:', e);
351
+ const {
352
+ errCode
353
+ } = e === null || e === void 0 ? void 0 : e.detail;
354
+ setVideoErrCode(errCode);
355
+ if (IpcFailCode[errCode]) {
356
+ onChangeStreamStatus && onChangeStreamStatus(errCode);
286
357
  setPlayState(d => {
287
358
  d.loadingState = false;
288
359
  d.errorState = true;
289
- d.errorMsg = Strings.getLang(IpcFailCode[type]);
360
+ d.errorMsg = Strings.getLang(IpcFailCode[errCode]);
290
361
  d.connectState = false;
291
362
  });
292
363
  }
@@ -316,26 +387,210 @@ const Player = props => {
316
387
  });
317
388
  });
318
389
  };
319
- const handlePlayerClick = () => {
320
- // console.log("videoTap:", devId);
321
- onPlayerTap && onPlayerTap(devId);
322
- };
323
390
 
324
- // 关闭隐私模式,重新拉流
391
+ /**
392
+ * 播放器容器点击事件
393
+ */
394
+
395
+ /**
396
+ * 播放器画面点击事件
397
+ */
398
+ const handleVideoTap = useCallback(() => {
399
+ if (!playState.loadingState && !playState.errorState && onlineStatus && !privateState) {
400
+ ipcTTTOperatorLog('VID: onVideoTap_event_send');
401
+ onPlayerTap && onPlayerTap(devId);
402
+ } else {
403
+ ipcTTTOperatorLog('VID: onVideoTap_event_trigger_not_send');
404
+ }
405
+ }, [playState.loadingState, playState.errorState, onlineStatus, privateState]);
406
+
407
+ /**
408
+ * 退出横屏
409
+ */
410
+
411
+ /**
412
+ * 获取错误展示内容
413
+ */
414
+ const getErrorContent = useCallback(() => {
415
+ if (!phoneNetworkConnect) {
416
+ return Strings.getLang('ipc_player_network_fail');
417
+ }
418
+ if (!onlineStatus) {
419
+ return Strings.getLang('ipc_player_device_offline');
420
+ }
421
+ if (!isLowPowerDevice && onlineStatus && privateState) {
422
+ return Strings.getLang('ipc_player_device_sleep');
423
+ }
424
+ if (isLowPowerDevice && lowPowerDeviceOnlineState && privateState) {
425
+ return Strings.getLang('ipc_player_device_sleep');
426
+ }
427
+ if (!isLowPowerDevice && device4GIsFreeze && onlineStatus && !privateState) {
428
+ return deviceFreezeReasonStore[deviceFreezeReason];
429
+ }
430
+ if (isLowPowerDevice && device4GIsFreeze && lowPowerDeviceOnlineState && !privateState) {
431
+ return deviceFreezeReasonStore[deviceFreezeReason];
432
+ }
433
+ if (onlineStatus && trafficLessOrEqualZero) {
434
+ return Strings.getLang('ipc_player_traffic_load_online_zero_tip');
435
+ }
436
+
437
+ // if (isLowPowerDevice && lowPowerDeviceOnlineState) {
438
+ // return Strings.getLang('ipc_player_traffic_load_online_zero_tip');
439
+ // }
440
+
441
+ if (!onlineStatus) {
442
+ return Strings.getLang('ipc_player_no_line');
443
+ }
444
+ if (videoErrCode !== '') {
445
+ if (Strings["ipc_player_error_".concat(codeCoverToInt(videoErrCode))]) {
446
+ return "".concat(Strings.getLang("ipc_player_error_".concat(codeCoverToInt(videoErrCode))), "(").concat(videoErrCode, ")");
447
+ }
448
+ return "".concat(Strings.getLang("ipc_player_error_common"), "(").concat(videoErrCode, ")");
449
+ }
450
+ return playState.errorMsg;
451
+ }, [phoneNetworkConnect, playState, videoErrCode, privateState, onlineStatus, isLowPowerDevice, lowPowerDeviceOnlineState, device4GIsFreeze, deviceFreezeReason]);
452
+
453
+ /**
454
+ * 根据自定义类型获取错误码展示内容
455
+ */
456
+ const getErrorContentByType = useCallback((errCode, type) => {
457
+ const errContent = getErrCodeDetailDataByCode(String(errCode));
458
+ const contentEmpty = _isEmpty(errContent);
459
+ switch (type) {
460
+ // 是否展示建议文案
461
+ case 'suggestedFlag':
462
+ if (contentEmpty) {
463
+ return false;
464
+ }
465
+ return errContent.suggestedText !== '';
466
+ // 建议文案
467
+ case 'suggestedText':
468
+ if (contentEmpty) {
469
+ return '';
470
+ }
471
+ return errContent.suggestedText;
472
+ // 是否展示点我重试
473
+ case 'retry':
474
+ if (!phoneNetworkConnect) {
475
+ return false;
476
+ }
477
+ if (!isLowPowerDevice && !onlineStatus) {
478
+ return false;
479
+ }
480
+ if (isLowPowerDevice && !lowPowerDeviceOnlineState) {
481
+ return false;
482
+ }
483
+ if (privateState && !isShare && !device4GIsFreeze) {
484
+ return true;
485
+ }
486
+ if (privateState && isShare) {
487
+ return false;
488
+ }
489
+
490
+ // 设备4G冻结,冻结原因为特殊情况下,展示retry
491
+ if (device4GIsFreeze && onlineStatus && !privateState && deviceFreezeReason === 1) {
492
+ return true;
493
+ }
494
+ if (contentEmpty || privateState) {
495
+ return true;
496
+ }
497
+ return errContent.try;
498
+ // 是否展示点我重试
499
+ case 'retryText':
500
+ if (privateState) {
501
+ return Strings.getLang('ipc_player_re_wake_camera');
502
+ }
503
+ return Strings.getLang('ipc_player_retry');
504
+ case 'help':
505
+ if (!phoneNetworkConnect || privateState) {
506
+ return false;
507
+ }
508
+ if (isLowPowerDevice && lowPowerDeviceOnlineState) {
509
+ return false;
510
+ }
511
+ if (isLowPowerDevice && !lowPowerDeviceOnlineState) {
512
+ return true;
513
+ }
514
+ if (!isLowPowerDevice && !onlineStatus) {
515
+ return true;
516
+ }
517
+ if (privateState && isShare) {
518
+ return false;
519
+ }
520
+ if (contentEmpty) {
521
+ return false;
522
+ }
523
+ return errContent.help;
524
+ case 'helpNum':
525
+ if (privateState && isShare) {
526
+ return false;
527
+ }
528
+ return errContent.helpNum;
529
+ case 'feedBack':
530
+ if (!phoneNetworkConnect) {
531
+ return true;
532
+ }
533
+ if (privateState && isShare) {
534
+ return false;
535
+ }
536
+ if (contentEmpty) {
537
+ return false;
538
+ }
539
+ return errContent.feedBack;
540
+ default:
541
+ return false;
542
+ }
543
+ }, [phoneNetworkConnect, privateState, onlineStatus, isLowPowerDevice, lowPowerDeviceOnlineState, device4GIsFreeze, deviceFreezeReason]);
544
+
545
+ /**
546
+ * 跳转帮助小程序
547
+ */
548
+ const handleGotoHelpMini = useCallback(async () => {
549
+ if (isLowPowerDevice && !lowPowerDeviceOnlineState || !onlineStatus) {
550
+ const realLanguage = await getLanguage();
551
+ const url = "godzilla://".concat(miniIdLabs.helpMini, "/pages/commonDetails/index?answer=/app-helpcenter/").concat(realLanguage, "/K94ow0gwu9bg2");
552
+ openTargetMinByShortLink(url);
553
+ return false;
554
+ }
555
+ const helpNum = getErrorContentByType(videoErrCode, 'helpNum');
556
+ const helpFeedBack = getErrorContentByType(videoErrCode, 'helpFeedBack');
557
+ const homeInfo = await getHomeInfo();
558
+ const devInfo = await getDeviceInfo(devId);
559
+ 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);
560
+ openTargetMinByShortLink(url);
561
+ return false;
562
+ }, [onlineStatus, isLowPowerDevice, lowPowerDeviceOnlineState]);
325
563
 
326
- // 退出横屏
564
+ /**
565
+ * 跳转反馈小程序
566
+ */
327
567
 
328
568
  return /*#__PURE__*/React.createElement(View, {
329
569
  className: Styles.ipc_player,
330
- onClick: handlePlayerClick
570
+ onClick: () => {
571
+ onPlayerContainerTap && onPlayerContainerTap(devId);
572
+ }
331
573
  }, /*#__PURE__*/React.createElement(IpcPlayer, _extends({
332
574
  className: "".concat(Styles.player, " ").concat(playState.updateLy),
333
- onVideoTap: handlePlayerClick,
575
+ onVideoTap: handleVideoTap,
334
576
  onZoomChange: onZoomChange,
335
- onCameraPreviewFailure: onCameraPreviewFailure,
577
+ onCameraPreviewFailure: data => {
578
+ ipcTTTOperatorLog("cameraPreviewFailure_event_trigger_".concat(JSON.stringify(data)));
579
+ if (data.type === 'cameraPreviewFailure') {
580
+ const {
581
+ deviceId,
582
+ errCode
583
+ } = data === null || data === void 0 ? void 0 : data.detail;
584
+ if (deviceId === devId) {
585
+ setVideoErrCode(errCode);
586
+ props.onCameraPreviewFailure && props.onCameraPreviewFailure(errCode);
587
+ }
588
+ }
589
+ },
336
590
  onCameraNotifyWeakNetwork: onCameraNotifyWeakNetwork,
337
591
  onInitDone: () => {
338
592
  console.log('视图层准备就绪~');
593
+ ipcTTTOperatorLog('VID: player_initDone_event_finish');
339
594
  setPlayState(d => {
340
595
  d.updateLy = Math.random();
341
596
  d.initLy = true;
@@ -343,9 +598,10 @@ const Player = props => {
343
598
  },
344
599
  onError: onError,
345
600
  onConnectChange: e => {
346
- var _e$detail2;
601
+ var _e$detail;
602
+ ipcTTTOperatorLog("VID: player_event_connect_change: ".concat(JSON.stringify(e)));
347
603
  console.log('连接状态发生变化', e);
348
- const code = e === null || e === void 0 || (_e$detail2 = e.detail) === null || _e$detail2 === void 0 ? void 0 : _e$detail2.state;
604
+ const code = e === null || e === void 0 || (_e$detail = e.detail) === null || _e$detail === void 0 ? void 0 : _e$detail.state;
349
605
  onChangeStreamStatus && onChangeStreamStatus(code === 0 ? 1001 : -1001);
350
606
  if (code === 0) {
351
607
  setPlayState(d => {
@@ -395,35 +651,35 @@ const Player = props => {
395
651
  style: {
396
652
  borderRadius: "".concat(borderRadius)
397
653
  },
398
- className: clsx(Styles.bg_center, Styles.state_label, !playState.errorState && Styles.hide),
654
+ className: clsx(Styles.bg_center, Styles.errorContainer, !playState.errorState && Styles.hide),
399
655
  onClick: () => {
400
656
  return false;
401
657
  }
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
658
  }, /*#__PURE__*/React.createElement(View, {
416
- className: clsx(Styles.iconfont, Styles.icon_tishi, !playState.deviceOnlineState && Styles.hide)
417
- }), /*#__PURE__*/React.createElement(View, {
418
- className: Styles.err_msg
659
+ className: clsx(Styles.errIconContainer)
660
+ }, renderErrIcon ? renderErrIcon() : /*#__PURE__*/React.createElement(View, {
661
+ className: clsx(Styles.errIcon)
662
+ })), /*#__PURE__*/React.createElement(View, {
663
+ className: clsx(Styles.errTextContainer)
419
664
  }, /*#__PURE__*/React.createElement(View, {
420
- className: clsx(Styles.msg, Styles.ellipsis)
421
- }, playState.deviceOnlineState ? playState.errorMsg : Strings.getLang('ipc_player_no_line')), /*#__PURE__*/React.createElement(View
422
- // @ts-ignore
423
- , {
424
- onClick: retry,
425
- className: clsx(Styles.retry, !playState.deviceOnlineState && Styles.hide)
426
- }, Strings.getLang('ipc_player_retry'))))), screenType === 'landscape' && (playState.loadingState || playState.errorState) && /*#__PURE__*/React.createElement(CoverView, {
665
+ className: clsx(Styles.errContent)
666
+ }, getErrorContent()), getErrorContentByType(videoErrCode, 'suggestedFlag') && /*#__PURE__*/React.createElement(View, {
667
+ className: clsx(Styles.errDesc)
668
+ }, getErrorContentByType(videoErrCode, 'suggestedText'))), /*#__PURE__*/React.createElement(View, {
669
+ className: clsx(Styles.errOperatorContainer)
670
+ }, getErrorContentByType(videoErrCode, 'retry') && /*#__PURE__*/React.createElement(View, {
671
+ className: clsx(Styles.operatorBtn, Styles.operatorRetry),
672
+ onClick: retry
673
+ }, getErrorContentByType(videoErrCode, 'retryText')), getErrorContentByType(videoErrCode, 'help') && /*#__PURE__*/React.createElement(View, {
674
+ className: clsx(Styles.operatorBtn, Styles.operatorHelp),
675
+ onClick: handleGotoHelpMini
676
+ }, Strings.getLang('ipc_player_help')), getErrorContentByType(videoErrCode, 'feedBack') && /*#__PURE__*/React.createElement(View, {
677
+ className: clsx(Styles.operatorBtn, Styles.operatorFeedBack),
678
+ onClick: () => {
679
+ const url = "godzilla://".concat(miniIdLabs.helpMini, "/pages/v2/problemSubmit/index");
680
+ openTargetMinByShortLink(url);
681
+ }
682
+ }, Strings.getLang('ipc_player_feedback')))), screenType === 'landscape' && (playState.loadingState || playState.errorState) && /*#__PURE__*/React.createElement(CoverView, {
427
683
  className: clsx(Styles.load_full_back_container),
428
684
  onClick: () => {
429
685
  setPageOrientation({