@ray-js/ipc-player-integration 0.0.1-beta-12 → 0.0.1-beta-13

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.
@@ -1,8 +1,10 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
3
  const _excluded = ["title", "duration"];
4
+ import IPCUtils from '@ray-js/ray-ipc-utils';
5
+ import { MuteMode } from '@ray-js/ray-ipc-utils/lib/interface';
4
6
  import { createUseCtx } from './ctx';
5
- import { Battery, Screenshot, TempHumidity, RecordVideo, FullScreen, VideoBitKbps, Muted, Resolution } from '../plugins';
7
+ import { Battery, Screenshot, TempHumidity, RecordVideo, FullScreen, VideoBitKbps, Muted, Resolution, Ptz } from '../plugins';
6
8
  import { authorizeStatus } from '../utils/authorize';
7
9
  const createPlayContext = ty.createIpcPlayerContext;
8
10
  // const createPlayContext = () => null;
@@ -27,6 +29,9 @@ const bottomContent = [{
27
29
  }, {
28
30
  id: 'Muted',
29
31
  content: Muted
32
+ }, {
33
+ id: 'Ptz',
34
+ content: Ptz
30
35
  }, {
31
36
  id: 'Resolution',
32
37
  content: Resolution
@@ -46,11 +51,48 @@ const toast = _ref => {
46
51
  icon: 'none'
47
52
  }, config));
48
53
  };
54
+ const getMemoryState = devId => {
55
+ return new Promise(resolve => {
56
+ IPCUtils.getCameraConfigInfo(devId).then(res => {
57
+ if (res.code === -1) {
58
+ return resolve({
59
+ mute: true
60
+ });
61
+ }
62
+ const value = res.data.microphoneSettings.cachedMuteMode === MuteMode.OFF;
63
+ return resolve({
64
+ mute: value
65
+ });
66
+ }).catch(() => {
67
+ resolve({
68
+ mute: true
69
+ });
70
+ });
71
+ });
72
+ };
73
+ const setMuteMemoryState = (devId, value) => {
74
+ const storageKey = `${devId}_microphone`;
75
+ const originStorage = ty.getStorageSync({
76
+ key: storageKey
77
+ });
78
+ const newData = originStorage ? _objectSpread({}, originStorage) : null;
79
+ if (newData) {
80
+ const muteMode = value ? MuteMode.OFF : MuteMode.ON;
81
+ newData.cachedMuteMode = muteMode;
82
+ // @ts-ignore
83
+ ty.setStorageSync({
84
+ key: storageKey,
85
+ data: newData
86
+ });
87
+ }
88
+ };
49
89
  export const useCtx = createUseCtx({
50
90
  createPlayContext,
51
91
  defaultTopContent: topContent,
52
92
  defaultAbsoluteContent: absoluteContent,
53
93
  defaultBottomContent: bottomContent,
54
94
  authorizeStatus: authorizeStatus,
55
- toast
95
+ toast,
96
+ getMemoryState,
97
+ setMuteMemoryState
56
98
  });
