@ray-js/ray-ipc-player 2.0.24 → 2.0.26-beta-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.js +27 -16
- package/lib/index.module.less +0 -4
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
2
2
|
import "core-js/modules/es.json.stringify.js";
|
|
3
3
|
import "core-js/modules/web.dom-collections.iterator.js";
|
|
4
4
|
/* eslint-disable no-unneeded-ternary */
|
|
5
|
-
import React, { useState, useEffect, useRef
|
|
5
|
+
import React, { useState, useEffect, useRef } from 'react';
|
|
6
6
|
import { useImmer } from 'use-immer';
|
|
7
7
|
import _isEmpty from 'lodash/isEmpty';
|
|
8
8
|
import { IpcPlayer, View, CoverView } from '@ray-js/components';
|
|
@@ -118,13 +118,13 @@ const Player = props => {
|
|
|
118
118
|
const retryCount = useRef(0); // 重试次数
|
|
119
119
|
const muteRef = useRef(defaultMute); // 静音
|
|
120
120
|
|
|
121
|
-
usePageEvent('onShow',
|
|
121
|
+
usePageEvent('onShow', useMemoizedFn(async () => {
|
|
122
122
|
// 视图准备就绪
|
|
123
123
|
if (phoneNetworkConnect && playState.initLy && ipcCtx.current && onlineStatus && !privateState) {
|
|
124
124
|
ipcTTTOperatorLog('VID: onShow_event_to_retry');
|
|
125
125
|
retry();
|
|
126
126
|
}
|
|
127
|
-
}
|
|
127
|
+
}));
|
|
128
128
|
usePageEvent('onShow', () => {
|
|
129
129
|
getNetworkType({
|
|
130
130
|
success: res => {
|
|
@@ -188,7 +188,14 @@ const Player = props => {
|
|
|
188
188
|
}));
|
|
189
189
|
useMount(() => {
|
|
190
190
|
onNetworkStatusChange(res => {
|
|
191
|
+
console.log(res, 'res==========onNetworkStatusChange');
|
|
191
192
|
setPhoneNetworkConnect(res.isConnected);
|
|
193
|
+
if (!res.isConnected) {
|
|
194
|
+
// 断网,需要主动调用断流以及断开P2P
|
|
195
|
+
ipcTTTOperatorLog('VID: network is not connected, need stop preview and disconnect');
|
|
196
|
+
stopPreview();
|
|
197
|
+
disconnect();
|
|
198
|
+
}
|
|
192
199
|
});
|
|
193
200
|
});
|
|
194
201
|
useUnmount(() => {
|
|
@@ -324,6 +331,7 @@ const Player = props => {
|
|
|
324
331
|
d.errorMsg = Strings.getLang('ipc_player_device_offline');
|
|
325
332
|
});
|
|
326
333
|
} else if (playState.initLy && !privateState) {
|
|
334
|
+
console.log('sdhjsahdjshajdh');
|
|
327
335
|
ipcTTTOperatorLog("VID: privateState_status_change: ".concat(privateState));
|
|
328
336
|
retry();
|
|
329
337
|
} else if (playState.initLy && privateState) {
|
|
@@ -336,8 +344,11 @@ const Player = props => {
|
|
|
336
344
|
|
|
337
345
|
// 重试
|
|
338
346
|
const _retry = async () => {
|
|
347
|
+
console.log('调用了重试');
|
|
339
348
|
const connectState = await getIsConnected(ipcCtx.current);
|
|
349
|
+
console.log('调用了重试--connectState');
|
|
340
350
|
const isOnPreview = await getIsOnPreview(ipcCtx.current);
|
|
351
|
+
console.log('调用了重试--isOnPreview');
|
|
341
352
|
setPlayState(d => {
|
|
342
353
|
d.connectState = connectState ? true : false;
|
|
343
354
|
d.errorMsg = '';
|
|
@@ -449,8 +460,7 @@ const Player = props => {
|
|
|
449
460
|
}, 15000);
|
|
450
461
|
}
|
|
451
462
|
});
|
|
452
|
-
const retry =
|
|
453
|
-
// console.log('retry:', muteRef.current);
|
|
463
|
+
const retry = useMemoizedFn(() => {
|
|
454
464
|
console.log('重新拉流启动');
|
|
455
465
|
// 任何重试拉流时, 将播放器状态还原为loading状态
|
|
456
466
|
setVideoErrCode('');
|
|
@@ -464,7 +474,8 @@ const Player = props => {
|
|
|
464
474
|
// 低功耗设备隐私模式需单独处理,先进行下发唤醒, 唤醒后再进行下发DP
|
|
465
475
|
phoneNetworkConnect && onlineStatus && privateState && isLowPowerDevice && !isVirtualDevice && handleReWakeCameraLowPowerDevice();
|
|
466
476
|
phoneNetworkConnect && onlineStatus && !privateState && _retry();
|
|
467
|
-
|
|
477
|
+
// }, [isLowPowerDevice, phoneNetworkConnect && playState.connectState, privateState, onlineStatus]);
|
|
478
|
+
});
|
|
468
479
|
|
|
469
480
|
// 创建ipc实例
|
|
470
481
|
const createIpcCtx = () => {
|
|
@@ -619,7 +630,7 @@ const Player = props => {
|
|
|
619
630
|
*/
|
|
620
631
|
|
|
621
632
|
// 异常事件
|
|
622
|
-
const onError =
|
|
633
|
+
const onError = useMemoizedFn(e => {
|
|
623
634
|
ipcTTTOperatorLog("VID: player_event_on_error: ".concat(JSON.stringify(e)));
|
|
624
635
|
if (playState.errorState) {
|
|
625
636
|
return;
|
|
@@ -638,7 +649,7 @@ const Player = props => {
|
|
|
638
649
|
d.connectState = false;
|
|
639
650
|
});
|
|
640
651
|
}
|
|
641
|
-
}
|
|
652
|
+
});
|
|
642
653
|
|
|
643
654
|
// 连接状态发生变化
|
|
644
655
|
const connectChange = useMemoizedFn(e => {
|
|
@@ -711,14 +722,14 @@ const Player = props => {
|
|
|
711
722
|
/**
|
|
712
723
|
* 播放器画面点击事件
|
|
713
724
|
*/
|
|
714
|
-
const handleVideoTap =
|
|
725
|
+
const handleVideoTap = useMemoizedFn(() => {
|
|
715
726
|
if (!playState.loadingState && !playState.errorState && onlineStatus && !privateState) {
|
|
716
727
|
ipcTTTOperatorLog('VID: onVideoTap_event_send');
|
|
717
728
|
onPlayerTap && onPlayerTap(devId);
|
|
718
729
|
} else {
|
|
719
730
|
ipcTTTOperatorLog('VID: onVideoTap_event_trigger_not_send');
|
|
720
731
|
}
|
|
721
|
-
}
|
|
732
|
+
});
|
|
722
733
|
|
|
723
734
|
/**
|
|
724
735
|
* 退出横屏
|
|
@@ -751,7 +762,7 @@ const Player = props => {
|
|
|
751
762
|
/**
|
|
752
763
|
* 获取错误展示内容
|
|
753
764
|
*/
|
|
754
|
-
const getErrorContent =
|
|
765
|
+
const getErrorContent = useMemoizedFn(() => {
|
|
755
766
|
if (!phoneNetworkConnect) {
|
|
756
767
|
return Strings.getLang('ipc_player_network_fail');
|
|
757
768
|
}
|
|
@@ -795,12 +806,12 @@ const Player = props => {
|
|
|
795
806
|
return "".concat(Strings.getLang("ipc_player_error_common"), "(").concat(videoErrCode, ")");
|
|
796
807
|
}
|
|
797
808
|
return playState.errorMsg;
|
|
798
|
-
}
|
|
809
|
+
});
|
|
799
810
|
|
|
800
811
|
/**
|
|
801
812
|
* 根据自定义类型获取错误码展示内容
|
|
802
813
|
*/
|
|
803
|
-
const getErrorContentByType =
|
|
814
|
+
const getErrorContentByType = useMemoizedFn((errCode, type) => {
|
|
804
815
|
const errContent = getErrCodeDetailDataByCode(String(errCode));
|
|
805
816
|
const contentEmpty = _isEmpty(errContent);
|
|
806
817
|
switch (type) {
|
|
@@ -887,12 +898,12 @@ const Player = props => {
|
|
|
887
898
|
default:
|
|
888
899
|
return false;
|
|
889
900
|
}
|
|
890
|
-
}
|
|
901
|
+
});
|
|
891
902
|
|
|
892
903
|
/**
|
|
893
904
|
* 跳转帮助小程序
|
|
894
905
|
*/
|
|
895
|
-
const handleGotoHelpMini =
|
|
906
|
+
const handleGotoHelpMini = useMemoizedFn(async () => {
|
|
896
907
|
if (isLowPowerDevice && !lowPowerDeviceOnlineState || !onlineStatus) {
|
|
897
908
|
const realLanguage = await getLanguage();
|
|
898
909
|
const url = "godzilla://".concat(miniIdLabs.helpMini, "/pages/commonDetails/index?answer=/app-helpcenter/").concat(realLanguage, "/K94ow0gwu9bg2");
|
|
@@ -906,7 +917,7 @@ const Player = props => {
|
|
|
906
917
|
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);
|
|
907
918
|
openTargetMinByShortLink(url);
|
|
908
919
|
return false;
|
|
909
|
-
}
|
|
920
|
+
});
|
|
910
921
|
|
|
911
922
|
/**
|
|
912
923
|
* 跳转反馈小程序
|
package/lib/index.module.less
CHANGED
|
@@ -154,7 +154,6 @@
|
|
|
154
154
|
text-align: center;
|
|
155
155
|
font-size: 12px;
|
|
156
156
|
padding: 0 16px;
|
|
157
|
-
word-break: break-all;
|
|
158
157
|
|
|
159
158
|
.errIconContainer {
|
|
160
159
|
.errIcon {
|
|
@@ -179,14 +178,12 @@
|
|
|
179
178
|
color: #ffffff;
|
|
180
179
|
font-size: 12px;
|
|
181
180
|
font-weight: 400;
|
|
182
|
-
word-break: break-word;
|
|
183
181
|
}
|
|
184
182
|
.errDesc {
|
|
185
183
|
margin-top: 5px;
|
|
186
184
|
color: rgba(255, 255, 255, 0.7);
|
|
187
185
|
font-size: 12px;
|
|
188
186
|
font-weight: 400;
|
|
189
|
-
word-break: break-word;
|
|
190
187
|
}
|
|
191
188
|
}
|
|
192
189
|
|
|
@@ -211,7 +208,6 @@
|
|
|
211
208
|
margin: 0 4px;
|
|
212
209
|
text-overflow: ellipsis;
|
|
213
210
|
padding: 8px 16px;
|
|
214
|
-
word-break: break-word;
|
|
215
211
|
}
|
|
216
212
|
.operatorBtn:hover {
|
|
217
213
|
opacity: 0.9;
|