@ray-js/ipc-player-integration 0.0.1-beta-71 → 0.0.1-beta-73

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/ui/ui.js +122 -12
  2. package/package.json +2 -2
package/lib/ui/ui.js CHANGED
@@ -83,9 +83,14 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
83
83
  const timer = useRef();
84
84
  const [scaleMultiple, setScaleMultiple] = useState(playerFit === 'contain' ? 1 : -2);
85
85
  const [currentZoomLevel, setCurrentZoomLevel] = useState(playerFit === 'contain' ? 1 : -2);
86
+ const [verticalCoverZoom, setVerticalCoverZoom] = useState(-2);
87
+ // const [verticalCoverZoom, setVerticalCoverZoom] = useState(-2);
88
+ // const [verticalZoomLevel, setVerticalZoomLevel] = useState(playerFit === 'contain' ? 1 : -2);
89
+
86
90
  useEffect(() => {
87
91
  setScaleMultiple(playerFit === 'contain' ? 1 : -2);
88
92
  setCurrentZoomLevel(playerFit === 'contain' ? 1 : -2);
93
+ // setVerticalZoomLevel(playerFit === 'contain' ? 1 : -2);
89
94
  }, [playerFit]);
90
95
  useEffect(() => {
91
96
  setBrandColor(brandColor);
@@ -111,21 +116,41 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
111
116
  deviceType
112
117
  } = systemInfo.current;
113
118
  // 针对pad 暂不支持横屏,且在ios pad模式下 会触发onResize事件, 待解决
114
-
115
119
  if (deviceType === 'pad') {
116
120
  setScreenType('vertical');
117
121
  } else {
118
122
  setScreenType(type === 'landscape' ? 'full' : 'vertical');
119
123
  }
120
-
121
124
  // 若为全屏模式并且要求按宽填充,即横屏时充满,主动设置模式为-1即可
122
125
  if (type === 'landscape' && landscapeMode === 'fill') {
126
+ // instance.IPCPlayerInstance.setObjectFit({
127
+ // objectFit: 'fillCrop',
128
+ // });
129
+ console.log(scaleMultiple, '===========fill');
123
130
  setScaleMultiple(-1);
124
131
  } else if (type === 'landscape' && landscapeMode === 'standard') {
132
+ // instance.IPCPlayerInstance.setObjectFit({
133
+ // objectFit: 'contain',
134
+ // });
135
+ // setTimeout(() => {
136
+ // console.log('dsahdjsahjdhsajhdjh==');
137
+ // instance.IPCPlayerInstance.setScaleMultiple({
138
+ // scaleMultiple: -2,
139
+ // });
140
+ // }, 3000);
141
+ console.log(scaleMultiple, '===========landscape');
125
142
  setScaleMultiple(-2);
126
143
  } else {
127
144
  // 竖屏时 将屏幕播放比例设为按宽按高
128
- setScaleMultiple(playerFit === 'contain' ? -1 : -2);
145
+ // console.log(verticalZoomLevel, 'verticalZoomLevel======');
146
+ // instance.IPCPlayerInstance.setScaleMultiple({
147
+ // scaleMultiple: playerFit === 'contain' ? -1 : -2,
148
+ // });
149
+ console.log(scaleMultiple, '===========landscape');
150
+ setScaleMultiple(playerFit === 'contain' ? scaleMultiple === 1 ? -1 : 1 : -2);
151
+ // instance.IPCPlayerInstance.setObjectFit({
152
+ // objectFit: playerFit === 'contain' ? 'fillCrop' : 'contain',
153
+ // });
129
154
  }
130
155
  } catch (err) {
131
156
  console.log(err, 'err');
@@ -269,6 +294,8 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
269
294
  // 合并为三种状态 连接中 暂停 播放中
270
295
  const playState = playStateMap[code] || PlayState.CONNECTING;
271
296
  if (playState !== PlayState.PLAYING) {
297
+ console.log('非播放状态=======');
298
+ console.log(currentZoomLevel, 'currentZoomLevel');
272
299
  setScaleMultiple(currentZoomLevel);
273
300
  }
274
301
  setPlayState(playState);
@@ -333,7 +360,63 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
333
360
  };
334
361
  }, []);
335
362
  playState === PlayState.PLAYING;