package/lib/ctx/ctx.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ComponentConfig, UseCtx } from '../interface';
2
- import type { createPlayContext, AuthorizeStatus, Toast } from './ports.output';
2
+ import type { createPlayContext, AuthorizeStatus, Toast, GetMemoryState, SetMuteMemoryState } from './ports.output';
3
3
  type Depend = {
4
4
  createPlayContext: createPlayContext;
5
5
  defaultTopContent?: ComponentConfig[];
@@ -7,6 +7,8 @@ type Depend = {
7
7
  defaultAbsoluteContent?: ComponentConfig[];
8
8
  authorizeStatus: AuthorizeStatus;
9
9
  toast: Toast;
10
+ getMemoryState: GetMemoryState;
11
+ setMuteMemoryState: SetMuteMemoryState;
10
12
  };
11
- export declare const createUseCtx: ({ createPlayContext, defaultTopContent, defaultBottomContent, defaultAbsoluteContent, authorizeStatus, toast, }: Depend) => UseCtx;
13
+ export declare const createUseCtx: ({ createPlayContext, defaultTopContent, defaultBottomContent, defaultAbsoluteContent, authorizeStatus, toast, getMemoryState, setMuteMemoryState, }: Depend) => UseCtx;
12
14
  export {};
package/lib/ctx/ctx.js CHANGED
@@ -1,5 +1,5 @@
1
- import { useRef, useCallback } from 'react';
2
- import { useAtom, updateAtom, getDefaultStore } from './store';
1
+ import { useRef, useCallback, useEffect } from 'react';
2
+ import { useAtom, updateAtom, getDefaultStore, useStore } from './store';
3
3
  import { PlayState } from '../interface';
4
4
  const SAVE_TO_ALBUM = 1;
5
5
  export const createUseCtx = _ref => {
@@ -9,7 +9,9 @@ export const createUseCtx = _ref => {
9
9
  defaultBottomContent,
10
10
  defaultAbsoluteContent,
11
11
  authorizeStatus,
12
- toast
12
+ toast,
13
+ getMemoryState,
14
+ setMuteMemoryState
13
15
  } = _ref;
14
16
  return _ref2 => {
15
17
  let {
@@ -25,12 +27,16 @@ export const createUseCtx = _ref => {
25
27
  // 录像中
26
28
  const recording = useAtom(false);
27
29
 
28
- // 静音
30
+ // 静音 true 代表静音 false 代表不静音
29
31
  const mute = useAtom(false);
30
32
 
31
33
  // 清晰度
32
34
  const resolution = useAtom('HD');
33
35
 
36
+ // ptz 是否点击
37
+ const ptzActive = useAtom(false);
38
+ // 全屏清晰度UI切换是否展示
39
+ const fullResolutionActive = useAtom(false);
34
40
  // 对讲中
35
41
  const intercom = useAtom(false);
36
42
  const playState = useAtom(PlayState.CONNECTING);
@@ -40,10 +46,50 @@ export const createUseCtx = _ref => {
40
46
  const topContent = useAtom(initTopContent || defaultTopContent || []);
41
47
  const bottomContent = useAtom(initBottomContent || defaultBottomContent || []);
42
48
  const absoluteContent = useAtom(initAbsoluteContent || defaultAbsoluteContent || []);
49
+ const {
50
+ _playState
51
+ } = useStore({
52
+ _playState: playState
53
+ });
54
+ useEffect(() => {
55
+ if (devId && _playState === PlayState.PLAYING) {
56
+ // 获取缓存的值且同步
57
+ getMemoryState(devId).then(res => {
58
+ _setMute(res.mute);
59
+ });
60
+ }
61
+ }, [devId, _playState]);
43
62
  const IPCPlayerInstance = useRef();
44
63
  if (!IPCPlayerInstance.current) {
45
64
  IPCPlayerInstance.current = createPlayContext(devId);
46
65
  }
66
+ const _setMute = async target => {
67
+ return new Promise((resolve, reject) => {
68
+ IPCPlayerInstance.current.setMuted({
69
+ mute: target,
70
+ success: () => {
71
+ console.log('=== set mute success ===', target);
72
+ setMuteMemoryState(devId, target);
73
+ updateAtom(mute, target);
74
+ resolve(true);
75
+ },
76
+ fail: err => {
77
+ IPCPlayerInstance.current.isMuted({
78
+ success(res) {
79
+ console.log('==== 当前静音状态 ====', res);
80
+ updateAtom(mute, res);
81
+ }
82
+ });
83
+ reject(err);
84
+ const errObj = err.innerError || err || {};
85
+ const errMsg = errObj.errorMsg || I18n.t('error_setMute');
86
+ toast({
87
+ title: errMsg
88
+ });
89
+ }
90
+ });
91
+ });
92
+ };
47
93
 
48
94
  /**
49
95
  * 设置清晰度
@@ -57,6 +103,8 @@ export const createUseCtx = _ref => {
57
103
  recording,
58
104
  mute,
59
105
  resolution,
106
+ ptzActive,
107
+ fullResolutionActive,
60
108
  intercom,
61
109
  playState,
62
110
  setPlayState,
@@ -98,22 +146,7 @@ export const createUseCtx = _ref => {
98
146
  }
99
147
  });
100
148
  },
101
- setMute: async target => {
102
- return new Promise((resolve, reject) => {
103
- updateAtom(mute, target);
104
- IPCPlayerInstance.current.setMuted({
105
- mute: target,
106
- success: () => {
107
- updateAtom(mute, target);
108
- resolve(true);
109
- },
110
- fail: err => {
111
- updateAtom(mute, !target);
112
- reject(err);
113
- }
114
- });
115
- });
116
- },
149
+ setMute: _setMute,
117
150
  setResolution: async target => {
118
151
  console.log('执行清晰度方法');
119
152
  return new Promise((resolve, reject) => {
@@ -171,6 +204,12 @@ export const createUseCtx = _ref => {
171
204
  }
172
205
  });
173
206
  },
207
+ setPtzActive: value => {
208
+ updateAtom(ptzActive, value);
209
+ },
210
+ setFullResolutionActive: value => {
211
+ updateAtom(fullResolutionActive, value);
212
+ },
174
213
  setScreenType: value => {
175
214
  updateAtom(screenType, value);
176
215
  },
@@ -1,3 +1,7 @@
1
1
  export type { Toast } from '../ports.output';
2
2
  export type createPlayContext = (devId: string) => IpcContext;
3
3
  export type AuthorizeStatus = (type: string) => Promise<boolean>;
4
+ export type GetMemoryState = (devId: string) => Promise<{
5
+ mute: boolean;
6
+ }>;
7
+ export type SetMuteMemoryState = (devId: string, value: boolean) => void;
@@ -36,12 +36,16 @@ export type UseCtx = (options: {
36
36
  recording: RetAtom<boolean>;
37
37
  mute: RetAtom<boolean>;
38
38
  intercom: RetAtom<boolean>;
39
+ ptzActive: RetAtom<boolean>;
40
+ fullResolutionActive: RetAtom<boolean>;
39
41
  playState: RetAtom<PlayState>;
40
42
  IPCPlayerInstance: IpcContext;
41
43
  topContent: RetAtom<ComponentConfig[]>;
42
44
  bottomContent: RetAtom<ComponentConfig[]>;
43
45
  absoluteContent: RetAtom<ComponentConfig[]>;
44
46
  setScreenType: (type: ScreenType) => void;
47
+ setPtzActive: (type: boolean) => void;
48
+ setFullResolutionActive: (type: boolean) => void;
45
49
  setRecording: (value: boolean) => Promise<boolean>;
46
50
  setIntercom: (value: boolean) => Promise<boolean>;
47
51
  setMute: (value: boolean) => Promise<boolean>;
@@ -8,12 +8,16 @@ export declare const Battery: import("react").FunctionComponent<{
8
8
  recording: import("../..").RetAtom<boolean>;
9
9
  mute: import("../..").RetAtom<boolean>;
10
10
  intercom: import("../..").RetAtom<boolean>;
11
+ ptzActive: import("../..").RetAtom<boolean>;
12
+ fullResolutionActive: import("../..").RetAtom<boolean>;
11
13
  playState: import("../..").RetAtom<import("../..").PlayState>;
12
14
  IPCPlayerInstance: IpcContext;
13
15
  topContent: import("../..").RetAtom<import("../..").ComponentConfig<any & Record<string, any>>[]>;
14
16
  bottomContent: import("../..").RetAtom<import("../..").ComponentConfig<any & Record<string, any>>[]>;
15
17
  absoluteContent: import("../..").RetAtom<import("../..").ComponentConfig<any & Record<string, any>>[]>;
16
18
  setScreenType: (type: import("../..").ScreenType) => void;
19
+ setPtzActive: (type: boolean) => void;
20
+ setFullResolutionActive: (type: boolean) => void;
17
21
  setRecording: (value: boolean) => Promise<boolean>;
18
22
  setIntercom: (value: boolean) => Promise<boolean>;
19
23
  setMute: (value: boolean) => Promise<boolean>;
@@ -1,20 +1,22 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
2
  import React, { useContext } from 'react';
3
3
  import { View, setPageOrientation } from '@ray-js/ray';
4
+ import { useUpdateEffect } from 'ahooks';
5
+ import clsx from 'clsx';
4
6
  import { UIEventContext } from '../../ui/context';
5
- import { startTimeToHideAllComponent, showAllComponent } from '../../ui/constant';
7
+ import { startTimeToHideAllComponent, showAllComponent, voiceIntercomId, verticalScreenId, ptzControlId, fullResolutionId } from '../../ui/constant';
6
8
  import { useStore } from '../../ctx/store';
7
9
  import { VerticalScreen } from './verticalScreen';
8
10
  import { VoiceIntercom } from './voiceIntercom';
9
11
  import './fullScreen.less';
10
- const VerticalScreenId = 'VerticalScreen';
11
- const VoiceIntercomId = 'VoiceIntercom';
12
12
  export function FullScreen(props) {
13
13
  const {
14
14
  screenType: screenTypeAtom,
15
15
  setScreenType,
16
16
  addContent,
17
- deleteContent
17
+ deleteContent,
18
+ setPtzActive,
19
+ setFullResolutionActive
18
20
  } = props;
19
21
  const {
20
22
  screenType
@@ -24,7 +26,15 @@ export function FullScreen(props) {
24
26
  const {
25
27
  event
26
28
  } = useContext(UIEventContext);
27
- const handFull = () => {
29
+
30
+ /**
31
+ * 竖屏统一操作
32
+ */
33
+
34
+ /**
35
+ * 全屏统一操作
36
+ */
37
+ const handleFull = () => {
28
38
  ty.hideMenuButton();
29
39
  ty.hideStatusBar();
30
40
  ty.setNavigationBarBack({
@@ -33,7 +43,7 @@ export function FullScreen(props) {
33
43
 
34
44
  // 添加全屏后,返回竖屏的控件
35
45
  addContent('top', {
36
- id: VerticalScreenId,
46
+ id: verticalScreenId,
37
47
  content: VerticalScreen,
38
48
  initProps: _objectSpread(_objectSpread({}, props), {}, {
39
49
  onClick: () => {
@@ -44,33 +54,54 @@ export function FullScreen(props) {
44
54
  });
45
55
  // 全屏后,添加语音对讲控件
46
56
  addContent('absolute', {
47
- id: VoiceIntercomId,
57
+ id: voiceIntercomId,
48
58
  content: props => {
49
59
  return /*#__PURE__*/React.createElement(View, {
50
- className: "ipc-player-plugin-full-screen-voice"
60
+ className: clsx('ipc-player-plugin-full-screen-voice')
51
61
  }, /*#__PURE__*/React.createElement(VoiceIntercom, props));
52
62
  },
53
63
  absoluteContentClassName: 'ipc-player-plugin-full-screen-voice-warp',
54
64
  initProps: _objectSpread({}, props)
55
65
  });
56
66
  };
67
+
68
+ /**
69
+ * 针对横竖屏方法统一集中处理
70
+ */
71
+ const handlers = {
72
+ full: () => {
73
+ handleFull();
74
+ event.emit(startTimeToHideAllComponent);
75
+ },
76
+ vertical: () => {
77
+ ty.setNavigationBarBack({
78
+ type: 'system'
79
+ });
80
+ ty.showMenuButton();
81
+ ty.showStatusBar();
82
+ deleteContent('top', verticalScreenId);
83
+ deleteContent('absolute', voiceIntercomId);
84
+ deleteContent('absolute', ptzControlId);
85
+ deleteContent('absolute', fullResolutionId);
86
+ // 还原Ptz点击状态值
87
+ setPtzActive(false);
88
+ // 还原全屏清晰度状态值
89
+ setFullResolutionActive(false);
90
+ }
91
+ };
92
+ useUpdateEffect(() => {
93
+ var _handlers$screenType;
94
+ (_handlers$screenType = handlers[screenType]) === null || _handlers$screenType === void 0 || _handlers$screenType.call(handlers);
95
+ }, [screenType]);
57
96
  const handClick = target => {
58
97
  const pageOrientation = target === 'vertical' ? 'portrait' : 'landscape';
59
- setScreenType(target);
60
98
  setPageOrientation({
61
99
  pageOrientation,
62
100
  success: () => {
101
+ setScreenType(target);
63
102
  if (target === 'full') {
64
- handFull();
65
- event.emit(startTimeToHideAllComponent);
66
- } else {
67
- ty.setNavigationBarBack({
68
- type: 'system'
69
- });
70
- ty.showMenuButton();
71
- ty.showStatusBar();
72
- deleteContent('top', VerticalScreenId);
73
- deleteContent('absolute', VoiceIntercomId);
103
+ // handFull();
104
+ // event.emit(startTimeToHideAllComponent);
74
105
  }
75
106
  }
76
107
  });
@@ -9,9 +9,13 @@ import { startTimeToHideAllComponent, pauseTimeToHideAllComponent } from '../../
9
9
  import { useStore } from '../../ctx/store';
10
10
  export function VoiceIntercom(props) {
11
11
  const {
12
- screenType
12
+ screenType,
13
+ isPtzActive,
14
+ fullResolutionActive
13
15
  } = useStore({
14
- screenType: props.screenType
16
+ screenType: props.screenType,
17
+ isPtzActive: props.ptzActive,
18
+ fullResolutionActive: props.fullResolutionActive
15
19
  });
16
20
  const [shouldHide] = useComponentHideState(screenType);
17
21
  const {
@@ -19,7 +23,7 @@ export function VoiceIntercom(props) {
19
23
  } = useContext(UIEventContext);
20
24
  return /*#__PURE__*/React.createElement(CoverView, {
21
25
  className: clsx('ipc-player-plugin-full-screen-voice', {
22
- 'ipc-player-plugin-full-screen-voice-hide': shouldHide
26
+ 'ipc-player-plugin-full-screen-voice-hide': shouldHide || isPtzActive || fullResolutionActive
23
27
  })
24
28
  }, /*#__PURE__*/React.createElement(Component, _extends({}, props, {
25
29
  onTouchStart: () => {
@@ -6,4 +6,5 @@ export * from './fullScreen';
6
6
  export * from './videoBitKbps';
7
7
  export * from './voiceIntercom';
8
8
  export * from './muted';
9
+ export * from './ptz';
9
10
  export * from './resolution';
@@ -6,4 +6,5 @@ export * from './fullScreen';
6
6
  export * from './videoBitKbps';
7
7
  export * from './voiceIntercom';
8
8
  export * from './muted';
9
+ export * from './ptz';
9
10
  export * from './resolution';
@@ -1,44 +1,29 @@
1
1
  import { View, Text } from '@ray-js/ray';
2
- import React, { useEffect } from 'react';
3
- import { useStore, updateAtom } from '../../ctx/store';
2
+ import React from 'react';
3
+ import { useStore } from '../../ctx/store';
4
4
  import './muted.less';
5
5
  export const Muted = props => {
6
6
  const {
7
- IPCPlayerContext,
8
- mute
7
+ mute,
8
+ setMute
9
9
  } = props;
10
10
  const {
11
11
  isMuted
12
12
  } = useStore({
13
13
  isMuted: mute
14
14
  });
15
- const setIsMuted = value => {
16
- updateAtom(mute, value);
17
- };
18
- useEffect(() => {
19
- init();
20
- }, []);
21
- const init = () => {
22
- IPCPlayerContext.isMuted({
23
- success: res => {
24
- setIsMuted(res);
25
- },
26
- fail: res => {
27
- console.log('res===isMuted err', res);
28
- }
29
- });
30
- };
31
15
  return /*#__PURE__*/React.createElement(View, {
32
16
  onClick: () => {
33
- IPCPlayerContext.setMuted({
34
- mute: !isMuted,
35
- success: () => {
36
- setIsMuted(!isMuted);
37
- },
38
- fail: res => {
39
- console.log('res===setMuted err', res);
40
- }
41
- });
17
+ // IPCPlayerContext.setMuted({
18
+ // mute: !isMuted,
19
+ // success: res => {
20
+ // setIsMuted(!isMuted);
21
+ // },
22
+ // fail: res => {
23
+ // console.log('res===setMuted err', res);
24
+ // },
25
+ // });
26
+ setMute(!isMuted);
42
27
  },
43
28
  style: {
44
29
  display: 'flex'
@@ -0,0 +1 @@
1
+ export * from './ptz';
@@ -0,0 +1 @@
1
+ export * from './ptz';
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import { ComponentConfigProps } from '../../interface';
3
+ import './ptz.less';
4
+ export declare const Ptz: (props: ComponentConfigProps) => React.JSX.Element | null;
@@ -0,0 +1,67 @@
1
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
+ import { View, Text } from '@ray-js/ray';
3
+ import clsx from 'clsx';
4
+ import React, { useEffect } from 'react';
5
+ import { useStore, updateAtom } from '../../ctx/store';
6
+ import { ptzControlId } from '../../ui/constant';
7
+ import './ptz.less';
8
+ import { PtzControl } from './ptzControl';
9
+ export const Ptz = props => {
10
+ const {
11
+ IPCPlayerContext,
12
+ screenType: screenTypeAtom,
13
+ ptzActive,
14
+ addContent,
15
+ deleteContent
16
+ } = props;
17
+ const {
18
+ screenType,
19
+ isPtzActive
20
+ } = useStore({
21
+ screenType: screenTypeAtom,
22
+ isPtzActive: ptzActive
23
+ });
24
+ useEffect(() => {
25
+ // init();
26
+ }, []);
27
+
28
+ // const init = () => {
29
+ // IPCPlayerContext.isMuted({
30
+ // success: res => {
31
+ // setIsMuted(res);
32
+ // },
33
+ // fail: res => {
34
+ // console.log('res===isMuted err', res);
35
+ // },
36
+ // });
37
+ // };
38
+
39
+ if (screenType === 'vertical') {
40
+ return null;
41
+ }
42
+ return /*#__PURE__*/React.createElement(View, {
43
+ onClick: () => {
44
+ if (!isPtzActive) {
45
+ // 添加ptz空间
46
+ addContent('absolute', {
47
+ id: ptzControlId,
48
+ content: props => {
49
+ return /*#__PURE__*/React.createElement(View, {
50
+ className: "ipc-player-plugin-full-screen-ptz-control"
51
+ }, /*#__PURE__*/React.createElement(PtzControl, props));
52
+ },
53
+ absoluteContentClassName: 'ipc-player-plugin-full-screen-ptz-control-warp',
54
+ initProps: _objectSpread({}, props)
55
+ });
56
+ } else {
57
+ deleteContent('absolute', ptzControlId);
58
+ }
59
+ updateAtom(ptzActive, !isPtzActive);
60
+ },
61
+ style: {
62
+ display: 'flex'
63
+ }
64
+ }, /*#__PURE__*/React.createElement(Text, {
65
+ className: clsx('ipc-player-plugin-ptz-text-icon', 'icon-panel', 'icon-panel-ptz', isPtzActive && 'ipc-ptz-active')
66
+ }));
67
+ };
@@ -0,0 +1,42 @@
1
+ .ipc-player-plugin-ptz-text-icon {
2
+ color: var(--iconColor);
3
+ font-size: calc(var(--iconFontSize) * var(--ipc-player-size-scale, 1));
4
+ }
5
+
6
+ .ipc-ptz-active {
7
+ color: var(--iconActiveColor);
8
+ }
9
+
10
+ // .ipc-player-plugin-full-screen-ptz {
11
+ // position: absolute;
12
+ // top: 60%;
13
+ // transform: translateY(-50%);
14
+ // right: calc(16px * var(--ipc-player-size-scale, 1));
15
+ // color: var(--iconColor);
16
+ // font-size: calc(var(--iconFontSize) * var(--ipc-player-size-scale, 1));
17
+ // }
18
+
19
+ .ipc-player-plugin-full-screen-ptz-control-warp {
20
+ position: absolute;
21
+ bottom: 10px;
22
+ // transform: translate(0, -20%);
23
+ right: calc(10px * var(--ipc-player-size-scale, 1));;
24
+ z-index: 3;
25
+ }
26
+
27
+
28
+
29
+ .ipc-player-plugin-full-screen-ptz-control {
30
+ transform: translate(0, 0);
31
+ transition: transform ease-in 0.3s;
32
+ &.ipc-player-plugin-full-screen-ptz-control-hide {
33
+ transform: translate(0, 200%);
34
+ }
35
+ }
36
+
37
+ .arrow-icon-wrapper {
38
+ font-size: 12px;
39
+ color: #707070;
40
+ }
41
+
42
+
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import { ComponentConfigProps } from '../../interface';
3
+ import './ptz.less';
4
+ export declare const PtzControl: (props: ComponentConfigProps) => React.JSX.Element;
@@ -0,0 +1,64 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import React, { useContext } from 'react';
3
+ import { CoverView } from '@ray-js/ray';
4
+ import clsx from 'clsx';
5
+ import IpcPtzZoom from '@ray-js/ipc-ptz-zoom';
6
+ import { useComponentHideState } from '../../ui/hooks';
7
+ import { UIEventContext } from '../../ui/context';
8
+ import { useStore } from '../../ctx/store';
9
+ import { startTimeToHideAllComponent, pauseTimeToHideAllComponent } from '../../ui/constant';
10
+ import './ptz.less';
11
+ export const PtzControl = props => {
12
+ const {
13
+ screenType
14
+ } = useStore({
15
+ screenType: props.screenType
16
+ });
17
+ const [shouldHide] = useComponentHideState(screenType);
18
+ const {
19
+ event
20
+ } = useContext(UIEventContext);
21
+ return /*#__PURE__*/React.createElement(CoverView, _extends({
22
+ className: clsx('ipc-player-plugin-full-screen-ptz-control', {
23
+ 'ipc-player-plugin-full-screen-ptz-control-hide': shouldHide
24
+ })
25
+ }, props), /*#__PURE__*/React.createElement(IpcPtzZoom, {
26
+ ptzSize: "172px",
27
+ zoomData: [],
28
+ ptzData: [{
29
+ type: 'top',
30
+ // show: getEnumRangeIsValid('ptz_control', '0'),
31
+ show: true,
32
+ dpValue: '0',
33
+ icon: 'ptz-arrow'
34
+ }, {
35
+ type: 'right',
36
+ // show: getEnumRangeIsValid('ptz_control', '2'),
37
+ show: true,
38
+ dpValue: '2',
39
+ icon: 'ptz-arrow'
40
+ }, {
41
+ type: 'left',
42
+ // show: getEnumRangeIsValid('ptz_control', '6'),
43
+ show: true,
44
+ dpValue: '6',
45
+ icon: 'ptz-arrow'
46
+ }, {
47
+ type: 'bottom',
48
+ // show: getEnumRangeIsValid('ptz_control', '4'),
49
+ show: true,
50
+ dpValue: '4',
51
+ icon: 'ptz-arrow'
52
+ }],
53
+ onTouchPtzStart: data => {
54
+ console.log(data, 'data');
55
+ event.emit(pauseTimeToHideAllComponent);
56
+ },
57
+ onTouchPtzEnd: () => {
58
+ console.log('dsads');
59
+ event.emit(startTimeToHideAllComponent);
60
+ },
61
+ brandColor: "red",
62
+ iconClassName: clsx('arrow-icon-wrapper')
63
+ }));
64
+ };
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import { ComponentConfigProps } from '../../interface';
3
+ import './resolution.less';
4
+ export declare const FullResolutionControl: (props: ComponentConfigProps) => React.JSX.Element;
@@ -0,0 +1,31 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import React, { useContext } from 'react';
3
+ import { Text, View } from '@ray-js/ray';
4
+ import clsx from 'clsx';
5
+ import { useComponentHideState } from '../../ui/hooks';
6
+ import { UIEventContext } from '../../ui/context';
7
+ import { useStore } from '../../ctx/store';
8
+ import { startTimeToHideAllComponent, pauseTimeToHideAllComponent } from '../../ui/constant';
9
+ import './resolution.less';
10
+ export const FullResolutionControl = props => {
11
+ const {
12
+ screenType,
13
+ fullResolutionActive
14
+ } = useStore({
15
+ screenType: props.screenType,
16
+ fullResolutionActive: props.fullResolutionActive
17
+ });
18
+ const [shouldHide] = useComponentHideState(screenType);
19
+ const {
20
+ event
21
+ } = useContext(UIEventContext);
22
+ return /*#__PURE__*/React.createElement(View, _extends({
23
+ className: clsx('ipc-player-plugin-full-resolution-control', {
24
+ 'ipc-player-plugin-full-resolution-control-hide': shouldHide || !fullResolutionActive
25
+ })
26
+ }, props), /*#__PURE__*/React.createElement(Text, {
27
+ className: clsx('ipc-player-plugin-full-resolution-control-text')
28
+ }, "\u9AD8\u6E05"), /*#__PURE__*/React.createElement(Text, {
29
+ className: clsx('ipc-player-plugin-full-resolution-control-text')
30
+ }, "\u6807\u6E05"));
31
+ };
@@ -1,19 +1,34 @@
1
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
1
2
  import { View, Text } from '@ray-js/ray';
2
- import React, { useEffect } from 'react';
3
- import { useStore } from '../../ctx/store';
3
+ import clsx from 'clsx';
4
+ import React, { useContext, useEffect } from 'react';
5
+ import { FullResolutionControl } from './fullResolutionControl';
6
+ import { fullResolutionId, pauseTimeToHideAllComponent } from '../../ui/constant';
7
+ import { UIEventContext } from '../../ui/context';
8
+ import { useStore, updateAtom } from '../../ctx/store';
4
9
  import './resolution.less';
5
10
  export const Resolution = props => {
6
- console.log(props, 'props');
7
11
  const {
8
12
  IPCPlayerContext,
9
13
  resolution,
10
- setResolution
14
+ setResolution,
15
+ screenType: screenTypeAtom,
16
+ fullResolutionActive,
17
+ addContent
11
18
  } = props;
12
19
  const {
13
- currentResolution
20
+ currentResolution,
21
+ screenType,
22
+ isFullResolutionActive
14
23
  } = useStore({
15
- currentResolution: resolution
24
+ currentResolution: resolution,
25
+ screenType: screenTypeAtom,
26
+ isFullResolutionActive: fullResolutionActive
16
27
  });
28
+ const {
29
+ event
30
+ } = useContext(UIEventContext);
31
+ console.log(screenType, 'screenType');
17
32
  // const setIsMuted = (value: typeof currentResolution) => {
18
33
  // // updateAtom(mute, value);
19
34
  // };
@@ -23,19 +38,24 @@ export const Resolution = props => {
23
38
  }, []);
24
39
  return /*#__PURE__*/React.createElement(View, {
25
40
  onClick: () => {
26
- console.log('_____');
41
+ if (screenType === 'full') {
42
+ // 添加全屏清晰度空间
43
+ addContent('absolute', {
44
+ id: fullResolutionId,
45
+ content: props => {
46
+ return /*#__PURE__*/React.createElement(FullResolutionControl, props);
47
+ },
48
+ absoluteContentClassName: 'ipc-player-plugin-full-resolution-control-wrap',
49
+ initProps: _objectSpread({}, props)
50
+ });
51
+ updateAtom(fullResolutionActive, true);
52
+ event.emit(pauseTimeToHideAllComponent);
53
+ return false;
54
+ }
27
55
  setResolution(currentResolution === 'HD' ? 'normal' : 'hd');
28
- // // IPCPlayerContext.setMuted({
29
- // // mute: !isMuted,
30
- // // success: res => {
31
- // // setIsMuted(!isMuted);
32
- // // },
33
- // // fail: res => {
34
- // // console.log('res===setMuted err', res);
35
- // // },
36
- // // });
56
+ return true;
37
57
  },
38
- className: "resolutionWrapper"
58
+ className: clsx('ipc-player-plugin-resolution', screenType === 'vertical' ? 'ipc-player-plugin-resolution-vertical' : 'ipc-player-plugin-resolution-full')
39
59
  }, /*#__PURE__*/React.createElement(Text, {
40
60
  className: "resolutionText"
41
61
  }, currentResolution));
@@ -1,15 +1,51 @@
1
- .resolutionWrapper {
1
+ .ipc-player-plugin-resolution {
2
2
  background-color: rgba(255,255,255,0.2);
3
- padding: 2px 4px;
3
+ padding: calc(2px * var(--ipc-player-size-scale, 1)) calc(4px * var(--ipc-player-size-scale, 1));
4
4
  display: flex;
5
5
  justify-content: center;
6
6
  align-items: center;
7
- border-radius: 8rpx;
7
+ border-radius: calc(8px * var(--ipc-player-size-scale, 1));
8
8
  backdrop-filter: blur(8rpx);
9
9
  .resolutionText {
10
- color: #ffffff;
10
+ color: var(--iconColor);
11
11
  font-weight: 600;
12
- font-size: 24rpx;
13
-
12
+ font-size: calc(12px * var(--ipc-player-size-scale, 1));
14
13
  }
15
- }
14
+ }
15
+
16
+ .ipc-player-plugin-full-resolution-control {
17
+ transform: translate(0, 0);
18
+ height: 100%;
19
+ transition: transform 0.3s ease-in, opacity 0.3s ease-in, width 0.3s ease-in;
20
+ width: 200px;
21
+ display: flex;
22
+ flex-direction: column;
23
+ justify-content: center;
24
+ align-items: center;
25
+ background-color: rgba(0,0,0,0.9);
26
+ &.ipc-player-plugin-full-resolution-control-hide {
27
+ transform: translate(300%, 0);
28
+ opacity: 0;
29
+ width: 0;
30
+ }
31
+ }
32
+
33
+ .ipc-player-plugin-full-resolution-control-wrap {
34
+ position: absolute;
35
+ top: 0;
36
+ bottom: 0;
37
+ right: 0;
38
+ display: flex;
39
+ justify-content: center;
40
+ align-items: center;
41
+ // transform: translate(200%, 0);
42
+ z-index: 3;
43
+ }
44
+
45
+ .ipc-player-plugin-full-resolution-control-text {
46
+ font-size: 14px;
47
+ font-weight: 400;
48
+ text-align: center;
49
+ color: #ffffff;
50
+ min-height: 40px;
51
+ }
@@ -9,10 +9,12 @@ export function BottomContent(_ref) {
9
9
  children
10
10
  } = _ref;
11
11
  const {
12
- screenType
12
+ screenType,
13
+ fullResolutionActive
13
14
  } = useStore({
14
15
  screenType: ctx.screenType,
15
- playState: ctx.playState
16
+ playState: ctx.playState,
17
+ fullResolutionActive: ctx.fullResolutionActive
16
18
  });
17
19
  const [shouldHide] = useComponentHideState(screenType);
18
20
  return /*#__PURE__*/React.createElement(CoverView, {
@@ -24,7 +26,7 @@ export function BottomContent(_ref) {
24
26
  '--gap': '25px'
25
27
  },
26
28
  className: clsx('ipc-player-content-item', 'ipc-player-bottom-content', {
27
- 'ipc-player-bottom-content-hide': shouldHide
29
+ 'ipc-player-bottom-content-hide': shouldHide || fullResolutionActive
28
30
  })
29
31
  }, children));
30
32
  }
@@ -3,3 +3,7 @@ export declare const hideAllComponent = "hideAllComponent";
3
3
  export declare const playerTap = "playerTap";
4
4
  export declare const pauseTimeToHideAllComponent = "pauseTimeToHideAllComponent";
5
5
  export declare const startTimeToHideAllComponent = "startTimeToHideAllComponent";
6
+ export declare const voiceIntercomId = "voiceIntercomId";
7
+ export declare const verticalScreenId = "verticalScreenId";
8
+ export declare const ptzControlId = "ptzControlId";
9
+ export declare const fullResolutionId = "fullResolutionId";
@@ -2,4 +2,8 @@ export const showAllComponent = 'showAllComponent';
2
2
  export const hideAllComponent = 'hideAllComponent';
3
3
  export const playerTap = 'playerTap';
4
4
  export const pauseTimeToHideAllComponent = 'pauseTimeToHideAllComponent';
5
- export const startTimeToHideAllComponent = 'startTimeToHideAllComponent';
5
+ export const startTimeToHideAllComponent = 'startTimeToHideAllComponent';
6
+ export const voiceIntercomId = 'voiceIntercomId';
7
+ export const verticalScreenId = 'verticalScreenId';
8
+ export const ptzControlId = 'ptzControlId';
9
+ export const fullResolutionId = 'fullResolutionId';
@@ -9,10 +9,12 @@ export function TopContent(_ref) {
9
9
  children
10
10
  } = _ref;
11
11
  const {
12
- screenType
12
+ screenType,
13
+ fullResolutionActive
13
14
  } = useStore({
14
15
  screenType: ctx.screenType,
15
- playState: ctx.playState
16
+ playState: ctx.playState,
17
+ fullResolutionActive: ctx.fullResolutionActive
16
18
  });
17
19
  const [shouldHide] = useComponentHideState(screenType);
18
20
  return /*#__PURE__*/React.createElement(CoverView, {
@@ -24,7 +26,7 @@ export function TopContent(_ref) {
24
26
  '--gap': '16px'
25
27
  },
26
28
  className: clsx('ipc-player-content-item', 'ipc-player-top-content', {
27
- 'ipc-player-top-content-hide': shouldHide
29
+ 'ipc-player-top-content-hide': shouldHide || fullResolutionActive
28
30
  })
29
31
  }, children));
30
32
  }
package/lib/ui/ui.d.ts CHANGED
@@ -4,6 +4,7 @@ import './ui.less';
4
4
  type CtxInstance = ReturnType<UseCtx>;
5
5
  type CSSVariable = {
6
6
  '--iconColor': string;
7
+ '--iconActiveColor': string;
7
8
  '--iconFontSize': string;
8
9
  '--bg-color': string;
9
10
  '--fontColor': string;
package/lib/ui/ui.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
- import React, { useRef, useMemo, useEffect, useCallback } from 'react';
2
+ import React, { useContext, useRef, useMemo, useEffect, useCallback } from 'react';
3
3
  import { View, CoverView, getSystemInfoSync, usePageEvent } from '@ray-js/ray';
4
4
  import clsx from 'clsx';
5
5
  import IPCPlayer from '@ray-js/ray-ipc-player';
@@ -24,6 +24,8 @@ function getCtxInstance(instance, devId) {
24
24
 
25
25
  const defaultCSSVariable = {
26
26
  '--iconColor': '#fff',
27
+ // 有需要点击呈现不同颜色的icon
28
+ '--iconActiveColor': '#ec653c',
27
29
  '--iconFontSize': '20px',
28
30
  '--bg-color': '#000',
29
31
  '--fontColor': '#fff',
@@ -42,7 +44,8 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
42
44
  console.log(instance, 'instance');
43
45
  const {
44
46
  setPlayState,
45
- setScreenType
47
+ setScreenType,
48
+ setFullResolutionActive
46
49
  } = instance;
47
50
  const prevTriggerEvent = useRef();
48
51
  const eventRef = useRef();
@@ -50,6 +53,9 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
50
53
  if (!eventRef.current) {
51
54
  eventRef.current = getEventInstance();
52
55
  }
56
+ const {
57
+ event
58
+ } = useContext(UIEventContext);
53
59
 
54
60
  /**
55
61
  * 监听屏幕布局变化
@@ -70,13 +76,15 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
70
76
  bottomContent,
71
77
  absoluteContent,
72
78
  screenType,
73
- playState
79
+ playState,
80
+ fullResolutionActive
74
81
  } = useStore({
75
82
  topContent: instance.topContent,
76
83
  bottomContent: instance.bottomContent,
77
84
  absoluteContent: instance.absoluteContent,
78
85
  screenType: instance.screenType,
79
- playState: instance.playState
86
+ playState: instance.playState,
87
+ fullResolutionActive: instance.fullResolutionActive
80
88
  });
81
89
  const renderTopContent = useMemo(() => {
82
90
  if (!topContent || !(topContent !== null && topContent !== void 0 && topContent.length)) return null;
@@ -105,13 +113,22 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
105
113
  const _screenType = store.get(instance.screenType);
106
114
  eventRef.current.emit(playerTap);
107
115
  if (_screenType === 'full') {
116
+ // 如果全屏清晰度展开, 则点击关闭全屏清晰度, 展示所有组件
117
+ if (fullResolutionActive) {
118
+ setFullResolutionActive(false);
119
+ // 展示相应菜单启动自动隐藏定时
120
+ triggerEvent(showAllComponent);
121
+ // event.emit(startTimeToHideAllComponent);
122
+ return false;
123
+ }
108
124
  if (prevTriggerEvent.current === hideAllComponent) {
109
125
  triggerEvent(showAllComponent);
110
126
  } else {
111
127
  triggerEvent(hideAllComponent);
112
128
  }
113
129
  }
114
- }, []);
130
+ return false;
131
+ }, [fullResolutionActive]);
115
132
  const triggerEvent = type => {
116
133
  const store = getDefaultStore();
117
134
  const _screenType = store.get(instance.screenType);
@@ -225,6 +242,7 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
225
242
  ctx: instance
226
243
  }, renderBottomContent), playerReady && (() => {
227
244
  if (!absoluteContent || !(absoluteContent !== null && absoluteContent !== void 0 && absoluteContent.length)) return null;
245
+ console.log(absoluteContent, 'absoluteContent');
228
246
  return absoluteContent.map(item => {
229
247
  return /*#__PURE__*/React.createElement(CoverView, {
230
248
  key: item.id,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/ipc-player-integration",
3
- "version": "0.0.1-beta-12",
3
+ "version": "0.0.1-beta-13",
4
4
  "description": "IPC 播放器功能集成",
5
5
  "main": "lib/index",
6
6
  "files": [
@@ -36,7 +36,8 @@
36
36
  },
37
37
  "dependencies": {
38
38
  "@ray-js/ray-ipc-player": "2.0.18-beta-beta-1",
39
- "@ray-js/ray-ipc-utils": "1.1.0-beta-7",
39
+ "@ray-js/ray-ipc-utils": "1.1.0-beta-12",
40
+ "@ray-js/ipc-ptz-zoom": "0.0.2-beta-1",
40
41
  "clsx": "^1.2.1",
41
42
  "jotai": "^2.10.2"
42
43
  },