@ray-js/ray-ipc-player 2.0.26 → 2.0.27

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
@@ -56,7 +56,8 @@ const Player = props => {
56
56
  onPlayerContainerTap,
57
57
  reConnect = false,
58
58
  awakeStatus = undefined,
59
- ignoreHideStopPreview = false
59
+ ignoreHideStopPreview = false,
60
+ onChangeIgnoreHideStopPreview
60
61
  } = props;
61
62
  const {
62
63
  borderRadius,
@@ -123,19 +124,21 @@ const Player = props => {
123
124
  const muteRef = useRef(defaultMute); // 静音
124
125
 
125
126
  usePageEvent('onShow', useMemoizedFn(async () => {
126
- // 视图准备就绪
127
- if (phoneNetworkConnect && playState.initLy && ipcCtx.current && onlineStatus && !privateState) {
128
- ipcTTTOperatorLog('VID: onShow_event_to_retry');
129
- retry();
127
+ if (ignoreHideStopPreview) {
128
+ onChangeIgnoreHideStopPreview && onChangeIgnoreHideStopPreview(false);
129
+ return;
130
130
  }
131
- }));
132
- usePageEvent('onShow', () => {
133
131
  getNetworkType({
134
132
  success: res => {
135
133
  setPhoneNetworkConnect(res.networkType !== 'none');
136
134
  }
137
135
  });
138
- });
136
+ // 视图准备就绪
137
+ if (phoneNetworkConnect && playState.initLy && ipcCtx.current && onlineStatus && !privateState) {
138
+ ipcTTTOperatorLog('VID: onShow_event_to_retry');
139
+ retry();
140
+ }
141
+ }));
139
142
  usePageEvent('onResize', sizeData => {
140
143
  const {
141
144
  type
@@ -180,19 +183,18 @@ const Player = props => {
180
183
  onDpDataChange(handleDpDataChange);
181
184
  }, []);
182
185
  usePageEvent('onHide', useMemoizedFn(async () => {
183
- setPlayState(d => {
184
- d.loadingState = true;
185
- });
186
186
  if (ignoreHideStopPreview) {
187
187
  return;
188
188
  }
189
+ setPlayState(d => {
190
+ d.loadingState = true;
191
+ });
189
192
  // 先停流
190
193
  stopPreview();
191
194
  // await getCurMute();
192
195
  }));
193
196
  useMount(() => {
194
197
  onNetworkStatusChange(res => {
195
- console.log(res, 'res==========onNetworkStatusChange');
196
198
  setPhoneNetworkConnect(res.isConnected);
197
199
  if (!res.isConnected) {
198
200
  // 断网,需要主动调用断流以及断开P2P
@@ -186,4 +186,10 @@ export type IProps = {
186
186
  * @default false
187
187
  */
188
188
  ignoreHideStopPreview?: boolean;
189
+ /**
190
+ * @description.en onChangeIgnoreHideStopPreview
191
+ * @description.zh 更新 ignoreHideStopPreview 数据
192
+ * @default (data) => void
193
+ */
194
+ onChangeIgnoreHideStopPreview?: (data: boolean) => void;
189
195
  };
package/lib/utils.js CHANGED
@@ -158,14 +158,18 @@ export const ipcTTTOperatorLog = ipcLogString => {
158
158
  */
159
159
  export const wakeUpDevice = deviceId => {
160
160
  ipcTTTOperatorLog('start publish wakeUpDevice');
161
- ty.device.wakeUpDevice({
162
- deviceId,
163
- dps: {},
164
- success: () => {
165
- ipcTTTOperatorLog('publish wakeUpDevice success');
166
- },
167
- fail: () => {
168
- ipcTTTOperatorLog('publish wakeUpDevice fail');
169
- }
170
- });
161
+ try {
162
+ ty.device.wakeUpDevice({
163
+ deviceId,
164
+ dps: {},
165
+ success: () => {
166
+ ipcTTTOperatorLog('publish wakeUpDevice success');
167
+ },
168
+ fail: () => {
169
+ ipcTTTOperatorLog('publish wakeUpDevice fail');
170
+ }
171
+ });
172
+ } catch (err) {
173
+ console.log('wakeUpDevice error', err);
174
+ }
171
175
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/ray-ipc-player",
3
- "version": "2.0.26",
3
+ "version": "2.0.27",
4
4
  "description": "ray小程序播放器",
5
5
  "keywords": [
6
6
  "tuya-miniapp",