336
- console.log(scaleMultiple, 'scaleMultiple===');
363
+ /**
364
+ * 监听当前的zoom比例状态
365
+ */
366
+ // useEffect(() => {
367
+ // if (screenType === 'vertical') {
368
+ // console.log(currentZoomLevel, '竖屏时的缩放比例');
369
+ // setVerticalZoomLevel(currentZoomLevel);
370
+ // // setScaleMultiple(currentZoomLevel);
371
+ // }
372
+ // }, [screenType, currentZoomLevel]);
373
+
374
+ const onZoomChange = useMemoizedFn(data => {
375
+ const {
376
+ zoomLevel,
377
+ scaleMode
378
+ } = data === null || data === void 0 ? void 0 : data.detail;
379
+ // 针对返回0的情况,忽略
380
+ console.log('推送的zoomChange', JSON.stringify(data));
381
+ if (zoomLevel === 0) {
382
+ return false;
383
+ }
384
+ /**
385
+ * 针对竖屏为cover模式时,横屏为standard模式时,主动设置缩放比例,避免因值不能正常变化
386
+ */
387
+ if (scaleMode === -2 && playerFit === 'cover' && screenType === 'vertical' && landscapeMode === 'standard') {
388
+ console.log('dsadsadsad----', zoomLevel);
389
+ setScaleMultiple(zoomLevel);
390
+ // setVerticalCoverZoom(zoomLevel);
391
+ }
392
+ /**
393
+ * 针对竖屏为contain模式时,横屏为fill模式时,主动设置缩放比例,避免因值不能正常变化
394
+ */
395
+ if (scaleMode === -1 && playerFit === 'contain' && screenType === 'vertical' && landscapeMode === 'fill') {
396
+ setVerticalCoverZoom(zoomLevel);
397
+ }
398
+
399
+ /**
400
+ * 横屏情况下 针对竖屏为contain模式时,横屏为fill模式时,主动设置缩放比例,避免因值不能正常变化
401
+ */
402
+ if (scaleMode === -2 && playerFit === 'cover' && screenType !== 'vertical' && landscapeMode === 'standard') {
403
+ setScaleMultiple(zoomLevel);
404
+ }
405
+ if (scaleMode === -1 && playerFit === 'contain' && screenType !== 'vertical' && landscapeMode === 'fill') {
406
+ setVerticalCoverZoom(zoomLevel);
407
+ setScaleMultiple(zoomLevel);
408
+ }
409
+
410
+ // if (screenType === 'vertical' && scaleMode === -1) {
411
+ // console.log('dsadsadsad----');
412
+ // // setVerticalCoverZoom(zoomLevel);
413
+ // setScaleMultiple(zoomLevel);
414
+ // }
415
+ console.log(data === null || data === void 0 ? void 0 : data.detail, 'data?.detail');
416
+ console.log(zoomLevel, 'zoomLevel======');
417
+ setCurrentZoomLevel(zoomLevel);
418
+ return false;
419
+ });
337
420
  return /*#__PURE__*/React.createElement(UIEventContext.Provider, {
338
421
  value: {
339
422
  event: eventRef.current,
@@ -357,14 +440,20 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
357
440
  console.log(`onCameraNotifyWeakNetwork: ${JSON.stringify(data)}`);
358
441
  },
359
442
  clarity: decodeClarityDic[resolution],
360
- onZoomChange: data => {
361
- const {
362
- zoomLevel
363
- } = data === null || data === void 0 ? void 0 : data.detail;
364
- console.log(zoomLevel, 'zoomLevel======');
365
- setCurrentZoomLevel(zoomLevel);
366
- },
443
+ onZoomChange: onZoomChange
444
+ // objectFit={
445
+ // screenType === 'vertical'
446
+ // ? playerFit === 'contain'
447
+ // ? 'fillCrop'
448
+ // : 'contain'
449
+ // : landscapeMode === 'standard'
450
+ // ? 'contain'
451
+ // : 'fillCrop'
452
+ // }
453
+ ,
454
+ objectFit: "fillCrop",
367
455
  scaleMultiple: scaleMultiple
456
+ // scaleMultiple={-100}
368
457
  // 安卓横屏问题
369
458
  // ptzControllable={screenType === 'vertical'}
370
459
  ,
@@ -429,5 +518,26 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
429
518
  className: clsx('absolute-item-container')
430
519
  })));
431
520
  });
432
- })()));
521
+ })(), /*#__PURE__*/React.createElement(View, {
522
+ style: {
523
+ position: 'absolute',
524
+ top: '30px',
525
+ right: '20px',
526
+ backgroundColor: 'red'
527
+ }
528
+ }, "scaleMultiple: ", scaleMultiple), /*#__PURE__*/React.createElement(View, {
529
+ style: {
530
+ position: 'absolute',
531
+ top: '50px',
532
+ right: '20px',
533
+ backgroundColor: 'blue'
534
+ }
535
+ }, "\u5C4F\u5E55\u65B9\u5411: ", screenType), /*#__PURE__*/React.createElement(View, {
536
+ style: {
537
+ position: 'absolute',
538
+ top: '100px',
539
+ right: '20px',
540
+ backgroundColor: 'blue'
541
+ }
542
+ }, "\u5F53\u524D\u6BD4\u4F8B: ", currentZoomLevel)));
433
543
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/ipc-player-integration",
3
- "version": "0.0.1-beta-71",
3
+ "version": "0.0.1-beta-73",
4
4
  "description": "IPC 播放器功能集成",
5
5
  "main": "lib/index",
6
6
  "files": [
@@ -38,7 +38,7 @@
38
38
  "dependencies": {
39
39
  "@ray-js/ipc-ptz-zoom": "0.0.2-beta-7",
40
40
  "@ray-js/panel-sdk": "^1.13.1",
41
- "@ray-js/ray-ipc-player": "2.0.20-beta-13",
41
+ "@ray-js/ray-ipc-player": "2.0.20-beta-17",
42
42
  "@ray-js/ray-ipc-utils": "1.1.0-beta-17",
43
43
  "@ray-js/svg": "0.2.0",
44
44
  "clsx": "^1.2.1",