@ray-js/ray-ipc-player 2.1.0-beta.1 → 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.
@@ -137,6 +137,7 @@ export const usePlayerConnection = _ref => {
137
137
  d.errorState = false;
138
138
  d.loadingState = true;
139
139
  });
140
+ handleReWakeCamera();
140
141
  // 如果值为false, 表示设备为睡眠状态,需要唤醒设备
141
142
  setMqttPrivateFlag(true);
142
143
  setEnableWakeUpInterval(true);
package/lib/index.js CHANGED
@@ -101,6 +101,9 @@ const Player = props => {
101
101
  useRef(null);
102
102
  const firstPreviewTimeRef = useRef(false);
103
103
 
104
+ // 标记是否进入内存缓存/后台(onPause、onHide 设为 true,onShow 还原为 false),拉流时若为 true 则拦截
105
+ const isInBackgroundRef = useRef(false);
106
+
104
107
  // 自定义计时老低功耗方案设备在线状态, 用于短暂时间报上下线的UI展示兼容 待实现
105
108
  const [lowPowerDeviceOnlineState, setLowPowerDeviceOnlineState] = useState(onlineStatus);
106
109
  // 用于记录低功耗设备上报离线,延迟5秒展示,避免因设备频繁上下线 导致显示杂乱
@@ -169,6 +172,7 @@ const Player = props => {
169
172
  }
170
173
  });
171
174
  usePageEvent('onShow', useMemoizedFn(async () => {
175
+ isInBackgroundRef.current = false;
172
176
  getNetworkType({
173
177
  success: res => {
174
178
  console.log('网络类型', res);
@@ -251,6 +255,7 @@ const Player = props => {
251
255
  onDpDataChange(handleDpDataChange);
252
256
  }, []);
253
257
  usePageEvent('onHide', useMemoizedFn(async () => {
258
+ isInBackgroundRef.current = true;
254
259
  ipcTTTOperatorLog('VID: onHide event will go to stopPreview');
255
260
  if (ignoreHideStopPreview) {
256
261
  return;
@@ -263,6 +268,7 @@ const Player = props => {
263
268
  // await getCurMute();
264
269
  }));
265
270
  useAppEvent('onPause', useMemoizedFn(async () => {
271
+ isInBackgroundRef.current = true;
266
272
  console.log('onPause, 重新拉流');
267
273
  ipcTTTOperatorLog('VID: onPause stopPreview');
268
274
  stopPreview();
@@ -383,7 +389,7 @@ const Player = props => {
383
389
  * 当检测到设备上报休眠后,触发重新连接
384
390
  */
385
391
  useEffect(() => {
386
- if (wirelessFlag) {
392
+ if (wirelessFlag && !isInBackgroundRef.current) {
387
393
  // 进入面板后,若监听到设备上报休眠后, 需进行重新连接
388
394
  setWirelessFlag(false);
389
395
  _reConnect();
@@ -425,7 +431,7 @@ const Player = props => {
425
431
  * 当接收到外部重连指令且设备在线时,触发重新连接
426
432
  */
427
433
  useEffect(() => {
428
- if (reConnect && devId && onlineStatus) {
434
+ if (reConnect && devId && onlineStatus && !isInBackgroundRef.current) {
429
435
  _reConnect();
430
436
  }
431
437
  }, [reConnect, devId, onlineStatus, _reConnect]);
@@ -490,6 +496,11 @@ const Player = props => {
490
496
  console.log('不在播放器路由内, 不进行拉流');
491
497
  return;
492
498
  }
499
+ if (isInBackgroundRef.current) {
500
+ console.log('处于后台/内存缓存,拦截拉流');
501
+ ipcTTTOperatorLog('VID: isInBackground, block retry');
502
+ return;
503
+ }
493
504
  phoneNetworkConnect && onlineStatus && privateState && (!isLowPowerDevice || isVirtualDevice) && handleReWakeCamera();
494
505
 
495
506
  // 低功耗设备隐私模式需单独处理,先进行下发唤醒, 唤醒后再进行下发DP
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/ray-ipc-player",
3
- "version": "2.1.0-beta.1",
3
+ "version": "2.1.0-beta.2",
4
4
  "description": "ray小程序播放器",
5
5
  "keywords": [
6
6
  "tuya-miniapp",