@ray-js/ipc-player-integration 0.0.34 → 0.0.35-beta.2

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 (45) hide show
  1. package/lib/ctx/ctx.composition.js +11 -1
  2. package/lib/features/initPlayerWidgets/index.d.ts +7 -0
  3. package/lib/features/initPlayerWidgets/index.js +11 -0
  4. package/lib/i18n/index.d.ts +16 -0
  5. package/lib/i18n/strings.d.ts +8 -0
  6. package/lib/i18n/strings.js +10 -2
  7. package/lib/interface.d.ts +1 -1
  8. package/lib/res/try/try_close.png +0 -0
  9. package/lib/res/try/try_en.png +0 -0
  10. package/lib/res/try/try_open.png +0 -0
  11. package/lib/res/try/try_zh.png +0 -0
  12. package/lib/ui/bottomLeftContent.d.ts +3 -1
  13. package/lib/ui/bottomLeftContent.js +78 -8
  14. package/lib/ui/bottomRightContent.d.ts +3 -1
  15. package/lib/ui/bottomRightContent.js +11 -4
  16. package/lib/ui/constant.d.ts +10 -0
  17. package/lib/ui/constant.js +12 -0
  18. package/lib/ui/index.d.ts +1 -1
  19. package/lib/ui/index.js +1 -1
  20. package/lib/ui/ui.d.ts +1 -0
  21. package/lib/ui/ui.js +21 -5
  22. package/lib/ui/ui.less +5 -1
  23. package/lib/widgets/floodlight/floodlight.d.ts +4 -0
  24. package/lib/widgets/floodlight/floodlight.js +55 -0
  25. package/lib/widgets/floodlight/floodlight.less +4 -0
  26. package/lib/widgets/floodlight/index.d.ts +1 -0
  27. package/lib/widgets/floodlight/index.js +1 -0
  28. package/lib/widgets/index.d.ts +4 -0
  29. package/lib/widgets/index.js +4 -0
  30. package/lib/widgets/siren/index.d.ts +1 -0
  31. package/lib/widgets/siren/index.js +1 -0
  32. package/lib/widgets/siren/siren.d.ts +4 -0
  33. package/lib/widgets/siren/siren.js +55 -0
  34. package/lib/widgets/siren/siren.less +4 -0
  35. package/lib/widgets/trialBadge/index.d.ts +15 -0
  36. package/lib/widgets/trialBadge/index.js +86 -0
  37. package/lib/widgets/trialBadge/index.less +57 -0
  38. package/lib/widgets/trialBadge/useTrialBadge.d.ts +16 -0
  39. package/lib/widgets/trialBadge/useTrialBadge.js +41 -0
  40. package/lib/widgets/tryExperience/index.d.ts +1 -0
  41. package/lib/widgets/tryExperience/index.js +1 -0
  42. package/lib/widgets/tryExperience/tryExperience.d.ts +10 -0
  43. package/lib/widgets/tryExperience/tryExperience.js +71 -0
  44. package/lib/widgets/tryExperience/tryExperience.less +13 -0
  45. package/package.json +2 -2
@@ -4,7 +4,7 @@ const _excluded = ["title", "duration"];
4
4
  import { getCameraConfigInfo } from '@ray-js/ray-ipc-utils';
5
5
  import { IntercomMode, MuteMode, ClarityType } from '@ray-js/ray-ipc-utils/lib/interface';
6
6
  import { createUseCtx } from './ctx';
7
- import { FullSmallIntercom, VerticalSmallIntercom, BatteryFull, Battery, Screenshot, TempHumidity, Signal4G, RecordVideo, FullScreen, VideoBitKBP, Muted, Resolution, Ptz, MultiPtz, TileTip, PtzMoveableTip, LandscapeTip, TileActions, MoveablePtzControl, SwitchLayout, ToggleVerticalFull, RealTimeMagnification } from '../widgets';
7
+ import { FullSmallIntercom, VerticalSmallIntercom, BatteryFull, Battery, Screenshot, TempHumidity, Signal4G, RecordVideo, FullScreen, VideoBitKBP, Muted, Floodlight, Siren, TryExperience, Resolution, Ptz, MultiPtz, TileTip, PtzMoveableTip, LandscapeTip, TileActions, MoveablePtzControl, SwitchLayout, ToggleVerticalFull, RealTimeMagnification } from '../widgets';
8
8
  import { authorizeStatus } from '../utils/authorize';
9
9
  import { landscapeTipId, moveablePtzControlId, multiPtzId, ptzMoveableTipId, tileActionsId, tileTipId } from '../ui/constant';
10
10
  import { multiPrefix } from '../widgets/multiCamera/constants';
