@ray-js/ray-ipc-player 2.0.25 → 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.
Files changed (2) hide show
  1. package/lib/index.js +21 -16
  2. 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, useCallback } from 'react';
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', useCallback(async () => {
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
- }, [phoneNetworkConnect, onlineStatus && playState.connectState, privateState, playState.initLy]));
127
+ }));
128
128
  usePageEvent('onShow', () => {
129
129
  getNetworkType({
130
130
  success: res => {
@@ -188,6 +188,7 @@ const Player = props => {
188
188
  }));
189
189
  useMount(() => {
190
190
  onNetworkStatusChange(res => {
191
+ console.log(res, 'res==========onNetworkStatusChange');
191
192
  setPhoneNetworkConnect(res.isConnected);
192
193
  if (!res.isConnected) {
193
194
  // 断网,需要主动调用断流以及断开P2P
@@ -330,6 +331,7 @@ const Player = props => {
330
331
  d.errorMsg = Strings.getLang('ipc_player_device_offline');
331
332
  });
332
333
  } else if (playState.initLy && !privateState) {
334
+ console.log('sdhjsahdjshajdh');
333
335
  ipcTTTOperatorLog("VID: privateState_status_change: ".concat(privateState));
334
336
  retry();
335
337
  } else if (playState.initLy && privateState) {
@@ -342,8 +344,11 @@ const Player = props => {
342
344
 
343
345
  // 重试
344
346
  const _retry = async () => {
347
+ console.log('调用了重试');
345
348
  const connectState = await getIsConnected(ipcCtx.current);
349
+ console.log('调用了重试--connectState');
346
350
  const isOnPreview = await getIsOnPreview(ipcCtx.current);
351
+ console.log('调用了重试--isOnPreview');
347
352
  setPlayState(d => {
348
353
  d.connectState = connectState ? true : false;
349
354
  d.errorMsg = '';
@@ -455,8 +460,7 @@ const Player = props => {
455
460
  }, 15000);
456
461
  }
457
462
  });
458
- const retry = useCallback(() => {
459
- // console.log('retry:', muteRef.current);
463
+ const retry = useMemoizedFn(() => {
460
464
  console.log('重新拉流启动');
461
465
  // 任何重试拉流时, 将播放器状态还原为loading状态
462
466
  setVideoErrCode('');
@@ -470,7 +474,8 @@ const Player = props => {
470
474
  // 低功耗设备隐私模式需单独处理,先进行下发唤醒, 唤醒后再进行下发DP
471
475
  phoneNetworkConnect && onlineStatus && privateState && isLowPowerDevice && !isVirtualDevice && handleReWakeCameraLowPowerDevice();
472
476
  phoneNetworkConnect && onlineStatus && !privateState && _retry();
473
- }, [isLowPowerDevice, phoneNetworkConnect && playState.connectState, privateState, onlineStatus]);
477
+ // }, [isLowPowerDevice, phoneNetworkConnect && playState.connectState, privateState, onlineStatus]);
478
+ });
474
479
 
475
480
  // 创建ipc实例
476
481
  const createIpcCtx = () => {
@@ -625,7 +630,7 @@ const Player = props => {
625
630
  */
626
631
 
627
632
  // 异常事件
628
- const onError = useCallback(e => {
633
+ const onError = useMemoizedFn(e => {
629
634
  ipcTTTOperatorLog("VID: player_event_on_error: ".concat(JSON.stringify(e)));
630
635
  if (playState.errorState) {
631
636
  return;
@@ -644,7 +649,7 @@ const Player = props => {
644
649
  d.connectState = false;
645
650
  });
646
651
  }
647
- }, [playState.errorState]);
652
+ });
648
653
 
649
654
  // 连接状态发生变化
650
655
  const connectChange = useMemoizedFn(e => {
@@ -717,14 +722,14 @@ const Player = props => {
717
722
  /**
718
723
  * 播放器画面点击事件
719
724
  */
720
- const handleVideoTap = useCallback(() => {
725
+ const handleVideoTap = useMemoizedFn(() => {
721
726
  if (!playState.loadingState && !playState.errorState && onlineStatus && !privateState) {
722
727
  ipcTTTOperatorLog('VID: onVideoTap_event_send');
723
728
  onPlayerTap && onPlayerTap(devId);
724
729
  } else {
725
730
  ipcTTTOperatorLog('VID: onVideoTap_event_trigger_not_send');
726
731
  }
727
- }, [onPlayerTap, playState.loadingState, playState.errorState, onlineStatus, privateState]);
732
+ });
728
733
 
729
734
  /**
730
735
  * 退出横屏
@@ -757,7 +762,7 @@ const Player = props => {
757
762
  /**
758
763
  * 获取错误展示内容
759
764
  */
760
- const getErrorContent = useCallback(() => {
765
+ const getErrorContent = useMemoizedFn(() => {
761
766
  if (!phoneNetworkConnect) {
762
767
  return Strings.getLang('ipc_player_network_fail');
763
768
  }
@@ -801,12 +806,12 @@ const Player = props => {
801
806
  return "".concat(Strings.getLang("ipc_player_error_common"), "(").concat(videoErrCode, ")");
802
807
  }
803
808
  return playState.errorMsg;
804
- }, [phoneNetworkConnect, playState, videoErrCode, privateState, onlineStatus, isLowPowerDevice, lowPowerDeviceOnlineState, device4GIsFreeze, deviceFreezeReason, lowPrivateOutTimeFlag]);
809
+ });
805
810
 
806
811
  /**
807
812
  * 根据自定义类型获取错误码展示内容
808
813
  */
809
- const getErrorContentByType = useCallback((errCode, type) => {
814
+ const getErrorContentByType = useMemoizedFn((errCode, type) => {
810
815
  const errContent = getErrCodeDetailDataByCode(String(errCode));
811
816
  const contentEmpty = _isEmpty(errContent);
812
817
  switch (type) {
@@ -893,12 +898,12 @@ const Player = props => {
893
898
  default:
894
899
  return false;
895
900
  }
896
- }, [phoneNetworkConnect, privateState, onlineStatus, isLowPowerDevice, lowPowerDeviceOnlineState, device4GIsFreeze, deviceFreezeReason]);
901
+ });
897
902
 
898
903
  /**
899
904
  * 跳转帮助小程序
900
905
  */
901
- const handleGotoHelpMini = useCallback(async () => {
906
+ const handleGotoHelpMini = useMemoizedFn(async () => {
902
907
  if (isLowPowerDevice && !lowPowerDeviceOnlineState || !onlineStatus) {
903
908
  const realLanguage = await getLanguage();
904
909
  const url = "godzilla://".concat(miniIdLabs.helpMini, "/pages/commonDetails/index?answer=/app-helpcenter/").concat(realLanguage, "/K94ow0gwu9bg2");
@@ -912,7 +917,7 @@ const Player = props => {
912
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);
913
918
  openTargetMinByShortLink(url);
914
919
  return false;
915
- }, [onlineStatus, isLowPowerDevice, lowPowerDeviceOnlineState]);
920
+ });
916
921
 
917
922
  /**
918
923
  * 跳转反馈小程序
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/ray-ipc-player",
3
- "version": "2.0.25",
3
+ "version": "2.0.26-beta-1",
4
4
  "description": "ray小程序播放器",
5
5
  "keywords": [
6
6
  "tuya-miniapp",