@ray-js/ipc-player-integration 0.0.35-beta.4 → 0.0.35-beta.6

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.
@@ -21,8 +21,6 @@ export declare const landscapeTipId = "landscapeTipId";
21
21
  export declare const multiPtzId = "multiPtzId";
22
22
  /** 控件点击统一事件:任意播放器内控件被点击时触发,可用于埋点或统一处理 */
23
23
  export declare const widgetClick = "widgetClick";
24
- /** 「去体验」按钮业务事件,与清晰度 resolutionBtnControlClick 用法一致 */
25
- export declare const tryExperienceBtnClick = "tryExperienceBtnClick";
26
24
  /**
27
25
  * 试看倒计时结束事件:试看徽章倒计时归零时触发,
28
26
  * 业务侧/相关控件可监听此事件刷新自己的状态(例如 TryExperience 重新拉取状态)
@@ -22,9 +22,6 @@ export const multiPtzId = 'multiPtzId';
22
22
  /** 控件点击统一事件:任意播放器内控件被点击时触发,可用于埋点或统一处理 */
23
23
  export const widgetClick = 'widgetClick';
24
24
 
25
- /** 「去体验」按钮业务事件,与清晰度 resolutionBtnControlClick 用法一致 */
26
- export const tryExperienceBtnClick = 'tryExperienceBtnClick';
27
-
28
25
  /**
29
26
  * 试看倒计时结束事件:试看徽章倒计时归零时触发,
30
27
  * 业务侧/相关控件可监听此事件刷新自己的状态(例如 TryExperience 重新拉取状态)
package/lib/ui/index.d.ts CHANGED
@@ -3,4 +3,4 @@ export * from './hooks';
3
3
  export * from './context';
4
4
  export type * from './event';
5
5
  export { widgetClick } from './widgetClick';
6
- export { widgetLabs, tryExperienceBtnClick, trialCountdownEnd } from './constant';
6
+ export { widgetLabs, trialCountdownEnd } from './constant';
package/lib/ui/index.js CHANGED
@@ -2,4 +2,4 @@ export * from './ui';
2
2
  export * from './hooks';
3
3
  export * from './context';
4
4
  export { widgetClick } from './widgetClick';
5
- export { widgetLabs, tryExperienceBtnClick, trialCountdownEnd } from './constant';
5
+ export { widgetLabs, trialCountdownEnd } from './constant';
package/lib/ui/ui.js CHANGED
@@ -12,7 +12,7 @@ import { PlayState, PlayerStreamStatus, MultiCameraScreenMode } from '../interfa
12
12
  import { useCtx } from '../ctx/ctx.composition';
13
13
  import { useStore, updateAtom } from '../ctx/store';
14
14
  import { UIEventContext } from './context';
15
- import { showAllComponent, hideAllComponent, playerTap, startTimeToHideAllComponent, pauseTimeToHideAllComponent, decodeClarityDic, changeIgnoreHideStopPreview, moveablePtzControlId, tileActionsId, tileTipId, landscapeTipId, multiPtzId, ptzMoveableTipId, showFlowLowTipId, zoomLevelChange, setScaleMultipleEvent } from './constant';
15
+ import { showAllComponent, hideAllComponent, playerTap, startTimeToHideAllComponent, pauseTimeToHideAllComponent, decodeClarityDic, changeIgnoreHideStopPreview, moveablePtzControlId, tileActionsId, tileTipId, landscapeTipId, multiPtzId, ptzMoveableTipId, showFlowLowTipId, zoomLevelChange, setScaleMultipleEvent, trialCountdownEnd } from './constant';
16
16
  import BottomLeftContent from './bottomLeftContent';
17
17
  import BottomRightContent from './bottomRightContent';
18
18
  import TopLeftContent from './topLeftContent';
@@ -104,14 +104,14 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
104
104
  useImperativeHandle(eventRefProp, () => eventRef.current, [eventRef.current]);
105
105
  const timer = useRef();
106
106
  const reGetOrientationTimer = useRef(null);
107
- const [scaleMultiple, setScaleMultiple] = useState(playerFit === 'contain' ? 1 : -2);
108
- const [currentZoomLevel, setCurrentZoomLevel] = useState(playerFit === 'contain' ? 1 : -2);
107
+ // 统一调整为1倍缩放,保证画面展示完全
108
+ const [scaleMultiple, setScaleMultiple] = useState(1);
109
+ // 统一调整为1倍缩放,保证画面展示完全
110
+ const [currentZoomLevel, setCurrentZoomLevel] = useState(1);
109
111
  const [createCtx, setCreateCtx] = useState(false);
110
112
  // 是否需要忽略进入后台停止预览
111
113
  const [ignoreStopOnHide, setIgnoreStopOnHide] = useState(ignoreHideStopPreview);
112
114
  const [verticalCoverZoom, setVerticalCoverZoom] = useState(-2);
113
- // const [verticalCoverZoom, setVerticalCoverZoom] = useState(-2);
114
- // const [verticalZoomLevel, setVerticalZoomLevel] = useState(playerFit === 'contain' ? 1 : -2);
115
115
 
116
116
  // 展示顶部内容
117
117
  const [showTopContent, setShowTopContent] = useState(true);
@@ -407,8 +407,8 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
407
407
  eventRef.current.emit(showAllComponent);
408
408
  eventRef.current.emit('disablePlayerTap', true);
409
409
  eventRef.current.emit(pauseTimeToHideAllComponent);
410
- // 按宽填充,保证播放流宽度为屏幕宽度,高度自适应
411
- setScaleMultiple(-1);
410
+ // 按宽填充,保证播放流宽度为屏幕宽度,高度自适应设为1倍
411
+ setScaleMultiple(1);
412
412
  } else {
413
413
  // 短屏或横屏时,恢复自动隐藏
414
414
  eventRef.current.emit('disablePlayerTap', false);
@@ -417,8 +417,9 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
417
417
  }, [isVerticalFullLayout, screenType, playerFit]);
418
418
  useEffect(() => {
419
419
  if (createCtx) {
420
- setScaleMultiple(playerFit === 'contain' ? 1 : -2);
421
- setCurrentZoomLevel(playerFit === 'contain' ? 1 : -2);
420
+ // 统一调整为1倍缩放,保证画面展示完全
421
+ setScaleMultiple(1);
422
+ setCurrentZoomLevel(1);
422
423
  }
423
424
  }, [playerFit, createCtx]);
424
425
  useEffect(() => {
@@ -427,7 +428,6 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
427
428
  }, [brandColor, verticalMic]);
428
429
  const refreshSmartImageQuality = useMemoizedFn(() => {
429
430
  getSmartImageQualityState(devId).then(res => {
430
- console.log('res===getSmartImageQualityState', res);
431
431
  updatePlayerWidgetProps(instance, 'bottomLeft', 'TryExperience', {
432
432
  buttonState: res.buttonState,
433
433
  trialRemainingSec: res.trialRemainingSec,
@@ -436,8 +436,10 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
436
436
  });
437
437
  });
438
438
  useEffect(() => {
439
- refreshSmartImageQuality();
440
- }, [instance]);
439
+ if (playState === PlayState.PLAYING) {
440
+ refreshSmartImageQuality();
441
+ }
442
+ }, [playState]);
441
443
  const refreshBottomLeft = () => {
442
444
  event.current.emit(startTimeToHideAllComponent);
443
445
  event.current.emit(showAllComponent);
@@ -496,19 +498,8 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
496
498
  }
497
499
  triggerEvent(showAllComponent);
498
500
  }
499
- // 若为全屏模式并且要求按宽填充,即横屏时充满,主动设置模式为-1即可
500
- if (type === 'landscape' && landscapeMode === 'fill') {
501
- console.log(scaleMultiple, '===========fill');
502
- setScaleMultiple(-1);
503
- } else if (type === 'landscape' && landscapeMode === 'standard') {
504
- console.log(scaleMultiple, '===========landscape');
505
- setScaleMultiple(-2);
506
- } else {
507
- // 竖屏时 将屏幕播放比例设为按宽按高
508
-
509
- console.log(scaleMultiple, '===========landscape');
510
- setScaleMultiple(playerFit === 'contain' ? scaleMultiple === 1 ? -1 : 1 : -2);
511
- }
501
+ // 横屏(fill/standard)与竖屏均统一调整为 1 倍缩放,保证画面完整展示
502
+ setScaleMultiple(1);
512
503
  } catch (err) {
513
504
  console.log(err, 'err');
514
505
  }
@@ -672,10 +663,12 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
672
663
  }
673
664
  }
674
665
  if (playState === PlayState.PLAYING) {
675
- // 仅在第一次播放成功时,针对竖屏并且为cover模式时,设置为-2
666
+ // 仅在第一次播放成功时,针对竖屏并且为cover模式时,设置为-2 修改为只针对第一次播放成功时
676
667
  console.log('Playing状态');
677
- if (screenType === 'vertical' && playerFit === 'cover' && !hasPlayedRef.current) {
678
- setScaleMultiple(-2);
668
+ // if (screenType === 'vertical' && playerFit === 'cover' && !hasPlayedRef.current) {
669
+ if (!hasPlayedRef.current) {
670
+ // 统一调整为1倍缩放,保证画面展示完全
671
+ setScaleMultiple(1);
679
672
  hasPlayedRef.current = true;
680
673
  }
681
674
  }
@@ -752,6 +745,11 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
752
745
  const onSetScaleMultiple = value => {
753
746
  setScaleMultiple(value);
754
747
  };
748
+ const onTrialCountdownEnd = useMemoizedFn(() => {
749
+ updatePlayerWidgetProps(instance, 'bottomLeft', 'TryExperience', {
750
+ buttonState: 2
751
+ });
752
+ });
755
753
  useEffect(() => {
756
754
  eventRef.current.on(startTimeToHideAllComponent, listenStart);
757
755
  eventRef.current.on(pauseTimeToHideAllComponent, listenPause);
@@ -761,6 +759,7 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
761
759
  eventRef.current.on('refreshBottomLeft', refreshBottomLeft);
762
760
  eventRef.current.on(changeIgnoreHideStopPreview, onChangeIgnoreHideStopPreview);
763
761
  eventRef.current.on(setScaleMultipleEvent, onSetScaleMultiple);
762
+ eventRef.current.on(trialCountdownEnd, onTrialCountdownEnd);
764
763
  return () => {
765
764
  eventRef.current.off(startTimeToHideAllComponent, listenStart);
766
765
  eventRef.current.off(pauseTimeToHideAllComponent, listenPause);
@@ -770,6 +769,7 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
770
769
  eventRef.current.off('refreshBottomLeft', refreshBottomLeft);
771
770
  eventRef.current.off(changeIgnoreHideStopPreview, onChangeIgnoreHideStopPreview);
772
771
  eventRef.current.off(setScaleMultipleEvent, onSetScaleMultiple);
772
+ eventRef.current.off(trialCountdownEnd, onTrialCountdownEnd);
773
773
  if (multiTapTimerRef.current) {
774
774
  clearTimeout(multiTapTimerRef.current);
775
775
  multiTapTimerRef.current = null;
@@ -784,14 +784,6 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
784
784
  /**
785
785
  * 监听当前的zoom比例状态
786
786
  */