@@ -41,6 +41,16 @@ export const defaultBottomLeftContent = [{
41
41
  }, {
42
42
  id: 'Muted',
43
43
  content: Muted
44
+ }, {
45
+ id: 'Floodlight',
46
+ content: Floodlight
47
+ }, {
48
+ id: 'Siren',
49
+ content: Siren
50
+ }, /* TryExperience 必须紧跟 Muted,在 VerticalSmallIntercom 之前 */
51
+ {
52
+ id: 'TryExperience',
53
+ content: TryExperience
44
54
  }, {
45
55
  id: 'VerticalSmallIntercom',
46
56
  content: VerticalSmallIntercom
@@ -8,11 +8,18 @@ export type InitPlayerWidgetsOptions = {
8
8
  hideScreenShotMenu?: boolean;
9
9
  hideRecordVideoMenu?: boolean;
10
10
  hideResolutionMenu?: boolean;
11
+ hideTryExperienceMenu?: boolean;
11
12
  hideKbsMenu?: boolean;
12
13
  hideSignalMenu?: boolean;
13
14
  showToggleVerticalFull?: boolean;
14
15
  showRealTimeMagnification?: boolean;
15
16
  directionControlProps?: Partial<React.ComponentProps<typeof FullScreen>['directionControlProps']>;
17
+ smartImageQualityState?: {
18
+ isPurchase: boolean;
19
+ buttonState: number;
20
+ trialRemainingSec: number;
21
+ canOpenSettings: boolean;
22
+ };
16
23
  topLeftContent?: ComponentConfig[];
17
24
  topRightContent?: ComponentConfig[];
18
25
  bottomLeftContent?: ComponentConfig[];
@@ -17,8 +17,18 @@ export async function initPlayerWidgets(ctx, options) {
17
17
  }
18
18
  ctx.addContent('topRight', newDefaultTopRightContent);
19
19
  const resolutionIndex = newDefaultBottomLeftContent.findIndex(item => item.id === 'Resolution');
20
+ const tryExperienceIndex = newDefaultBottomLeftContent.findIndex(item => item.id === 'TryExperience');
20
21
  const screenShotIndex = newDefaultBottomLeftContent.findIndex(item => item.id === 'Screenshot');
21
22
  const recordVideoIndex = newDefaultBottomLeftContent.findIndex(item => item.id === 'RecordVideo');
23
+ if (tryExperienceIndex !== -1) {
24
+ var _options$smartImageQu, _options$smartImageQu2;
25
+ // @ts-ignore
26
+ newDefaultBottomLeftContent[tryExperienceIndex].initProps = {
27
+ hideTryExperienceMenu: options.hideTryExperienceMenu,
28
+ buttonState: (_options$smartImageQu = options.smartImageQualityState) === null || _options$smartImageQu === void 0 ? void 0 : _options$smartImageQu.buttonState,
29
+ trialRemainingSec: (_options$smartImageQu2 = options.smartImageQualityState) === null || _options$smartImageQu2 === void 0 ? void 0 : _options$smartImageQu2.trialRemainingSec
30
+ };
31
+ }
22
32
  if (resolutionIndex !== -1) {
23
33
  // @ts-ignore
24
34
  newDefaultBottomLeftContent[resolutionIndex].initProps = {
@@ -44,6 +54,7 @@ export async function initPlayerWidgets(ctx, options) {
44
54
  newDefaultBottomLeftContent[magnificationIndex].hidden = false;
45
55
  }
46
56
  }
57
+ console.log('res===1', newDefaultBottomLeftContent);
47
58
  ctx.addContent('bottomLeft', newDefaultBottomLeftContent);
48
59
  const newDefaultBottomRightContent = _cloneDeep(options.bottomRightContent || defaultBottomRightContent);
49
60
  const fullScreenIndex = newDefaultBottomRightContent.findIndex(item => item.id === 'FullScreen');
@@ -20,6 +20,7 @@ declare const Strings: kit.I18N<{
20
20
  ipc_player_authorize_confirm_text: string;
21
21
  ipc_player_error_record_tip: string;
22
22
  ipc_player_change_resolution_success: string;
23
+ ipc_player_try_experience: string;
23
24
  ipc_player_ptz_control_tip: string;
24
25
  ipc_player_ptz_close_control_tip: string;
25
26
  ipc_player_tile_tip_text_step1: string;
@@ -28,6 +29,9 @@ declare const Strings: kit.I18N<{
28
29
  ipc_player_tip_confirm: string;
29
30
  ipc_player_ptz_moveable_tip_text: string;
30
31
  ipc_player_flow_low_tip: string;
32
+ ipc_player_trial_in_use: string;
33
+ ipc_player_trial_preview_text: string;
34
+ ipc_player_trial_subscribe: string;
31
35
  };
32
36
  zh: {
33
37
  ipc_player_resolution_HD: string;
@@ -49,6 +53,7 @@ declare const Strings: kit.I18N<{
49
53
  ipc_player_authorize_confirm_text: string;
50
54
  ipc_player_error_record_tip: string;
51
55
  ipc_player_change_resolution_success: string;
56
+ ipc_player_try_experience: string;
52
57
  ipc_player_ptz_control_tip: string;
53
58
  ipc_player_ptz_close_control_tip: string;
54
59
  ipc_player_tile_tip_text_step1: string;
@@ -57,6 +62,9 @@ declare const Strings: kit.I18N<{
57
62
  ipc_player_tip_confirm: string;
58
63
  ipc_player_ptz_moveable_tip_text: string;
59
64
  ipc_player_flow_low_tip: string;
65
+ ipc_player_trial_in_use: string;
66
+ ipc_player_trial_preview_text: string;
67
+ ipc_player_trial_subscribe: string;
60
68
  };
61
69
  }, {
62
70
  ipc_player_resolution_HD: string;
@@ -78,6 +86,7 @@ declare const Strings: kit.I18N<{
78
86
  ipc_player_authorize_confirm_text: string;
79
87
  ipc_player_error_record_tip: string;
80
88
  ipc_player_change_resolution_success: string;
89
+ ipc_player_try_experience: string;
81
90
  ipc_player_ptz_control_tip: string;
82
91
  ipc_player_ptz_close_control_tip: string;
83
92
  ipc_player_tile_tip_text_step1: string;
@@ -86,6 +95,9 @@ declare const Strings: kit.I18N<{
86
95
  ipc_player_tip_confirm: string;
87
96
  ipc_player_ptz_moveable_tip_text: string;
88
97
  ipc_player_flow_low_tip: string;
98
+ ipc_player_trial_in_use: string;
99
+ ipc_player_trial_preview_text: string;
100
+ ipc_player_trial_subscribe: string;
89
101
  } | {
90
102
  ipc_player_resolution_HD: string;
91
103
  ipc_player_resolution_SD: string;
@@ -106,6 +118,7 @@ declare const Strings: kit.I18N<{
106
118
  ipc_player_authorize_confirm_text: string;
107
119
  ipc_player_error_record_tip: string;
108
120
  ipc_player_change_resolution_success: string;
121
+ ipc_player_try_experience: string;
109
122
  ipc_player_ptz_control_tip: string;
110
123
  ipc_player_ptz_close_control_tip: string;
111
124
  ipc_player_tile_tip_text_step1: string;
@@ -114,5 +127,8 @@ declare const Strings: kit.I18N<{
114
127
  ipc_player_tip_confirm: string;
115
128
  ipc_player_ptz_moveable_tip_text: string;
116
129
  ipc_player_flow_low_tip: string;
130
+ ipc_player_trial_in_use: string;
131
+ ipc_player_trial_preview_text: string;
132
+ ipc_player_trial_subscribe: string;
117
133
  }>;
118
134
  export default Strings;
@@ -19,6 +19,7 @@ declare const _default: {
19
19
  ipc_player_authorize_confirm_text: string;
20
20
  ipc_player_error_record_tip: string;
21
21
  ipc_player_change_resolution_success: string;
22
+ ipc_player_try_experience: string;
22
23
  ipc_player_ptz_control_tip: string;
23
24
  ipc_player_ptz_close_control_tip: string;
24
25
  ipc_player_tile_tip_text_step1: string;
@@ -27,6 +28,9 @@ declare const _default: {
27
28
  ipc_player_tip_confirm: string;
28
29
  ipc_player_ptz_moveable_tip_text: string;
29
30
  ipc_player_flow_low_tip: string;
31
+ ipc_player_trial_in_use: string;
32
+ ipc_player_trial_preview_text: string;
33
+ ipc_player_trial_subscribe: string;
30
34
  };
31
35
  zh: {
32
36
  ipc_player_resolution_HD: string;
@@ -48,6 +52,7 @@ declare const _default: {
48
52
  ipc_player_authorize_confirm_text: string;
49
53
  ipc_player_error_record_tip: string;
50
54
  ipc_player_change_resolution_success: string;
55
+ ipc_player_try_experience: string;
51
56
  ipc_player_ptz_control_tip: string;
52
57
  ipc_player_ptz_close_control_tip: string;
53
58
  ipc_player_tile_tip_text_step1: string;
@@ -56,6 +61,9 @@ declare const _default: {
56
61
  ipc_player_tip_confirm: string;
57
62
  ipc_player_ptz_moveable_tip_text: string;
58
63
  ipc_player_flow_low_tip: string;
64
+ ipc_player_trial_in_use: string;
65
+ ipc_player_trial_preview_text: string;
66
+ ipc_player_trial_subscribe: string;
59
67
  };
60
68
  };
61
69
  export default _default;
@@ -19,6 +19,7 @@ export default {
19
19
  ipc_player_authorize_confirm_text: 'Go to Settings',
20
20
  ipc_player_error_record_tip: 'The recording has failed, please try again later.',
21
21
  ipc_player_change_resolution_success: 'Switch successful',
22
+ ipc_player_try_experience: 'Try it',
22
23
  ipc_player_ptz_control_tip: 'Swipe up, down, left, or right to control the PTZ direction.',
23
24
  ipc_player_ptz_close_control_tip: 'Close',
24
25
  ipc_player_tile_tip_text_step1: 'Click here to expand/collapse the player',
@@ -26,7 +27,10 @@ export default {
26
27
  ipc_player_tip_next: 'Next',
27
28
  ipc_player_tip_confirm: 'Got it',
28
29
  ipc_player_ptz_moveable_tip_text: 'Hold the middle to drag the direction control area',
29
- ipc_player_flow_low_tip: 'The device’s remaining data is below 200MB. Please recharge as soon as possible.'
30
+ ipc_player_flow_low_tip: 'The device’s remaining data is below 200MB. Please recharge as soon as possible.',
31
+ ipc_player_trial_in_use: 'Trial',
32
+ ipc_player_trial_preview_text: 'Preview',
33
+ ipc_player_trial_subscribe: 'Open'
30
34
  },
31
35
  zh: {
32
36
  ipc_player_resolution_HD: '高清',
@@ -48,6 +52,7 @@ export default {
48
52
  ipc_player_authorize_confirm_text: '去设置',
49
53
  ipc_player_error_record_tip: '录制出错了,请稍后再试',
50
54
  ipc_player_change_resolution_success: '切换成功',
55
+ ipc_player_try_experience: '去体验',
51
56
  ipc_player_ptz_control_tip: '上下左右滑动,控制云台方向',
52
57
  ipc_player_ptz_close_control_tip: '关闭',
53
58
  ipc_player_tile_tip_text_step1: '点击此处可展开/收起播放窗口',
@@ -55,6 +60,9 @@ export default {
55
60
  ipc_player_tip_next: '下一步',
56
61
  ipc_player_tip_confirm: '知道了',
57
62
  ipc_player_ptz_moveable_tip_text: '长按中间可拖动方向控制区域',
58
- ipc_player_flow_low_tip: '设备当前剩余流量不足200M,请尽快充值'
63
+ ipc_player_flow_low_tip: '设备当前剩余流量不足200M,请尽快充值',
64
+ ipc_player_trial_in_use: '试用中',
65
+ ipc_player_trial_preview_text: '试看剩余',
66
+ ipc_player_trial_subscribe: '开通'
59
67
  }
60
68
  };
@@ -11,7 +11,7 @@ export type IpcContext = {
11
11
  };
12
12
  export type RetAtom<T> = PrimitiveAtom<T> & WithInitialValue<T>;
13
13
  export type ScreenType = 'full' | 'vertical';
14
- export type WidgetId = 'BatteryFull' | 'TempHumidity' | 'VideoBitKBP' | 'FullSmallIntercom' | 'Screenshot' | 'RecordVideo' | 'Muted' | 'VerticalSmallIntercom' | 'Ptz' | 'Resolution' | 'FullScreen' | 'moveablePtzControlId';
14
+ export type WidgetId = 'BatteryFull' | 'TempHumidity' | 'VideoBitKBP' | 'FullSmallIntercom' | 'Screenshot' | 'RecordVideo' | 'Muted' | 'Floodlight' | 'Siren' | 'TryExperience' | 'VerticalSmallIntercom' | 'Ptz' | 'Resolution' | 'FullScreen' | 'moveablePtzControlId';
15
15
  export declare const enum PlayerStreamStatus {
16
16
  UnknownException = -1000,
17
17
  ConnectSuccess = 1001,
Binary file
Binary file
Binary file
Binary file
@@ -3,6 +3,8 @@ import { UseCtx } from '../interface';
3
3
  type Props = {
4
4
  ctx: ReturnType<UseCtx>;
5
5
  children: React.ReactNode;
6
+ /** 右下角组件占据的宽度(px),左下角通过该值约束自身可视宽度,避免与右下角重叠 */
7
+ reservedRight?: number;
6
8
  };
7
- declare const BottomLeftContent: ({ ctx, children }: Props) => React.JSX.Element;
9
+ declare const BottomLeftContent: ({ ctx, children, reservedRight }: Props) => React.JSX.Element;
8
10
  export default BottomLeftContent;
@@ -1,30 +1,100 @@
1
- import React from 'react';
1
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
+ import "core-js/modules/esnext.iterator.constructor.js";
3
+ import "core-js/modules/esnext.iterator.find.js";
4
+ import React, { useMemo } from 'react';
2
5
  import { CoverView, View } from '@ray-js/ray';
3
6
  import clsx from 'clsx';
4
7
  import { useStore } from '../ctx/store';
5
8
  import { useComponentHideState } from './hooks';
9
+ import { TrialBadge, useTrialBadge } from '../widgets/trialBadge';
10
+ /** 右侧透明渐变宽度,用于提示横向可滑动 */
11
+ const FADE_MASK = 'linear-gradient(to right, #000 calc(100% - 16px), transparent 100%)';
12
+
13
+ /**
14
+ * 试用徽章在不同 screenType 下的容器样式。
15
+ * 「贴在底栏顶部」的策略一致(bottom: 100%),只是 left / marginBottom
16
+ * 等数值按横竖屏不同的边距规则做差异化处理。
17
+ */
18
+ const TRIAL_BADGE_WRAP_STYLE_VERTICAL = {
19
+ position: 'absolute',
20
+ left: '0px',
21
+ bottom: '100%',
22
+ marginBottom: 4,
23
+ zIndex: 2,
24
+ width: 'max-content'
25
+ };
26
+ const TRIAL_BADGE_WRAP_STYLE_FULL = {
27
+ position: 'absolute',
28
+ left: '25px',
29
+ bottom: '100%',
30
+ marginBottom: 8,
31
+ zIndex: 2,
32
+ width: 'max-content'
33
+ };
6
34
  const BottomLeftContent = _ref => {
7
35
  let {
8
36
  ctx,
9
- children
37
+ children,
38
+ reservedRight = 0
10
39
  } = _ref;
11
40
  const {
12
- screenType
41
+ screenType,
42
+ brandColor,
43
+ bottomLeftContent
13
44
  } = useStore({
14
45
  screenType: ctx.screenType,
15
- playState: ctx.playState
46
+ playState: ctx.playState,
47
+ brandColor: ctx.brandColor,
48
+ bottomLeftContent: ctx.bottomLeftContent
16
49
  });
50
+ const trialRemainingSec = useMemo(() => {
51
+ var _trialRemainingSec, _tryExp$initProps;
52
+ const tryExp = bottomLeftContent === null || bottomLeftContent === void 0 ? void 0 : bottomLeftContent.find(item => item.id === 'TryExperience');
53
+ return (_trialRemainingSec = tryExp === null || tryExp === void 0 || (_tryExp$initProps = tryExp.initProps) === null || _tryExp$initProps === void 0 ? void 0 : _tryExp$initProps.trialRemainingSec) !== null && _trialRemainingSec !== void 0 ? _trialRemainingSec : 0;
54
+ }, [bottomLeftContent]);
17
55
  const [shouldHide] = useComponentHideState();
56
+
57
+ // 横竖屏共用同一份徽章状态、回调;TrialBadge 实例不随 screenType 切换而重挂载,
58
+ // 倒计时与可见性可在横竖屏切换之间保持一致
59
+ const {
60
+ showTrialBadge,
61
+ handleTrialSubscribe,
62
+ handleCountdownEnd
63
+ } = useTrialBadge(ctx.event, trialRemainingSec);
64
+ const paddingLeftPx = screenType === 'vertical' ? 0 : 25;
65
+ const trialBadgeWrapStyle = screenType === 'vertical' ? TRIAL_BADGE_WRAP_STYLE_VERTICAL : TRIAL_BADGE_WRAP_STYLE_FULL;
18
66
  return /*#__PURE__*/React.createElement(CoverView, {
19
- className: clsx('ipc-player-bottom-left-content-wrap'),
67
+ className: clsx('ipc-player-bottom-left-content-wrap')
68
+ // 注意:不要在这里覆盖 position,CSS 类已经设置 position: absolute; left: 0; bottom: 0
69
+ // 否则 children 会失去贴底定位,从而与 bottomRightContent 不对齐
70
+ ,
20
71
  style: {
21
- paddingRight: screenType === 'vertical' ? '0' : '50px',
72
+ right: `${reservedRight}px`,
22
73
  height: screenType === 'vertical' ? shouldHide ? '41px' : '40px' : shouldHide ? '57px' : '58px'
23
74
  }
24
- }, /*#__PURE__*/React.createElement(View, {
75
+ }, showTrialBadge && /*#__PURE__*/React.createElement(View, {
76
+ className: clsx('bottom-left-item-container'),
77
+ style: _objectSpread(_objectSpread({}, trialBadgeWrapStyle), {}, {
78
+ transform: shouldHide ? 'translateY(40px)' : 'translateY(0)',
79
+ opacity: shouldHide ? 0 : 1,
80
+ transition: 'transform 0.3s ease-in-out, opacity 0.3s ease-in-out'
81
+ })
82
+ }, /*#__PURE__*/React.createElement(TrialBadge, {
83
+ brandColor: brandColor,
84
+ trialRemainingSec: trialRemainingSec,
85
+ onSubscribe: handleTrialSubscribe,
86
+ onCountdownEnd: handleCountdownEnd
87
+ })), /*#__PURE__*/React.createElement(View, {
25
88
  style: {
26
89
  paddingBottom: screenType === 'vertical' ? '14px' : '32px',
27
- paddingLeft: screenType === 'vertical' ? 0 : '25px'
90
+ paddingLeft: `${paddingLeftPx}px`,
91
+ width: '100%',
92
+ overflowX: 'auto',
93
+ overflowY: 'hidden',
94
+ whiteSpace: 'nowrap',
95
+ WebkitOverflowScrolling: 'touch',
96
+ WebkitMaskImage: FADE_MASK,
97
+ maskImage: FADE_MASK
28
98
  },
29
99
  className: clsx('ipc-player-bottom-left-content-container', {
30
100
  // 'ipc-player-bottom-left-content-hide': shouldHide,
@@ -3,6 +3,8 @@ import { UseCtx } from '../interface';
3
3
  type Props = {
4
4
  ctx: ReturnType<UseCtx>;
5
5
  children: React.ReactNode;
6
+ /** 由 ui.tsx 计算得到的右下角组件宽度(与左下角的 reservedRight 保持一致) */
7
+ width?: number;
6
8
  };
7
- declare const BottomRightContent: ({ ctx, children }: Props) => React.JSX.Element;
9
+ declare const BottomRightContent: ({ ctx, children, width }: Props) => React.JSX.Element;
8
10
  export default BottomRightContent;
@@ -1,3 +1,4 @@
1
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
1
2
  import React from 'react';
2
3
  import { CoverView, View } from '@ray-js/ray';
3
4
  import clsx from 'clsx';
@@ -6,7 +7,8 @@ import { useComponentHideState } from './hooks';
6
7
  const BottomRightContent = _ref => {
7
8
  let {
8
9
  ctx,
9
- children
10
+ children,
11
+ width
10
12
  } = _ref;
11
13
  const {
12
14
  screenType
@@ -17,14 +19,19 @@ const BottomRightContent = _ref => {
17
19
  const [shouldHide] = useComponentHideState();
18
20
  return /*#__PURE__*/React.createElement(CoverView, {
19
21
  className: clsx('ipc-player-bottom-right-content-wrap'),
20
- style: {
22
+ style: _objectSpread({
21
23
  paddingLeft: screenType === 'vertical' ? '10px' : '0',
22
24
  height: screenType === 'vertical' ? shouldHide ? '41px' : '40px' : shouldHide ? '57px' : '58px'
23
- }
25
+ }, typeof width === 'number' && width > 0 ? {
26
+ width: `${width}px`,
27
+ boxSizing: 'border-box'
28
+ } : null)
24
29
  }, /*#__PURE__*/React.createElement(View, {
25
30
  style: {
26
31
  paddingBottom: screenType === 'vertical' ? '14px' : '32px',
27
- paddingRight: screenType === 'vertical' ? 0 : '25px'
32
+ paddingRight: screenType === 'vertical' ? 0 : '25px',
33
+ width: '100%',
34
+ justifyContent: 'flex-end'
28
35
  },
29
36
  className: clsx('ipc-player-bottom-right-content-container', {
30
37
  // 'ipc-player-bottom-right-content-hide': shouldHide,
@@ -21,13 +21,23 @@ 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
+ /**
27
+ * 试看倒计时结束事件:试看徽章倒计时归零时触发,
28
+ * 业务侧/相关控件可监听此事件刷新自己的状态(例如 TryExperience 重新拉取状态)
29
+ */
30
+ export declare const trialCountdownEnd = "trialCountdownEnd";
24
31
  /** 控件点击事件用的 widgetId,统一在此维护 */
25
32
  export declare const widgetLabs: {
26
33
  readonly SCREENSHOT: "Screenshot";
27
34
  readonly RECORD_VIDEO: "RecordVideo";
28
35
  readonly RESOLUTION: "Resolution";
36
+ readonly TRY_EXPERIENCE: "TryExperience";
29
37
  readonly FULL_RESOLUTION_CONTROL: "FullResolutionControl";
30
38
  readonly MUTED: "Muted";
39
+ readonly FLOODLIGHT: "Floodlight";
40
+ readonly SIREN: "Siren";
31
41
  readonly PTZ: "Ptz";
32
42
  readonly PTZ_CONTROL_TIP: "PtzControlTip";
33
43
  readonly MOVE_INTERACTIVE_CONTROL: "MoveInteractiveControl";
@@ -22,13 +22,25 @@ export const multiPtzId = 'multiPtzId';
22
22
  /** 控件点击统一事件:任意播放器内控件被点击时触发,可用于埋点或统一处理 */
23
23
  export const widgetClick = 'widgetClick';
24
24
 
25
+ /** 「去体验」按钮业务事件,与清晰度 resolutionBtnControlClick 用法一致 */
26
+ export const tryExperienceBtnClick = 'tryExperienceBtnClick';
27
+
28
+ /**
29
+ * 试看倒计时结束事件:试看徽章倒计时归零时触发,
30
+ * 业务侧/相关控件可监听此事件刷新自己的状态(例如 TryExperience 重新拉取状态)
31
+ */
32
+ export const trialCountdownEnd = 'trialCountdownEnd';
33
+
25
34
  /** 控件点击事件用的 widgetId,统一在此维护 */
26
35
  export const widgetLabs = {
27
36
  SCREENSHOT: 'Screenshot',
28
37
  RECORD_VIDEO: 'RecordVideo',
29
38
  RESOLUTION: 'Resolution',
39
+ TRY_EXPERIENCE: 'TryExperience',
30
40
  FULL_RESOLUTION_CONTROL: 'FullResolutionControl',
31
41
  MUTED: 'Muted',
42
+ FLOODLIGHT: 'Floodlight',
43
+ SIREN: 'Siren',
32
44
  PTZ: 'Ptz',
33
45
  PTZ_CONTROL_TIP: 'PtzControlTip',
34
46
  MOVE_INTERACTIVE_CONTROL: 'MoveInteractiveControl',
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 } from './constant';
6
+ export { widgetLabs, tryExperienceBtnClick, 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 } from './constant';
5
+ export { widgetLabs, tryExperienceBtnClick, trialCountdownEnd } from './constant';
package/lib/ui/ui.d.ts CHANGED
@@ -37,6 +37,7 @@ type Props = {
37
37
  showFlowLowTip?: boolean;
38
38
  extend?: Record<string, any>;
39
39
  refreshElement?: boolean;
40
+ autoWakeUp?: boolean;
40
41
  };
41
42
  export declare const IPCPlayerIntegration: React.MemoExoticComponent<(props: Props) => React.JSX.Element>;
42
43
  export {};
package/lib/ui/ui.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
2
  import "core-js/modules/esnext.iterator.constructor.js";
3
+ import "core-js/modules/esnext.iterator.filter.js";
3
4
  import "core-js/modules/esnext.iterator.map.js";
4
5
  import React, { useContext, useState, useRef, useMemo, useEffect, useImperativeHandle } from 'react';
5
6
  import { View, CoverView, getSystemInfoSync, usePageEvent, setNavigationBarBack, setPageOrientation, getCurrentPages } from '@ray-js/ray';
@@ -67,7 +68,8 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
67
68
  limitFlow = false,
68
69
  showFlowLowTip = false,
69
70
  extend = {},
70
- refreshElement = false
71
+ refreshElement = false,
72
+ autoWakeUp = false
71
73
  } = props;
72
74
  const {
73
75
  event
@@ -621,7 +623,18 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
621
623
  // 添加通用变量单独组件类名
622
624
  className: clsx('bottom-right-item-container')
623
625
  })));
624
- }, [bottomLeftContent, instance]);
626
+ }, [bottomRightContent, instance]);
627
+
628
+ /**
629
+ * 右下角可见按钮数 → 右下角组件宽度(左下角同时用作右侧预留宽度)
630
+ * 1 个按钮: 115px / 2 个按钮: 132px / 0 个按钮: 0
631
+ */
632
+ const bottomRightWidth = useMemo(() => {
633
+ const visibleCount = (bottomRightContent || []).filter(item => !item.hidden).length;
634
+ if (visibleCount <= 0) return 0;
635
+ if (visibleCount === 1) return 115;
636
+ return 132;
637
+ }, [bottomRightContent]);
625
638
 
626
639
  /**
627
640
  * 视频流加载状态封装
@@ -918,6 +931,7 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
918
931
  playerRoute: playerRoute,
919
932
  defaultAutoPlay: defaultAutoPlay,
920
933
  limitFlow: limitFlow,
934
+ autoWakeUp: autoWakeUp,
921
935
  extend: _objectSpread(_objectSpread({
922
936
  backgroundColor: '#262626'
923
937
  }, instance.multiCameraCtx.extendProps), extend)
@@ -942,10 +956,12 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
942
956
  style: {
943
957
  height: screenType === 'vertical' ? '48px' : '72px'
944
958
  }
945
- }, /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(BottomLeftContent, {
946
- ctx: instance
959
+ }, /*#__PURE__*/React.createElement(React.Fragment, null, playerReady && /*#__PURE__*/React.createElement(BottomLeftContent, {
960
+ ctx: instance,
961
+ reservedRight: bottomRightWidth
947
962
  }, renderBottomLeftContent), /*#__PURE__*/React.createElement(BottomRightContent, {
948
- ctx: instance
963
+ ctx: instance,
964
+ width: bottomRightWidth
949
965
  }, renderBottomRightContent))), (() => {
950
966
  if (!absoluteContent || !(absoluteContent !== null && absoluteContent !== void 0 && absoluteContent.length)) return null;
951
967
  return absoluteContent.map(item => {
package/lib/ui/ui.less CHANGED
@@ -58,7 +58,7 @@
58
58
  }
59
59
 
60
60
  .ipc-player-bottom-content-hide {
61
- transform: translate(0, 110%);
61
+ transform: translate(0, 100%);
62
62
  transition: transform 0.3s ease-in-out;
63
63
  }
64
64
 
@@ -214,6 +214,9 @@
214
214
  display: flex;
215
215
  justify-content: center;
216
216
  align-items: center;
217
+ // 左下角支持横向滚动;不允许子项被压缩,否则在 width:100% 的滚动容器里
218
+ // 子项会被挤而不是触发横滑
219
+ flex-shrink: 0;
217
220
  }
218
221
 
219
222
  .bottom-left-item-container:first-of-type {
@@ -231,6 +234,7 @@
231
234
  // 左下角全屏子元素容器
232
235
  .bottom-left-item-full-container {
233
236
  padding: 0 24px !important;
237
+ flex-shrink: 0;
234
238
  }
235
239
 
236
240
  .bottom-left-item-full-container:first-of-type {
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import { ComponentConfigProps } from '../../interface';
3
+ import './floodlight.less';
4
+ export declare const Floodlight: (props: ComponentConfigProps) => React.JSX.Element | null;
@@ -0,0 +1,55 @@
1
+ import { View, Text } from '@ray-js/ray';
2
+ import React, { useContext } from 'react';
3
+ import clsx from 'clsx';
4
+ import { useDpState } from '../../hooks';
5
+ import { useStore } from '../../ctx/store';
6
+ import { UIEventContext } from '../../ui/context';
7
+ import { widgetLabs, widgetClick, pauseTimeToHideAllComponent, startTimeToHideAllComponent } from '../../ui/constant';
8
+ import './floodlight.less';
9
+ const FLOODLIGHT_SWITCH_DP_CODE = 'floodlight_switch';
10
+ export const Floodlight = props => {
11
+ const {
12
+ devId,
13
+ screenType: screenTypeAtom,
14
+ className,
15
+ event: propsEvent
16
+ } = props;
17
+ const {
18
+ event: ctxEvent
19
+ } = useContext(UIEventContext);
20
+ const event = propsEvent !== null && propsEvent !== void 0 ? propsEvent : ctxEvent;
21
+ const {
22
+ screenType,
23
+ brandColor
24
+ } = useStore({
25
+ screenType: screenTypeAtom,
26
+ brandColor: props.brandColor
27
+ });
28
+ const [state, dpSchema, sendDp] = useDpState({
29
+ devId,
30
+ dpCodes: [FLOODLIGHT_SWITCH_DP_CODE]
31
+ });
32
+ const supported = !!(dpSchema !== null && dpSchema !== void 0 && dpSchema[FLOODLIGHT_SWITCH_DP_CODE]);
33
+ const enabled = !!state[FLOODLIGHT_SWITCH_DP_CODE];
34
+ if (screenType !== 'full' || !supported) {
35
+ return null;
36
+ }
37
+ return /*#__PURE__*/React.createElement(View, {
38
+ className: clsx(className),
39
+ onClick: () => {
40
+ event.emit(widgetClick, {
41
+ widgetId: widgetLabs.FLOODLIGHT
42
+ });
43
+ event.emit(pauseTimeToHideAllComponent);
44
+ sendDp({
45
+ [FLOODLIGHT_SWITCH_DP_CODE]: !enabled
46
+ });
47
+ event.emit(startTimeToHideAllComponent);
48
+ }
49
+ }, /*#__PURE__*/React.createElement(Text, {
50
+ className: clsx('icon-panel', 'icon-panel-deng', 'ipc-player-plugin-floodlight-text-icon'),
51
+ style: {
52
+ color: enabled ? brandColor : undefined
53
+ }
54
+ }));
55
+ };
@@ -0,0 +1,4 @@
1
+ .ipc-player-plugin-floodlight-text-icon {
2
+ color: var(--iconColor);
3
+ font-size: calc(var(--iconPlayerSize) * var(--ipc-player-size-scale, 1)) !important;
4
+ }
@@ -0,0 +1 @@
1
+ export * from './floodlight';
@@ -0,0 +1 @@
1
+ export * from './floodlight';
@@ -8,6 +8,10 @@ export * from './fullScreen';
8
8
  export * from './videoBitKBP';
9
9
  export * from './voiceIntercom';
10
10
  export * from './muted';
11
+ export * from './floodlight';
12
+ export * from './siren';
13
+ export * from './tryExperience';
14
+ export * from './trialBadge';
11
15
  export * from './ptz';
12
16
  export * from './resolution';
13
17
  export * from './fullSmallIntercom';
@@ -8,6 +8,10 @@ export * from './fullScreen';
8
8
  export * from './videoBitKBP';
9
9
  export * from './voiceIntercom';
10
10
  export * from './muted';
11
+ export * from './floodlight';
12
+ export * from './siren';
13
+ export * from './tryExperience';
14
+ export * from './trialBadge';
11
15
  export * from './ptz';
12
16
  export * from './resolution';
13
17
  export * from './fullSmallIntercom';
@@ -0,0 +1 @@
1
+ export * from './siren';
@@ -0,0 +1 @@
1
+ export * from './siren';
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import { ComponentConfigProps } from '../../interface';
3
+ import './siren.less';
4
+ export declare const Siren: (props: ComponentConfigProps) => React.JSX.Element | null;
@@ -0,0 +1,55 @@
1
+ import { View, Text } from '@ray-js/ray';
2
+ import React, { useContext } from 'react';
3
+ import clsx from 'clsx';
4
+ import { useDpState } from '../../hooks';
5
+ import { useStore } from '../../ctx/store';
6
+ import { UIEventContext } from '../../ui/context';
7
+ import { widgetLabs, widgetClick, pauseTimeToHideAllComponent, startTimeToHideAllComponent } from '../../ui/constant';
8
+ import './siren.less';
9
+ const SIREN_SWITCH_DP_CODE = 'siren_switch';
10
+ export const Siren = props => {
11
+ const {
12
+ devId,
13
+ screenType: screenTypeAtom,
14
+ className,
15
+ event: propsEvent
16
+ } = props;
17
+ const {
18
+ event: ctxEvent
19
+ } = useContext(UIEventContext);
20
+ const event = propsEvent !== null && propsEvent !== void 0 ? propsEvent : ctxEvent;
21
+ const {
22
+ screenType,
23
+ brandColor
24
+ } = useStore({
25
+ screenType: screenTypeAtom,
26
+ brandColor: props.brandColor
27
+ });
28
+ const [state, dpSchema, sendDp] = useDpState({
29
+ devId,
30
+ dpCodes: [SIREN_SWITCH_DP_CODE]
31
+ });
32
+ const supported = !!(dpSchema !== null && dpSchema !== void 0 && dpSchema[SIREN_SWITCH_DP_CODE]);
33
+ const enabled = !!state[SIREN_SWITCH_DP_CODE];
34
+ if (screenType !== 'full' || !supported) {
35
+ return null;
36
+ }
37
+ return /*#__PURE__*/React.createElement(View, {
38
+ className: clsx(className),
39
+ onClick: () => {
40
+ event.emit(widgetClick, {
41
+ widgetId: widgetLabs.SIREN
42
+ });
43
+ event.emit(pauseTimeToHideAllComponent);
44
+ sendDp({
45
+ [SIREN_SWITCH_DP_CODE]: !enabled
46
+ });
47
+ event.emit(startTimeToHideAllComponent);
48
+ }
49
+ }, /*#__PURE__*/React.createElement(Text, {
50
+ className: clsx('icon-panel', 'icon-panel-jingdi', 'ipc-player-plugin-siren-text-icon'),
51
+ style: {
52
+ color: enabled ? brandColor : undefined
53
+ }
54
+ }));
55
+ };
@@ -0,0 +1,4 @@
1
+ .ipc-player-plugin-siren-text-icon {
2
+ color: var(--iconColor);
3
+ font-size: calc(var(--iconPlayerSize) * var(--ipc-player-size-scale, 1)) !important;
4
+ }
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ import './index.less';
3
+ type Props = {
4
+ className?: string;
5
+ /** 主题色(用于「开通」按钮背景)。默认与 player brandColor 一致 */
6
+ brandColor?: string;
7
+ /** 试看倒计时初始秒数,来源于 smartImageQualityState.trialRemainingSec */
8
+ trialRemainingSec?: number;
9
+ /** 点击「开通」按钮回调 */
10
+ onSubscribe?: () => void;
11
+ /** 倒计时归零时触发,本组件保证整个生命周期内只回调一次 */
12
+ onCountdownEnd?: () => void;
13
+ };
14
+ export declare const TrialBadge: ({ className, brandColor, trialRemainingSec, onSubscribe, onCountdownEnd, }: Props) => React.JSX.Element;
15
+ export { useTrialBadge } from './useTrialBadge';
@@ -0,0 +1,86 @@
1
+ import React, { useEffect, useRef, useState } from 'react';
2
+ import { Image, Text, View } from '@ray-js/ray';
3
+ import clsx from 'clsx';
4
+ import Strings from '../../i18n';
5
+ import tryOpen from '../../res/try/try_open.png';
6
+ import './index.less';
7
+ /** 兜底主题色,与 player ctx 中 brandColor 默认值保持一致 */
8
+ const FALLBACK_BRAND_COLOR = '#FF592A';
9
+
10
+ /** 将秒数格式化为 mm:ss */
11
+ const formatCountdown = seconds => {
12
+ const safe = Math.max(0, Math.floor(seconds));
13
+ const m = Math.floor(safe / 60);
14
+ return `${String(m).padStart(2, '0')}:${String(safe % 60).padStart(2, '0')}`;
15
+ };
16
+ export const TrialBadge = _ref => {
17
+ let {
18
+ className,
19
+ brandColor = FALLBACK_BRAND_COLOR,
20
+ trialRemainingSec = 0,
21
+ onSubscribe,
22
+ onCountdownEnd
23
+ } = _ref;
24
+ const [remainingSec, setRemainingSec] = useState(Math.max(0, Math.floor(trialRemainingSec)));
25
+ /** 防止 onCountdownEnd 被重复触发;同时持有最新回调,避免依赖变化导致 effect 重跑 */
26
+ const endedRef = useRef(false);
27
+ const onCountdownEndRef = useRef(onCountdownEnd);
28
+ onCountdownEndRef.current = onCountdownEnd;
29
+ useEffect(() => {
30
+ setRemainingSec(Math.max(0, Math.floor(trialRemainingSec)));
31
+ }, [trialRemainingSec]);
32
+ useEffect(() => {
33
+ if (remainingSec <= 0) {
34
+ if (!endedRef.current) {
35
+ var _onCountdownEndRef$cu;
36
+ endedRef.current = true;
37
+ (_onCountdownEndRef$cu = onCountdownEndRef.current) === null || _onCountdownEndRef$cu === void 0 || _onCountdownEndRef$cu.call(onCountdownEndRef);
38
+ }
39
+ return undefined;
40
+ }
41
+ const timer = setInterval(() => {
42
+ setRemainingSec(prev => {
43
+ const next = prev - 1;
44
+ if (next <= 0) {
45
+ clearInterval(timer);
46
+ if (!endedRef.current) {
47
+ var _onCountdownEndRef$cu2;
48
+ endedRef.current = true;
49
+ (_onCountdownEndRef$cu2 = onCountdownEndRef.current) === null || _onCountdownEndRef$cu2 === void 0 || _onCountdownEndRef$cu2.call(onCountdownEndRef);
50
+ }
51
+ return 0;
52
+ }
53
+ return next;
54
+ });
55
+ }, 1000);
56
+ return () => clearInterval(timer);
57
+ }, [trialRemainingSec]);
58
+ const countdownText = formatCountdown(remainingSec);
59
+ return /*#__PURE__*/React.createElement(View, {
60
+ className: clsx('ipc-player-trial-badge', className)
61
+ }, /*#__PURE__*/React.createElement(Image, {
62
+ className: "ipc-player-trial-badge-icon",
63
+ src: tryOpen,
64
+ mode: "heightFix"
65
+ }), /*#__PURE__*/React.createElement(Text, {
66
+ className: "ipc-player-trial-badge-status"
67
+ }, Strings.getLang('ipc_player_trial_in_use')), /*#__PURE__*/React.createElement(Text, {
68
+ className: "ipc-player-trial-badge-divider"
69
+ }, "|"), /*#__PURE__*/React.createElement(Text, {
70
+ className: "ipc-player-trial-badge-preview"
71
+ }, `${Strings.getLang('ipc_player_trial_preview_text')} ${countdownText}`), /*#__PURE__*/React.createElement(View, {
72
+ className: "ipc-player-trial-badge-cta",
73
+ style: {
74
+ backgroundColor: brandColor
75
+ },
76
+ onClick: e => {
77
+ if (e && typeof e.stopPropagation === 'function') {
78
+ e.stopPropagation();
79
+ }
80
+ onSubscribe === null || onSubscribe === void 0 || onSubscribe();
81
+ }
82
+ }, /*#__PURE__*/React.createElement(Text, {
83
+ className: "ipc-player-trial-badge-cta-text"
84
+ }, Strings.getLang('ipc_player_trial_subscribe'))));
85
+ };
86
+ export { useTrialBadge } from './useTrialBadge';
@@ -0,0 +1,57 @@
1
+ .ipc-player-trial-badge {
2
+ display: inline-flex;
3
+ align-items: center;
4
+ height: 28px;
5
+ padding: 0 4px 0 8px;
6
+ border-radius: 6px;
7
+ background: rgba(0, 0, 0, 0.65);
8
+ flex-shrink: 0;
9
+ vertical-align: middle;
10
+ white-space: nowrap;
11
+ }
12
+
13
+ .ipc-player-trial-badge-icon {
14
+ display: block;
15
+ height: 20px;
16
+ width: auto;
17
+ margin-right: 6px;
18
+ flex-shrink: 0;
19
+ }
20
+
21
+ .ipc-player-trial-badge-status {
22
+ font-size: 12px;
23
+ color: #ffffff;
24
+ font-weight: 500;
25
+ line-height: 1;
26
+ }
27
+
28
+ .ipc-player-trial-badge-divider {
29
+ margin: 0 6px;
30
+ font-size: 12px;
31
+ color: rgba(255, 255, 255, 0.45);
32
+ line-height: 1;
33
+ }
34
+
35
+ .ipc-player-trial-badge-preview {
36
+ font-size: 12px;
37
+ color: rgba(255, 255, 255, 0.78);
38
+ line-height: 1;
39
+ margin-right: 8px;
40
+ }
41
+
42
+ .ipc-player-trial-badge-cta {
43
+ display: inline-flex;
44
+ align-items: center;
45
+ justify-content: center;
46
+ height: 22px;
47
+ padding: 0 10px;
48
+ border-radius: 11px;
49
+ flex-shrink: 0;
50
+ }
51
+
52
+ .ipc-player-trial-badge-cta-text {
53
+ font-size: 12px;
54
+ color: #ffffff;
55
+ font-weight: 600;
56
+ line-height: 1;
57
+ }
@@ -0,0 +1,16 @@
1
+ /// <reference types="react" />
2
+ import type { EventInstance } from '../../interface';
3
+ /**
4
+ * 试用徽章共享 Hook:vertical / full 两种 screenType 下共用同一份状态、回调和方法。
5
+ *
6
+ * - `showTrialBadge`:是否展示徽章;仅当 0 < trialRemainingSec < 300 时展示,倒计时归零会自动置 false。
7
+ * - `handleTrialSubscribe`:「开通」按钮点击回调。
8
+ * - `handleCountdownEnd`:倒计时归零回调,内部会广播 `trialCountdownEnd`
9
+ * 事件给其它控件(例如 TryExperience)刷新自身状态。
10
+ */
11
+ export declare const useTrialBadge: (event: EventInstance, trialRemainingSec: number) => {
12
+ showTrialBadge: boolean;
13
+ setShowTrialBadge: import("react").Dispatch<import("react").SetStateAction<boolean>>;
14
+ handleTrialSubscribe: () => void;
15
+ handleCountdownEnd: () => void;
16
+ };
@@ -0,0 +1,41 @@
1
+ import { useCallback, useEffect, useState } from 'react';
2
+ import { trialCountdownEnd } from '../../ui/constant';
3
+
4
+ /**
5
+ * 试看倒计时归零后的业务 hook 点(mock)。
6
+ * 后续接入业务校验 / 上报时替换该实现。横竖屏共用同一份逻辑。
7
+ */
8
+ const trialEndedTest = () => {
9
+ console.log('res===[TrialBadge] countdown end -> test()');
10
+ };
11
+
12
+ /**
13
+ * 试用徽章共享 Hook:vertical / full 两种 screenType 下共用同一份状态、回调和方法。
14
+ *
15
+ * - `showTrialBadge`:是否展示徽章;仅当 0 < trialRemainingSec < 300 时展示,倒计时归零会自动置 false。
16
+ * - `handleTrialSubscribe`:「开通」按钮点击回调。
17
+ * - `handleCountdownEnd`:倒计时归零回调,内部会广播 `trialCountdownEnd`
18
+ * 事件给其它控件(例如 TryExperience)刷新自身状态。
19
+ */
20
+ export const useTrialBadge = (event, trialRemainingSec) => {
21
+ const [showTrialBadge, setShowTrialBadge] = useState(false);
22
+ useEffect(() => {
23
+ if (trialRemainingSec > 0 && trialRemainingSec < 300) {
24
+ setShowTrialBadge(true);
25
+ }
26
+ }, [trialRemainingSec]);
27
+ const handleTrialSubscribe = useCallback(() => {
28
+ console.log('[TrialBadge] click subscribe');
29
+ }, []);
30
+ const handleCountdownEnd = useCallback(() => {
31
+ trialEndedTest();
32
+ event.emit(trialCountdownEnd);
33
+ setShowTrialBadge(false);
34
+ }, [event]);
35
+ return {
36
+ showTrialBadge,
37
+ setShowTrialBadge,
38
+ handleTrialSubscribe,
39
+ handleCountdownEnd
40
+ };
41
+ };
@@ -0,0 +1 @@
1
+ export * from './tryExperience';
@@ -0,0 +1 @@
1
+ export * from './tryExperience';
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import { ComponentConfigProps } from '../../interface';
3
+ import './tryExperience.less';
4
+ type Props = ComponentConfigProps & {
5
+ className?: string;
6
+ hideTryExperienceMenu?: boolean;
7
+ buttonState?: number;
8
+ };
9
+ export declare const TryExperience: (props: Props) => React.JSX.Element | null;
10
+ export {};
@@ -0,0 +1,71 @@
1
+ import { View, Image, getSystemInfoSync } from '@ray-js/ray';
2
+ import clsx from 'clsx';
3
+ import React, { useContext } from 'react';
4
+ import { pauseTimeToHideAllComponent, widgetClick, widgetLabs, tryExperienceBtnClick } from '../../ui/constant';
5
+ import { UIEventContext } from '../../ui/context';
6
+ import tryZh from '../../res/try/try_zh.png';
7
+ import tryEn from '../../res/try/try_en.png';
8
+ import tryOpen from '../../res/try/try_open.png';
9
+ import tryClose from '../../res/try/try_close.png';
10
+ import './tryExperience.less';
11
+ /** ty.ipc.test1 返回的体验状态 */
12
+ var TryExperienceStatus = /*#__PURE__*/function (TryExperienceStatus) {
13
+ TryExperienceStatus[TryExperienceStatus["Default"] = 0] = "Default";
14
+ TryExperienceStatus[TryExperienceStatus["Open"] = 1] = "Open";
15
+ TryExperienceStatus[TryExperienceStatus["Close"] = 2] = "Close";
16
+ return TryExperienceStatus;
17
+ }(TryExperienceStatus || {});
18
+ const ZH_LANG_REGEX = /^zh(_|-|$)/i;
19
+ const getDefaultLangIcon = () => {
20
+ try {
21
+ const {
22
+ language = ''
23
+ } = getSystemInfoSync() || {};
24
+ return ZH_LANG_REGEX.test(String(language)) ? tryZh : tryEn;
25
+ } catch {
26
+ return tryEn;
27
+ }
28
+ };
29
+ const pickIconByStatus = buttonState => {
30
+ switch (buttonState) {
31
+ case TryExperienceStatus.Open:
32
+ return tryOpen;
33
+ case TryExperienceStatus.Close:
34
+ return tryClose;
35
+ case TryExperienceStatus.Default:
36
+ default:
37
+ return getDefaultLangIcon();
38
+ }
39
+ };
40
+ export const TryExperience = props => {
41
+ const {
42
+ className,
43
+ hideTryExperienceMenu,
44
+ buttonState = 0,
45
+ event: propsEvent
46
+ } = props;
47
+ const {
48
+ event: ctxEvent
49
+ } = useContext(UIEventContext);
50
+ const event = propsEvent !== null && propsEvent !== void 0 ? propsEvent : ctxEvent;
51
+ const iconUrl = pickIconByStatus(buttonState);
52
+ if (hideTryExperienceMenu) {
53
+ return null;
54
+ }
55
+ return /*#__PURE__*/React.createElement(View, {
56
+ className: clsx(className),
57
+ onClick: () => {
58
+ event.emit(widgetClick, {
59
+ widgetId: widgetLabs.TRY_EXPERIENCE
60
+ });
61
+ event.emit(tryExperienceBtnClick);
62
+ event.emit(pauseTimeToHideAllComponent);
63
+ }
64
+ }, /*#__PURE__*/React.createElement(View, {
65
+ className: "try-experience-box"
66
+ }, /*#__PURE__*/React.createElement(Image, {
67
+ className: "try-experience-icon",
68
+ src: iconUrl,
69
+ mode: "heightFix"
70
+ })));
71
+ };
@@ -0,0 +1,13 @@
1
+ .try-experience-box {
2
+ display: inline-flex;
3
+ justify-content: center;
4
+ align-items: center;
5
+ min-height: calc(var(--iconBoxSize) * var(--ipc-player-size-scale, 1));
6
+ }
7
+
8
+ .try-experience-icon {
9
+ display: block;
10
+ height: calc(var(--iconBoxSize) * var(--ipc-player-size-scale, 1));
11
+ width: auto;
12
+ flex-shrink: 0;
13
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/ipc-player-integration",
3
- "version": "0.0.34",
3
+ "version": "0.0.35-beta.2",
4
4
  "description": "IPC 融合播放器",
5
5
  "main": "lib/index",
6
6
  "files": [
@@ -37,7 +37,7 @@
37
37
  "dependencies": {
38
38
  "@ray-js/direction-control": "^0.0.8",
39
39
  "@ray-js/ipc-ptz-zoom": "^0.0.3",
40
- "@ray-js/ray-ipc-player": "^2.1.0",
40
+ "@ray-js/ray-ipc-player": "2.1.1-beta.3",
41
41
  "@ray-js/ray-ipc-utils": "^1.1.15",
42
42
  "@ray-js/svg": "0.2.0",
43
43
  "clsx": "^1.2.1",