@ray-js/ipc-player-integration 0.0.1-beta-36 → 0.0.1-beta-37
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.
- package/lib/ctx/ctx.composition.js +0 -1
- package/lib/ctx/ctx.js +1 -1
- package/lib/plugins/ptz/ptz.less +6 -0
- package/lib/plugins/ptz/ptzControl.js +2 -1
- package/lib/plugins/resolution/resolution.d.ts +1 -1
- package/lib/plugins/resolution/resolution.js +28 -27
- package/lib/plugins/voiceIntercom/voiceIntercom.js +35 -8
- package/lib/utils/plugins/index.d.ts +3 -1
- package/lib/utils/plugins/index.js +10 -2
- package/package.json +2 -2
package/lib/ctx/ctx.js
CHANGED
|
@@ -82,8 +82,8 @@ export const createUseCtx = _ref => {
|
|
|
82
82
|
console.log('==== getMemoryState ====', res);
|
|
83
83
|
_setMute(res.mute);
|
|
84
84
|
setIntercomMode(res.intercomMode);
|
|
85
|
-
_setResolution(res.resolution);
|
|
86
85
|
setResolutionList(res.resolutionList);
|
|
86
|
+
_setResolution(res.resolution);
|
|
87
87
|
});
|
|
88
88
|
}
|
|
89
89
|
}, [devId, _playState]);
|
package/lib/plugins/ptz/ptz.less
CHANGED
|
@@ -72,7 +72,8 @@ export const PtzControl = props => {
|
|
|
72
72
|
}, []);
|
|
73
73
|
return /*#__PURE__*/React.createElement(CoverView, {
|
|
74
74
|
className: clsx('ipc-player-plugin-full-screen-ptz-control', {
|
|
75
|
-
'ipc-player-plugin-full-screen-ptz-control-hide': shouldHide || !isPtzActive
|
|
75
|
+
'ipc-player-plugin-full-screen-ptz-control-hide': shouldHide || !isPtzActive,
|
|
76
|
+
'ipc-player-plugin-full-screen-ptz-disappear': screenType === 'vertical'
|
|
76
77
|
})
|
|
77
78
|
}, /*#__PURE__*/React.createElement(IpcPtzZoom, {
|
|
78
79
|
ptzSize: "172px",
|
|
@@ -4,7 +4,7 @@ import './resolution.less';
|
|
|
4
4
|
export type ChangeResolutionWhenClick = ScreenType[];
|
|
5
5
|
type Props = ComponentConfigProps & {
|
|
6
6
|
className?: string;
|
|
7
|
-
|
|
7
|
+
verticalResolutionCustomClick?: boolean;
|
|
8
8
|
};
|
|
9
9
|
export declare const Resolution: (props: Props) => React.JSX.Element;
|
|
10
10
|
export {};
|
|
@@ -2,13 +2,13 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
|
2
2
|
import { View, Text } from '@ray-js/ray';
|
|
3
3
|
import clsx from 'clsx';
|
|
4
4
|
import React, { useContext } from 'react';
|
|
5
|
+
import { useMemoizedFn } from 'ahooks';
|
|
5
6
|
import Strings from '../../i18n';
|
|
6
7
|
import { FullResolutionControl } from './fullResolutionControl';
|
|
7
8
|
import { fullResolutionId, pauseTimeToHideAllComponent, hideAllComponent } from '../../ui/constant';
|
|
8
9
|
import { UIEventContext } from '../../ui/context';
|
|
9
10
|
import { useStore } from '../../ctx/store';
|
|
10
11
|
import './resolution.less';
|
|
11
|
-
const defaultChangeResolutionWhenClick = ['full'];
|
|
12
12
|
export const Resolution = props => {
|
|
13
13
|
const {
|
|
14
14
|
IPCPlayerContext,
|
|
@@ -16,7 +16,7 @@ export const Resolution = props => {
|
|
|
16
16
|
addContent,
|
|
17
17
|
hasContent,
|
|
18
18
|
className,
|
|
19
|
-
|
|
19
|
+
verticalResolutionCustomClick
|
|
20
20
|
} = props;
|
|
21
21
|
const {
|
|
22
22
|
resolution,
|
|
@@ -28,32 +28,33 @@ export const Resolution = props => {
|
|
|
28
28
|
const {
|
|
29
29
|
event
|
|
30
30
|
} = useContext(UIEventContext);
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
if (
|
|
36
|
-
event.emit(
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
initProps: _objectSpread({}, props)
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
return false;
|
|
50
|
-
}
|
|
51
|
-
if (screenType === 'vertical' && defaultChangeResolutionWhenClick.includes(screenType)) {
|
|
52
|
-
setResolution(resolution === 'HD' ? 'SD' : 'HD');
|
|
31
|
+
const onResolution = useMemoizedFn(() => {
|
|
32
|
+
event.emit('resolutionBtnControlClick');
|
|
33
|
+
if (screenType === 'full') {
|
|
34
|
+
event.emit(hideAllComponent);
|
|
35
|
+
if (hasContent('absolute', fullResolutionId)) {
|
|
36
|
+
event.emit('showFullResolutionControl');
|
|
37
|
+
} else {
|
|
38
|
+
addContent('absolute', {
|
|
39
|
+
id: fullResolutionId,
|
|
40
|
+
content: props => {
|
|
41
|
+
return /*#__PURE__*/React.createElement(FullResolutionControl, props);
|
|
42
|
+
},
|
|
43
|
+
absoluteContentClassName: 'ipc-player-plugin-full-resolution-control-wrap',
|
|
44
|
+
initProps: _objectSpread({}, props)
|
|
45
|
+
});
|
|
53
46
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
if (verticalResolutionCustomClick) return false;
|
|
50
|
+
if (screenType === 'vertical') {
|
|
51
|
+
setResolution(resolution === 'HD' ? 'SD' : 'HD');
|
|
52
|
+
}
|
|
53
|
+
event.emit(pauseTimeToHideAllComponent);
|
|
54
|
+
return true;
|
|
55
|
+
});
|
|
56
|
+
return /*#__PURE__*/React.createElement(View, {
|
|
57
|
+
onClick: onResolution,
|
|
57
58
|
className: clsx(className, screenType === 'vertical' ? 'ipc-player-plugin-resolution-vertical' : 'ipc-player-plugin-resolution-full')
|
|
58
59
|
}, /*#__PURE__*/React.createElement(View, {
|
|
59
60
|
className: "ipc-player-plugin-resolution"
|
|
@@ -30,6 +30,8 @@ export const VoiceIntercom = props => {
|
|
|
30
30
|
} = props;
|
|
31
31
|
const [frame, setFrame] = useState(0);
|
|
32
32
|
const talkingInterval = useRef(null);
|
|
33
|
+
// 每帧间隔(ms)
|
|
34
|
+
|
|
33
35
|
const {
|
|
34
36
|
event
|
|
35
37
|
} = useContext(UIEventContext);
|
|
@@ -79,18 +81,43 @@ export const VoiceIntercom = props => {
|
|
|
79
81
|
await setIntercom(false);
|
|
80
82
|
event.emit(startTimeToHideAllComponent);
|
|
81
83
|
};
|
|
84
|
+
// 获取 requestAnimationFrame 和兼容性回退
|
|
85
|
+
const requestFrame = callback => {
|
|
86
|
+
if (typeof requestAnimationFrame !== 'undefined') {
|
|
87
|
+
return requestAnimationFrame(callback);
|
|
88
|
+
}
|
|
89
|
+
return setTimeout(callback, 30); // 使用 setTimeout 模拟帧更新
|
|
90
|
+
};
|
|
91
|
+
const cancelFrame = id => {
|
|
92
|
+
if (typeof cancelAnimationFrame !== 'undefined') {
|
|
93
|
+
cancelAnimationFrame(id);
|
|
94
|
+
} else {
|
|
95
|
+
clearTimeout(id); // 清除 setTimeout
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
|
|
82
99
|
/**
|
|
83
100
|
* 处理对讲中动画
|
|
84
101
|
*/
|
|
85
102
|
useEffect(() => {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
103
|
+
const updateFrame = () => {
|
|
104
|
+
setFrame(prevFrame => (prevFrame + 1) % 124);
|
|
105
|
+
talkingInterval.current = requestFrame(updateFrame);
|
|
106
|
+
};
|
|
107
|
+
const stopAnimation = () => {
|
|
108
|
+
if (talkingInterval.current) {
|
|
109
|
+
cancelFrame(talkingInterval.current);
|
|
110
|
+
talkingInterval.current = null;
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
intercom ? (() => {
|
|
114
|
+
if (!talkingInterval.current) {
|
|
115
|
+
talkingInterval.current = requestFrame(updateFrame);
|
|
116
|
+
}
|
|
117
|
+
})() : stopAnimation();
|
|
118
|
+
return () => {
|
|
119
|
+
stopAnimation();
|
|
120
|
+
};
|
|
94
121
|
}, [intercom]);
|
|
95
122
|
|
|
96
123
|
// 根据当前帧和矩形索引计算高度
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { UseCtx } from '../../interface';
|
|
2
2
|
type Ctx = ReturnType<UseCtx>;
|
|
3
|
-
export declare function initPlayerPlugins(ctx: Ctx
|
|
3
|
+
export declare function initPlayerPlugins(ctx: Ctx, options: {
|
|
4
|
+
verticalResolutionCustomClick?: boolean;
|
|
5
|
+
}): Promise<void>;
|
|
4
6
|
export {};
|
|
@@ -1,11 +1,19 @@
|
|
|
1
|
+
import _cloneDeep from 'lodash/cloneDeep';
|
|
1
2
|
import { defaultTopLeftContent, defaultTopRightContent, defaultBottomLeftContent, defaultBottomRightContent } from '../../ctx';
|
|
2
3
|
import { hasDpCode } from '../../utils/device';
|
|
3
4
|
import { MoveInteractiveControlButton } from '../../plugins/moveInteractiveControl';
|
|
4
5
|
// 根据当前 dp 信息决定设置哪些 plugin
|
|
5
|
-
export async function initPlayerPlugins(ctx) {
|
|
6
|
+
export async function initPlayerPlugins(ctx, options) {
|
|
6
7
|
ctx.addContent('topLeft', defaultTopLeftContent);
|
|
7
8
|
ctx.addContent('topRight', defaultTopRightContent);
|
|
8
|
-
|
|
9
|
+
const newDefaultBottomLeftContent = _cloneDeep(defaultBottomLeftContent);
|
|
10
|
+
const resolutionIndex = newDefaultBottomLeftContent.findIndex(item => item.id === 'Resolution');
|
|
11
|
+
if (resolutionIndex !== -1) {
|
|
12
|
+
newDefaultBottomLeftContent[resolutionIndex].initProps = {
|
|
13
|
+
verticalResolutionCustomClick: options.verticalResolutionCustomClick
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
ctx.addContent('bottomLeft', newDefaultBottomLeftContent);
|
|
9
17
|
ctx.addContent('bottomRight', defaultBottomRightContent);
|
|
10
18
|
|
|
11
19
|
// 根据 ipc_manual_petting 是否存在,决定是否要插入控件 moveInteractiveControl
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ray-js/ipc-player-integration",
|
|
3
|
-
"version": "0.0.1-beta-
|
|
3
|
+
"version": "0.0.1-beta-37",
|
|
4
4
|
"description": "IPC 播放器功能集成",
|
|
5
5
|
"main": "lib/index",
|
|
6
6
|
"files": [
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"ahooks": "^3.1.6"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@ray-js/ipc-ptz-zoom": "0.0.2-beta-
|
|
39
|
+
"@ray-js/ipc-ptz-zoom": "0.0.2-beta-6",
|
|
40
40
|
"@ray-js/panel-sdk": "^1.13.1",
|
|
41
41
|
"@ray-js/ray-ipc-player": "2.0.20-beta-6",
|
|
42
42
|
"@ray-js/ray-ipc-utils": "1.1.0-beta-13",
|