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

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';
@@ -427,7 +427,6 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
427
427
  }, [brandColor, verticalMic]);
428
428
  const refreshSmartImageQuality = useMemoizedFn(() => {
429
429
  getSmartImageQualityState(devId).then(res => {
430
- console.log('res===getSmartImageQualityState', res);
431
430
  updatePlayerWidgetProps(instance, 'bottomLeft', 'TryExperience', {
432
431
  buttonState: res.buttonState,
433
432
  trialRemainingSec: res.trialRemainingSec,
@@ -436,8 +435,10 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
436
435
  });
437
436
  });
438
437
  useEffect(() => {
439
- refreshSmartImageQuality();
440
- }, [instance]);
438
+ if (playState === PlayState.PLAYING) {
439
+ refreshSmartImageQuality();
440
+ }
441
+ }, [playState]);
441
442
  const refreshBottomLeft = () => {
442
443
  event.current.emit(startTimeToHideAllComponent);
443
444
  event.current.emit(showAllComponent);
@@ -752,6 +753,11 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
752
753
  const onSetScaleMultiple = value => {
753
754
  setScaleMultiple(value);
754
755
  };
756
+ const onTrialCountdownEnd = useMemoizedFn(() => {
757
+ updatePlayerWidgetProps(instance, 'bottomLeft', 'TryExperience', {
758
+ buttonState: 2
759
+ });
760
+ });
755
761
  useEffect(() => {
756
762
  eventRef.current.on(startTimeToHideAllComponent, listenStart);
757
763
  eventRef.current.on(pauseTimeToHideAllComponent, listenPause);
@@ -761,6 +767,7 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
761
767
  eventRef.current.on('refreshBottomLeft', refreshBottomLeft);
762
768
  eventRef.current.on(changeIgnoreHideStopPreview, onChangeIgnoreHideStopPreview);
763
769
  eventRef.current.on(setScaleMultipleEvent, onSetScaleMultiple);
770
+ eventRef.current.on(trialCountdownEnd, onTrialCountdownEnd);
764
771
  return () => {
765
772
  eventRef.current.off(startTimeToHideAllComponent, listenStart);
766
773
  eventRef.current.off(pauseTimeToHideAllComponent, listenPause);
@@ -770,6 +777,7 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
770
777
  eventRef.current.off('refreshBottomLeft', refreshBottomLeft);
771
778
  eventRef.current.off(changeIgnoreHideStopPreview, onChangeIgnoreHideStopPreview);
772
779
  eventRef.current.off(setScaleMultipleEvent, onSetScaleMultiple);
780
+ eventRef.current.off(trialCountdownEnd, onTrialCountdownEnd);
773
781
  if (multiTapTimerRef.current) {
774
782
  clearTimeout(multiTapTimerRef.current);
775
783
  multiTapTimerRef.current = null;
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.5",
4
4
  "description": "IPC 融合播放器",
5
5
  "main": "lib/index",
6
6
  "files": [