787
- // useEffect(() => {
788
- // if (screenType === 'vertical') {
789
- // console.log(currentZoomLevel, '竖屏时的缩放比例');
790
- // setVerticalZoomLevel(currentZoomLevel);
791
- // // setScaleMultiple(currentZoomLevel);
792
- // }
793
- // }, [screenType, currentZoomLevel]);
794
-
795
787
  const onZoomChange = useMemoizedFn(data => {
796
788
  const {
797
789
  zoomLevel,
@@ -802,30 +794,19 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
802
794
  if (zoomLevel === 0) {
803
795
  return false;
804
796
  }
805
- /**
806
- * 针对竖屏为cover模式时,横屏为standard模式时,主动设置缩放比例,避免因值不能正常变化
807
- */
808
- if (scaleMode === -2 && playerFit === 'cover' && screenType === 'vertical' && landscapeMode === 'standard') {
809
- console.log('dsadsadsad----', zoomLevel);
810
- setScaleMultiple(zoomLevel);
811
- }
812
797
  /**
813
798
  * 针对竖屏为contain模式时,横屏为fill模式时,主动设置缩放比例,避免因值不能正常变化
814
799
  */
815
- if (scaleMode === -1 && playerFit === 'contain' && screenType === 'vertical' && landscapeMode === 'fill') {
816
- setVerticalCoverZoom(zoomLevel);
817
- }
800
+ // if (
801
+ // scaleMode === -1 &&
802
+ // playerFit === 'contain' &&
803
+ // screenType === 'vertical' &&
804
+ // landscapeMode === 'fill'
805
+ // ) {
806
+ // setVerticalCoverZoom(zoomLevel);
807
+ // }
818
808
 
819
- /**
820
- * 横屏情况下 针对竖屏为contain模式时,横屏为fill模式时,主动设置缩放比例,避免因值不能正常变化
821
- */
822
- if (scaleMode === -2 && playerFit === 'cover' && screenType !== 'vertical' && landscapeMode === 'standard') {
823
- setScaleMultiple(zoomLevel);
824
- }
825
- if (scaleMode === -1 && playerFit === 'contain' && screenType !== 'vertical' && landscapeMode === 'fill') {
826
- setVerticalCoverZoom(zoomLevel);
827
- setScaleMultiple(zoomLevel);
828
- }
809
+ // 直接记录当前缩放比例
829
810
  setCurrentZoomLevel(zoomLevel);
830
811
  instance.event.emit(zoomLevelChange, zoomLevel);
831
812
  return false;
package/lib/utils/ttt.js CHANGED
@@ -1,83 +1,119 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
2
  export function getSmartImageQualityState(devId) {
3
- // const mockData: SmartImageQualityResult = {
4
- // isPurchase: false,
5
- // buttonState: 1,
6
- // trialRemainingSec: 200,
7
- // canOpenSettings: false,
8
- // };
9
- // if (typeof ty?.ipc?.getSmartImageQualityState !== 'function') {
10
- // console.log('res===getSmartImageQualityState not exist, use mockData', mockData);
11
- // return Promise.resolve(mockData);
12
- // }
13
3
  return new Promise((resolve, reject) => {
14
- ty.ipc.getSmartImageQualityState({
15
- devId,
16
- scene: 'inPreview',
17
- success: data => {
18
- console.log('res===getSmartImageQualityState data', data);
19
- resolve(data);
20
- },
21
- fail: e => {
22
- console.warn('res===getSmartImageQualityState fail', e);
23
- reject(e);
24
- }
25
- });
4
+ var _ty;
5
+ if (typeof ((_ty = ty) === null || _ty === void 0 || (_ty = _ty.ipc) === null || _ty === void 0 ? void 0 : _ty.getSmartImageQualityState) !== 'function') {
6
+ reject(new Error('getSmartImageQualityState is not supported'));
7
+ return;
8
+ }
9
+ try {
10
+ ty.ipc.getSmartImageQualityState({
11
+ devId,
12
+ scene: 'inPreview',
13
+ success: data => {
14
+ console.log('res===getSmartImageQualityState data', data);
15
+ resolve(data);
16
+ },
17
+ fail: e => {
18
+ console.warn('res===getSmartImageQualityState fail', e);
19
+ reject(e);
20
+ }
21
+ });
22
+ } catch (e) {
23
+ console.warn('res===getSmartImageQualityState exception', e);
24
+ reject(e);
25
+ }
26
26
  });
27
27
  }
28
28
  export function getAIFrameFeature(devId) {
29
29
  return new Promise((resolve, reject) => {
30
- ty.ipc.getAIFrameFeature({
31
- devId,
32
- success: data => {
33
- console.log('res===getAIFrameFeature data', data);
34
- resolve(data);
35
- },
36
- fail: e => {
37
- console.warn('res===getAIFrameFeature fail', e);
38
- reject(e);
39
- }
40
- });
30
+ var _ty2;
31
+ if (typeof ((_ty2 = ty) === null || _ty2 === void 0 || (_ty2 = _ty2.ipc) === null || _ty2 === void 0 ? void 0 : _ty2.getAIFrameFeature) !== 'function') {
32
+ reject(new Error('getAIFrameFeature is not supported'));
33
+ return;
34
+ }
35
+ try {
36
+ ty.ipc.getAIFrameFeature({
37
+ devId,
38
+ success: data => {
39
+ console.log('res===getAIFrameFeature data', data);
40
+ resolve(data);
41
+ },
42
+ fail: e => {
43
+ console.warn('res===getAIFrameFeature fail', e);
44
+ reject(e);
45
+ }
46
+ });
47
+ } catch (e) {
48
+ console.warn('res===getAIFrameFeature exception', e);
49
+ reject(e);
50
+ }
41
51
  });
42
52
  }
43
53
  export function setAIFrameFeature(params) {
44
54
  return new Promise((resolve, reject) => {
45
- ty.ipc.setAIFrameFeature(_objectSpread(_objectSpread({}, params), {}, {
46
- success: data => {
47
- console.log('res===setAIFrameFeature data', data);
48
- resolve(data);
49
- },
50
- fail: e => {
51
- console.warn('res===setAIFrameFeature fail', e);
52
- reject(e);
53
- }
54
- }));
55
+ var _ty3;
56
+ if (typeof ((_ty3 = ty) === null || _ty3 === void 0 || (_ty3 = _ty3.ipc) === null || _ty3 === void 0 ? void 0 : _ty3.setAIFrameFeature) !== 'function') {
57
+ reject(new Error('setAIFrameFeature is not supported'));
58
+ return;
59
+ }
60
+ try {
61
+ ty.ipc.setAIFrameFeature(_objectSpread(_objectSpread({}, params), {}, {
62
+ success: data => {
63
+ console.log('res===setAIFrameFeature data', data);
64
+ resolve(data);
65
+ },
66
+ fail: e => {
67
+ console.warn('res===setAIFrameFeature fail', e);
68
+ reject(e);
69
+ }
70
+ }));
71
+ } catch (e) {
72
+ console.warn('res===setAIFrameFeature exception', e);
73
+ reject(e);
74
+ }
55
75
  });
56
76
  }
57
77
  export function getDeviceInfoRay(devId) {
58
78
  return new Promise((resolve, reject) => {
59
- var _ty$device;
60
- (_ty$device = ty.device) === null || _ty$device === void 0 || _ty$device.getDeviceInfo({
61
- deviceId: devId,
62
- success: res => {
63
- resolve(res);
64
- },
65
- fail: error => {
66
- reject(error);
67
- }
68
- });
79
+ var _ty4;
80
+ if (typeof ((_ty4 = ty) === null || _ty4 === void 0 || (_ty4 = _ty4.device) === null || _ty4 === void 0 ? void 0 : _ty4.getDeviceInfo) !== 'function') {
81
+ reject(new Error('getDeviceInfo is not supported'));
82
+ return;
83
+ }
84
+ try {
85
+ ty.device.getDeviceInfo({
86
+ deviceId: devId,
87
+ success: res => {
88
+ resolve(res);
89
+ },
90
+ fail: error => {
91
+ reject(error);
92
+ }
93
+ });
94
+ } catch (e) {
95
+ reject(e);
96
+ }
69
97
  });
70
98
  }
71
99
  export function getCurrentHomeInfoRay() {
72
100
  return new Promise((resolve, reject) => {
73
- var _ty$home;
74
- (_ty$home = ty.home) === null || _ty$home === void 0 || _ty$home.getCurrentHomeInfo({
75
- success: res => {
76
- resolve(res);
77
- },
78
- fail: error => {
79
- reject(error);
80
- }
81
- });
101
+ var _ty5;
102
+ if (typeof ((_ty5 = ty) === null || _ty5 === void 0 || (_ty5 = _ty5.home) === null || _ty5 === void 0 ? void 0 : _ty5.getCurrentHomeInfo) !== 'function') {
103
+ reject(new Error('getCurrentHomeInfo is not supported'));
104
+ return;
105
+ }
106
+ try {
107
+ ty.home.getCurrentHomeInfo({
108
+ success: res => {
109
+ resolve(res);
110
+ },
111
+ fail: error => {
112
+ reject(error);
113
+ }
114
+ });
115
+ } catch (e) {
116
+ reject(e);
117
+ }
82
118
  });
83
119
  }
@@ -1,6 +1,7 @@
1
1
  import { useCallback, useEffect, useState } from 'react';
2
- import { getAIFrameFeature, getCurrentHomeInfoRay, getDeviceInfoRay, setAIFrameFeature } from '../../utils/ttt';
2
+ import { getCurrentHomeInfoRay, getDeviceInfoRay } from '../../utils/ttt';
3
3
  import { gotoSecurityCloudService } from '../../utils';
4
+ import { trialCountdownEnd } from '../../ui/constant';
4
5
  import Strings from '../../i18n';
5
6
  export const useTrialBadge = (event, devId, trialRemainingSec) => {
6
7
  const [showTrialBadge, setShowTrialBadge] = useState(false);
@@ -25,14 +26,9 @@ export const useTrialBadge = (event, devId, trialRemainingSec) => {
25
26
  }, [devId]);
26
27
  const handleCountdownEnd = useCallback(async () => {
27
28
  try {
28
- const getAI = await getAIFrameFeature(devId);
29
- console.log('res===handleCountdownEnd', getAI);
30
- setAIFrameFeature({
31
- devId,
32
- enabled: false,
33
- aiFrameFeature: getAI.aiFrameFeature
34
- });
29
+ console.log('res===handleCountdownEnd');
35
30
  setShowTrialBadge(false);
31
+ event.emit(trialCountdownEnd);
36
32
  } catch (error) {
37
33
  ty.showToast({
38
34
  title: Strings.getLang('ipc_player_fetch_error'),
@@ -41,21 +41,20 @@ export const TryExperience = props => {
41
41
  const {
42
42
  className,
43
43
  hideTryExperienceMenu,
44
- buttonState = 0
44
+ buttonState
45
45
  } = props;
46
46
  const {
47
47
  brandColor
48
48
  } = useStore({
49
49
  brandColor: props.brandColor
50
50
  });
51
- const iconUrl = pickIconByStatus(buttonState);
52
51
  if (hideTryExperienceMenu) {
53
52
  return null;
54
53
  }
54
+ const iconUrl = pickIconByStatus(buttonState);
55
55
  return /*#__PURE__*/React.createElement(View, {
56
56
  className: clsx(className),
57
57
  onClick: () => {
58
- console.log('res===onTryExperience', props.devId, brandColor);
59
58
  gotoAIDrawMiniProgram(props.devId, brandColor);
60
59
  }
61
60
  }, /*#__PURE__*/React.createElement(View, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/ipc-player-integration",
3
- "version": "0.0.35-beta.4",
3
+ "version": "0.0.35-beta.6",
4
4
  "description": "IPC 融合播放器",
5
5
  "main": "lib/index",
6
6
  "files": [
@@ -64,7 +64,7 @@
64
64
  "husky": {
65
65
  "hooks": {
66
66
  "commit-msg": "commitlint -E HUSKY_GIT_PARAMS --config commitlint.config.js",
67
- "pre-commit": "lint-staged"
67
+ "pre-commit": "node ./scripts/check-protected-files.js && lint-staged"
68
68
  }
69
69
  },
70
70
  "lint-staged": {