@ray-js/ray-ipc-player 2.0.29-beta-1 → 2.0.29-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/index.js CHANGED
@@ -7,7 +7,7 @@ import { useImmer } from 'use-immer';
7
7
  import _isEmpty from 'lodash/isEmpty';
8
8
  import { IpcPlayer, View, CoverView } from '@ray-js/components';
9
9
  import { useMount, useUnmount, useMemoizedFn } from 'ahooks';
10
- import { setPageOrientation, usePageEvent, getNetworkType, offNetworkStatusChange, onNetworkStatusChange, publishDps, showToast, getSystemInfoSync, onMqttMessageReceived, registerMQTTProtocolListener, offMqttMessageReceived, unregisterMQTTProtocolListener, registerDeviceListListener, onDpDataChange, onDeviceOnlineStatusUpdate, performanceEvent } from '@ray-js/ray';
10
+ import { setPageOrientation, usePageEvent, getNetworkType, offNetworkStatusChange, onNetworkStatusChange, publishDps, showToast, getSystemInfoSync, onMqttMessageReceived, registerMQTTProtocolListener, offMqttMessageReceived, unregisterMQTTProtocolListener, registerDeviceListListener, onDpDataChange, onDeviceOnlineStatusUpdate, performanceEvent, getCurrentPages } from '@ray-js/ray';
11
11
  import clsx from 'clsx';
12
12
  import Strings from './i18n';
13
13
  import { IpcFailCode } from './constant';
@@ -60,7 +60,8 @@ const Player = props => {
60
60
  onChangeIgnoreHideStopPreview,
61
61
  hideSuggestedText = false,
62
62
  hideHelpButton = false,
63
- hideFeedBackButton = false
63
+ hideFeedBackButton = false,
64
+ playerRoute = ''
64
65
  } = props;
65
66
  const {
66
67
  borderRadius,
@@ -379,6 +380,11 @@ const Player = props => {
379
380
 
380
381
  // 无需关心连接状态直接发起重新连接
381
382
  const _reConnect = () => {
383
+ console.log('不在播放器路由内, 不进行标记');
384
+ // 排除默认值为"",不等于播放器路由时, 不进行连接操作
385
+ if (playerRoute !== '' && playerRoute !== getPlayerRoute()) {
386
+ return;
387
+ }
382
388
  setPlayState(d => {
383
389
  d.connectState = true;
384
390
  d.loadingText = Strings.getLang('ipc_player_get_video_stream');
@@ -475,8 +481,14 @@ const Player = props => {
475
481
  }, 15000);
476
482
  }
477
483
  });
484
+ const getPlayerRoute = () => {
485
+ const pages = getCurrentPages(); // 获取当前页面栈
486
+ const currentPage = pages[pages.length - 1]; // 获取当前页面实例
487
+ return currentPage.route;
488
+ };
478
489
  const retry = useMemoizedFn(() => {
479
490
  console.log('重新拉流启动');
491
+
480
492
  // 任何重试拉流时, 将播放器状态还原为loading状态
481
493
  setVideoErrCode('');
482
494
  setPlayState(d => {
@@ -484,6 +496,12 @@ const Player = props => {
484
496
  d.errorState = false;
485
497
  d.errorMsg = '';
486
498
  });
499
+ // 排除默认值为"",不等于播放器路由时, 不进行重试拉流
500
+
501
+ if (playerRoute !== '' && playerRoute !== getPlayerRoute()) {
502
+ console.log('不在播放器路由内, 不进行拉流');
503
+ return;
504
+ }
487
505
  phoneNetworkConnect && onlineStatus && privateState && (!isLowPowerDevice || isVirtualDevice) && handleReWakeCamera();
488
506
 
489
507
  // 低功耗设备隐私模式需单独处理,先进行下发唤醒, 唤醒后再进行下发DP
@@ -504,6 +522,10 @@ const Player = props => {
504
522
  // 建立连接
505
523
  const createConnect = useMemoizedFn(async params => {
506
524
  var _ipcCtx$current;
525
+ if (playerRoute !== '' && playerRoute !== getPlayerRoute()) {
526
+ console.log('不在播放器路由内, 不进行连接操作');
527
+ return;
528
+ }
507
529
  // console.log('建立连接前:', devId, Date.now());
508
530
  // 若走到连接状态,需清除低功耗15秒超时定时
509
531
  privateLowPowerDeviceTimeOutRef.current && clearTimeout(privateWakeOutTimeRef.current);
@@ -195,19 +195,25 @@ export type IProps = {
195
195
  /**
196
196
  * @description.en hide suggested text
197
197
  * @description.zh 隐藏建议文案
198
- * @default (data) => void
198
+ * @default false
199
199
  */
200
200
  hideSuggestedText?: boolean;
201
201
  /**
202
202
  * @description.en hide help button
203
203
  * @description.zh 隐藏反馈帮助按钮
204
- * @default (data) => void
204
+ * @default false
205
205
  */
206
206
  hideHelpButton?: boolean;
207
207
  /**
208
208
  * @description.en hide feedback button
209
209
  * @description.zh 隐藏反馈按钮
210
- * @default (data) => void
210
+ * @default false
211
211
  */
212
212
  hideFeedBackButton?: boolean;
213
+ /**
214
+ * @description.en Route where the player is located
215
+ * @description.zh 播放器所在路由
216
+ * @default '
217
+ */
218
+ playerRoute?: string;
213
219
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/ray-ipc-player",
3
- "version": "2.0.29-beta-1",
3
+ "version": "2.0.29-beta-2",
4
4
  "description": "ray小程序播放器",
5
5
  "keywords": [
6
6
  "tuya-miniapp",