@ray-js/ipc-player-integration 0.0.21 → 0.0.22

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/ctx/ctx.js CHANGED
@@ -7,6 +7,7 @@ import { getSystemInfoSync, showModal, openAppSystemSettingPage } from '@ray-js/
7
7
  import Strings from '../i18n';
8
8
  import { useAtom, updateAtom, getDefaultStore, useStore } from './store';
9
9
  import { PlayState, IntercomMode } from '../interface';
10
+ import { changeIgnoreHideStopPreview } from '../ui/constant';
10
11
  import { ClarityType } from '@ray-js/ray-ipc-utils/lib/interface';
11
12
  import { getEventInstance } from './event';
12
13
  const SAVE_TO_ALBUM = 1;
@@ -237,10 +238,14 @@ export const createUseCtx = _ref => {
237
238
  const store = getDefaultStore();
238
239
  const _intercom = store.get(intercom);
239
240
  if (target && target === _intercom) {
241
+ eventRef.current.emit(changeIgnoreHideStopPreview, false);
240
242
  console.log('Cannot intercom during video _intercom');
241
243
  return false;
242
244
  }
243
- if (!target && target === _intercom) return true;
245
+ if (!target && target === _intercom) {
246
+ eventRef.current.emit(changeIgnoreHideStopPreview, false);
247
+ return true;
248
+ }
244
249
  return new Promise((resolve, reject) => {
245
250
  if (target) {
246
251
  ty.authorizeStatus({
@@ -248,12 +253,14 @@ export const createUseCtx = _ref => {
248
253
  scope: 'scope.record',
249
254
  success: success => {
250
255
  console.log(success, 'success');
256
+ eventRef.current.emit(changeIgnoreHideStopPreview, false);
251
257
  IPCPlayerInstance.current.startTalk({
252
258
  success: () => {
253
259
  updateAtom(intercom, true);
254
260
  resolve(true);
255
261
  },
256
262
  fail: err => {
263
+ eventRef.current.emit(changeIgnoreHideStopPreview, false);
257
264
  const errObj = err.innerError || err || {};
258
265
  const errMsg = errObj.errorMsg || Strings.getLang('ipc_player_error_intercom');
259
266
  toast({
@@ -264,16 +271,20 @@ export const createUseCtx = _ref => {
264
271
  });
265
272
  },
266
273
  fail: () => {
274
+ console.log('失败回调');
267
275
  ty.authorize({
268
276
  // 麦克风权限
269
277
  scope: 'scope.record',
270
278
  success: () => {
279
+ console.log('我不知道你是个什么玩意');
271
280
  IPCPlayerInstance.current.startTalk({
272
281
  success: () => {
282
+ // eventRef.current.emit(changeIgnoreHideStopPreview, false);
273
283
  updateAtom(intercom, true);
274
284
  resolve(true);
275
285
  },
276
286
  fail: err => {
287
+ // eventRef.current.emit(changeIgnoreHideStopPreview, false);
277
288
  const errObj = err.innerError || err || {};
278
289
  const errMsg = errObj.errorMsg || Strings.getLang('ipc_player_error_intercom');
279
290
  toast({
@@ -284,6 +295,8 @@ export const createUseCtx = _ref => {
284
295
  });
285
296
  },
286
297
  fail: err => {
298
+ console.log('我不知道你是说什么');
299
+ // eventRef.current.emit(changeIgnoreHideStopPreview, false);
287
300
  showModal({
288
301
  title: '',
289
302
  content: Strings.getLang('ipc_player_no_record_permission'),
@@ -11,6 +11,7 @@ export declare const ptzControlTipId = "ptzControlTipId";
11
11
  export declare const fullResolutionId = "fullResolutionId";
12
12
  export declare const batteryId = "Battery";
13
13
  export declare const fullSmallIntercomId = "FullSmallIntercom";
14
+ export declare const changeIgnoreHideStopPreview = "changeIgnoreHideStopPreview";
14
15
  export declare const decodeClarityDic: {
15
16
  SS: string;
16
17
  SD: string;
@@ -11,6 +11,7 @@ export const ptzControlTipId = 'ptzControlTipId';
11
11
  export const fullResolutionId = 'fullResolutionId';
12
12
  export const batteryId = 'Battery';
13
13
  export const fullSmallIntercomId = 'FullSmallIntercom';
14
+ export const changeIgnoreHideStopPreview = 'changeIgnoreHideStopPreview';
14
15
  export const decodeClarityDic = {
15
16
  SS: 'ss',
16
17
  // 省流量
package/lib/ui/ui.js CHANGED
@@ -11,7 +11,7 @@ import { PlayState, PlayerStreamStatus } from '../interface';
11
11
  import { useCtx } from '../ctx/ctx.composition';
12
12
  import { useStore } from '../ctx/store';
13
13
  import { UIEventContext } from './context';
14
- import { showAllComponent, hideAllComponent, playerTap, startTimeToHideAllComponent, pauseTimeToHideAllComponent, decodeClarityDic } from './constant';
14
+ import { showAllComponent, hideAllComponent, playerTap, startTimeToHideAllComponent, pauseTimeToHideAllComponent, decodeClarityDic, changeIgnoreHideStopPreview } from './constant';
15
15
  import BottomLeftContent from './bottomLeftContent';
16
16
  import BottomRightContent from './bottomRightContent';
17
17
  import TopLeftContent from './topLeftContent';
@@ -94,10 +94,16 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
94
94
  const [scaleMultiple, setScaleMultiple] = useState(playerFit === 'contain' ? 1 : -2);
95
95
  const [currentZoomLevel, setCurrentZoomLevel] = useState(playerFit === 'contain' ? 1 : -2);
96
96
  const [createCtx, setCreateCtx] = useState(false);
97
+ // 是否需要忽略进入后台停止预览
98
+ const [ignoreStopOnHide, setIgnoreStopOnHide] = useState(ignoreHideStopPreview);
97
99
  const [verticalCoverZoom, setVerticalCoverZoom] = useState(-2);
98
100
  // const [verticalCoverZoom, setVerticalCoverZoom] = useState(-2);
99
101
  // const [verticalZoomLevel, setVerticalZoomLevel] = useState(playerFit === 'contain' ? 1 : -2);
100
102
 
103
+ // 外部传入的ignoreHideStopPreview变化时,同步更新
104
+ useEffect(() => {
105
+ setIgnoreStopOnHide(ignoreHideStopPreview);
106
+ }, [ignoreHideStopPreview]);
101
107
  const handleOrientationChange = useMemoizedFn(data => {
102
108
  console.log(data, 'data=============');
103
109
  const {
@@ -466,6 +472,9 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
466
472
  const listenShowEvent = useMemoizedFn(() => {
467
473
  setComponentHideState(false);
468
474
  });
475
+ const onChangeIgnoreHideStopPreview = state => {
476
+ setIgnoreStopOnHide(state);
477
+ };
469
478
  useEffect(() => {
470
479
  eventRef.current.on(startTimeToHideAllComponent, listenStart);
471
480
  eventRef.current.on(pauseTimeToHideAllComponent, listenPause);
@@ -473,6 +482,7 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
473
482
  eventRef.current.on(hideAllComponent, listenHideEvent);
474
483
  eventRef.current.on('disablePlayerTap', handDisablePlayerTap);
475
484
  eventRef.current.on('refreshBottomLeft', refreshBottomLeft);
485
+ eventRef.current.on(changeIgnoreHideStopPreview, onChangeIgnoreHideStopPreview);
476
486
  return () => {
477
487
  eventRef.current.off(startTimeToHideAllComponent, listenStart);
478
488
  eventRef.current.off(pauseTimeToHideAllComponent, listenPause);
@@ -480,6 +490,7 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
480
490
  eventRef.current.off(hideAllComponent, listenHideEvent);
481
491
  eventRef.current.off('disablePlayerTap', handDisablePlayerTap);
482
492
  eventRef.current.off('refreshBottomLeft', refreshBottomLeft);
493
+ eventRef.current.off(changeIgnoreHideStopPreview, onChangeIgnoreHideStopPreview);
483
494
  if (reGetOrientationTimer.current) {
484
495
  clearTimeout(reGetOrientationTimer.current);
485
496
  reGetOrientationTimer.current = null;
@@ -550,7 +561,8 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
550
561
  devId: devId,
551
562
  onlineStatus: deviceOnline,
552
563
  isShare: isShare,
553
- ignoreHideStopPreview: ignoreHideStopPreview,
564
+ ignoreHideStopPreview: ignoreStopOnHide,
565
+ onChangeIgnoreHideStopPreview: onChangeIgnoreHideStopPreview,
554
566
  ipcPlayerContext: instance.IPCPlayerInstance,
555
567
  onChangeStreamStatus: onChangeStreamStatus,
556
568
  onCtx: res => {
@@ -1,6 +1,6 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
2
  import React, { useRef, useContext, useState, useEffect } from 'react';
3
- import { View } from '@ray-js/ray';
3
+ import { View, getSystemInfoSync } from '@ray-js/ray';
4
4
  import clsx from 'clsx';
5
5
  import Svg from '@ray-js/svg';
6
6
  import { useStore, getDefaultStore, updateAtom } from '../../ctx/store';
@@ -8,7 +8,7 @@ import './voiceIntercom.less';
8
8
  import { PlayerStreamStatus, IntercomMode, PlayState } from '../../interface';
9
9
  import { UIEventContext } from '../../ui/context';
10
10
  import { radialGradient } from '../../utils';
11
- import { startTimeToHideAllComponent, pauseTimeToHideAllComponent } from '../../ui/constant';
11
+ import { startTimeToHideAllComponent, pauseTimeToHideAllComponent, changeIgnoreHideStopPreview } from '../../ui/constant';
12
12
  const NILL = () => null;
13
13
  export const VoiceIntercom = props => {
14
14
  const {
@@ -33,7 +33,6 @@ export const VoiceIntercom = props => {
33
33
  const [frame, setFrame] = useState(0);
34
34
  const talkingInterval = useRef(null);
35
35
  // 每帧间隔(ms)
36
-
37
36
  const {
38
37
  event
39
38
  } = useContext(UIEventContext);
@@ -60,9 +59,23 @@ export const VoiceIntercom = props => {
60
59
  console.log('PlayerStreamStatus not 1002');
61
60
  return;
62
61
  }
62
+ // 发送忽略进入后台停止预览的标记
63
+ const {
64
+ platform
65
+ } = getSystemInfoSync();
66
+ if (platform === 'ios') {
67
+ event.emit(changeIgnoreHideStopPreview, true);
68
+ }
63
69
  console.log('==== 开始对讲 =====');
64
70
  originMuteStatusBeforeVoice.current = _mute;
65
- await setIntercom(true);
71
+ try {
72
+ await setIntercom(true);
73
+ } catch (e) {
74
+ console.error('setIntercom failed:', e);
75
+ } finally {
76
+ // 无论对讲成功与否,都取消忽略进入后台停止预览的标记, 但是会
77
+ // event.emit(changeIgnoreHideStopPreview, false);
78
+ }
66
79
  // 确定对讲有成功回调后,单向对讲判断开始对讲前需要静音
67
80
  // 确定对讲有成功回调后, 双路对讲开始对讲前需要打开拾音器
68
81
  const muteTarget = intercomMode === IntercomMode.OneWay;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/ipc-player-integration",
3
- "version": "0.0.21",
3
+ "version": "0.0.22",
4
4
  "description": "IPC 融合播放器",
5
5
  "main": "lib/index",
6
6
  "files": [
@@ -38,7 +38,7 @@
38
38
  "@ray-js/ipc-ptz-zoom": "^0.0.2",
39
39
  "@ray-js/panel-sdk": "^1.13.1",
40
40
  "@ray-js/direction-control": "^0.0.8",
41
- "@ray-js/ray-ipc-player": "^2.0.26",
41
+ "@ray-js/ray-ipc-player": "^2.0.27",
42
42
  "@ray-js/ray-ipc-utils": "^1.1.10",
43
43
  "@ray-js/svg": "0.2.0",
44
44
  "clsx": "^1.2.1",