@ray-js/ipc-player-integration 0.0.1-beta-35 → 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 +8 -2
- package/lib/ctx/event.d.ts +8 -0
- package/lib/ctx/event.js +26 -0
- package/lib/interface.d.ts +7 -0
- package/lib/plugins/battery/battery.composition.d.ts +2 -0
- package/lib/plugins/battery/battery.less +1 -2
- package/lib/plugins/fullScreen/fullScreen.js +3 -5
- 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/tempHumidity/tempHumidity.js +2 -2
- package/lib/plugins/tempHumidity/tempHumidity.less +6 -3
- package/lib/plugins/videoBitKBP/videoBitKBP.less +1 -1
- package/lib/plugins/voiceIntercom/voiceIntercom.js +35 -8
- package/lib/ui/bottomLeftContent.js +1 -1
- package/lib/ui/bottomRightContent.js +1 -1
- package/lib/ui/ui.js +21 -13
- package/lib/ui/ui.less +15 -0
- 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
|
@@ -3,6 +3,7 @@ import Strings from '../i18n';
|
|
|
3
3
|
import { useAtom, updateAtom, getDefaultStore, useStore } from './store';
|
|
4
4
|
import { PlayState, IntercomMode } from '../interface';
|
|
5
5
|
import { ClarityType } from '@ray-js/ray-ipc-utils/lib/interface';
|
|
6
|
+
import { getEventInstance } from './event';
|
|
6
7
|
const SAVE_TO_ALBUM = 1;
|
|
7
8
|
export const createUseCtx = _ref => {
|
|
8
9
|
let {
|
|
@@ -70,6 +71,10 @@ export const createUseCtx = _ref => {
|
|
|
70
71
|
} = useStore({
|
|
71
72
|
_playState: playState
|
|
72
73
|
});
|
|
74
|
+
const eventRef = useRef();
|
|
75
|
+
if (!eventRef.current) {
|
|
76
|
+
eventRef.current = getEventInstance();
|
|
77
|
+
}
|
|
73
78
|
useEffect(() => {
|
|
74
79
|
if (devId && _playState === PlayState.PLAYING) {
|
|
75
80
|
// 获取缓存的值且同步
|
|
@@ -77,8 +82,8 @@ export const createUseCtx = _ref => {
|
|
|
77
82
|
console.log('==== getMemoryState ====', res);
|
|
78
83
|
_setMute(res.mute);
|
|
79
84
|
setIntercomMode(res.intercomMode);
|
|
80
|
-
_setResolution(res.resolution);
|
|
81
85
|
setResolutionList(res.resolutionList);
|
|
86
|
+
_setResolution(res.resolution);
|
|
82
87
|
});
|
|
83
88
|
}
|
|
84
89
|
}, [devId, _playState]);
|
|
@@ -335,7 +340,8 @@ export const createUseCtx = _ref => {
|
|
|
335
340
|
getStreamStatus: () => {
|
|
336
341
|
return streamStatus.current;
|
|
337
342
|
},
|
|
338
|
-
toast
|
|
343
|
+
toast,
|
|
344
|
+
event: eventRef.current
|
|
339
345
|
};
|
|
340
346
|
};
|
|
341
347
|
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
type Task = (...args: any[]) => void;
|
|
2
|
+
export type EventInstance = {
|
|
3
|
+
on: (type: string, cb: Task) => void;
|
|
4
|
+
off: (type: string, cb: Task) => void;
|
|
5
|
+
emit: (type: string, ...args: any[]) => void;
|
|
6
|
+
};
|
|
7
|
+
export declare function getEventInstance(): EventInstance;
|
|
8
|
+
export {};
|
package/lib/ctx/event.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export function getEventInstance() {
|
|
2
|
+
const map = {};
|
|
3
|
+
return {
|
|
4
|
+
on(type, cb) {
|
|
5
|
+
if (!map[type]) {
|
|
6
|
+
map[type] = [];
|
|
7
|
+
}
|
|
8
|
+
map[type].push(cb);
|
|
9
|
+
},
|
|
10
|
+
off(type, cb) {
|
|
11
|
+
if (map[type]) {
|
|
12
|
+
map[type] = map[type].filter(item => item !== cb);
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
emit(type) {
|
|
16
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
17
|
+
args[_key - 1] = arguments[_key];
|
|
18
|
+
}
|
|
19
|
+
if (map[type]) {
|
|
20
|
+
map[type].forEach(cb => {
|
|
21
|
+
cb && cb.apply(null, args); // eslint-disable-line
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
package/lib/interface.d.ts
CHANGED
|
@@ -25,6 +25,12 @@ export declare const enum PlayState {
|
|
|
25
25
|
PAUSE = 2
|
|
26
26
|
}
|
|
27
27
|
export type ContentPlaceType = 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight' | 'absolute';
|
|
28
|
+
type Task = (...args: any[]) => void;
|
|
29
|
+
export type EventInstance = {
|
|
30
|
+
on: (type: string, cb: Task) => void;
|
|
31
|
+
off: (type: string, cb: Task) => void;
|
|
32
|
+
emit: (type: string, ...args: any[]) => void;
|
|
33
|
+
};
|
|
28
34
|
export type UseCtx = (options: {
|
|
29
35
|
devId: string;
|
|
30
36
|
initTopLeftContent?: ComponentConfig[];
|
|
@@ -71,6 +77,7 @@ export type UseCtx = (options: {
|
|
|
71
77
|
hideContent: (type: ContentPlaceType, id: string) => void;
|
|
72
78
|
showContent: (type: ContentPlaceType, id: string) => void;
|
|
73
79
|
toast: Toast;
|
|
80
|
+
event: EventInstance;
|
|
74
81
|
};
|
|
75
82
|
export type ComponentConfig<T = ReturnType<UseCtx> & Record<string, any>> = {
|
|
76
83
|
id: string;
|
|
@@ -39,6 +39,7 @@ export declare const Battery: import("react").FunctionComponent<{
|
|
|
39
39
|
hideContent: (type: import("../..").ContentPlaceType, id: string) => void;
|
|
40
40
|
showContent: (type: import("../..").ContentPlaceType, id: string) => void;
|
|
41
41
|
toast: import("../../ports.output").Toast;
|
|
42
|
+
event: import("../../interface").EventInstance;
|
|
42
43
|
} & {
|
|
43
44
|
className?: string | undefined;
|
|
44
45
|
}>;
|
|
@@ -82,6 +83,7 @@ export declare const BatteryFull: import("react").FunctionComponent<{
|
|
|
82
83
|
hideContent: (type: import("../..").ContentPlaceType, id: string) => void;
|
|
83
84
|
showContent: (type: import("../..").ContentPlaceType, id: string) => void;
|
|
84
85
|
toast: import("../../ports.output").Toast;
|
|
86
|
+
event: import("../../interface").EventInstance;
|
|
85
87
|
} & {
|
|
86
88
|
className?: string | undefined;
|
|
87
89
|
}>;
|
|
@@ -4,9 +4,8 @@
|
|
|
4
4
|
height: calc(24px * var(--ipc-player-size-scale, 1));
|
|
5
5
|
padding: 0 calc(9px * var(--ipc-player-size-scale, 1));
|
|
6
6
|
border-radius: calc(24px * var(--ipc-player-size-scale, 1));
|
|
7
|
-
background-color: rgba(255, 255, 255, 0.
|
|
7
|
+
background-color: rgba(255, 255, 255, 0.2);
|
|
8
8
|
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
|
9
|
-
// backdrop-filter: blur(10px);
|
|
10
9
|
|
|
11
10
|
.ipc-player-plugin-battery-border {
|
|
12
11
|
position: relative;
|
|
@@ -93,19 +93,17 @@ export function FullScreen(props) {
|
|
|
93
93
|
handleFull();
|
|
94
94
|
},
|
|
95
95
|
vertical: () => {
|
|
96
|
-
event.emit(pauseTimeToHideAllComponent);
|
|
97
96
|
ty.setNavigationBarBack({
|
|
98
97
|
type: 'system'
|
|
99
98
|
});
|
|
100
|
-
ty.showMenuButton();
|
|
101
|
-
ty.showStatusBar();
|
|
102
99
|
event.emit(pauseTimeToHideAllComponent);
|
|
103
|
-
deleteContent('topLeft', verticalScreenId);
|
|
104
100
|
deleteContent('absolute', voiceIntercomId);
|
|
105
101
|
deleteContent('absolute', ptzControlId);
|
|
102
|
+
deleteContent('topLeft', verticalScreenId);
|
|
106
103
|
deleteContent('absolute', fullResolutionId);
|
|
107
104
|
deleteContent('absolute', fullTravelRouteControlId);
|
|
108
|
-
|
|
105
|
+
ty.showMenuButton();
|
|
106
|
+
ty.showStatusBar();
|
|
109
107
|
}
|
|
110
108
|
};
|
|
111
109
|
useUpdateEffect(() => {
|
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"
|
|
@@ -48,9 +48,9 @@ export const TempHumidity = props => {
|
|
|
48
48
|
className: clsx('ipc-player-plugin-tempHumidity')
|
|
49
49
|
}, (() => {
|
|
50
50
|
if ((tempC || tempUnit === '1' && tempF) && humidity) {
|
|
51
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, tempRender(), /*#__PURE__*/React.createElement(
|
|
51
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, tempRender(), /*#__PURE__*/React.createElement(View, {
|
|
52
52
|
className: "ipc-player-plugin-tempHumidity-divider"
|
|
53
|
-
}
|
|
53
|
+
}), humRender());
|
|
54
54
|
}
|
|
55
55
|
if (tempC || tempUnit === '1' && tempF) {
|
|
56
56
|
return /*#__PURE__*/React.createElement(React.Fragment, null, tempRender());
|
|
@@ -6,13 +6,16 @@
|
|
|
6
6
|
border-radius: calc(24px * var(--ipc-player-size-scale, 1));
|
|
7
7
|
color: var(--iconColor);
|
|
8
8
|
font-size: calc(12px * var(--ipc-player-size-scale, 1));
|
|
9
|
-
background-color: rgba(255, 255, 255, 0.
|
|
9
|
+
background-color: rgba(255, 255, 255, 0.2);
|
|
10
10
|
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
.ipc-player-plugin-tempHumidity-divider {
|
|
14
|
-
margin: calc(
|
|
15
|
-
color:
|
|
14
|
+
margin: calc(6px * var(--ipc-player-size-scale, 1));
|
|
15
|
+
color: rgba(0,0,0,0.2);
|
|
16
|
+
width: calc(1px * var(--ipc-player-size-scale, 1));
|
|
17
|
+
height: calc(12px * var(--ipc-player-size-scale, 1));
|
|
18
|
+
background-color: rgba(255, 255, 255, 0.2);
|
|
16
19
|
}
|
|
17
20
|
|
|
18
21
|
// .text-icon-tempHumidity {
|
|
@@ -6,6 +6,6 @@
|
|
|
6
6
|
border-radius: calc(24px * var(--ipc-player-size-scale, 1));
|
|
7
7
|
color: var(--iconColor);
|
|
8
8
|
font-size: calc(12px * var(--ipc-player-size-scale, 1));
|
|
9
|
-
background-color: rgba(255, 255, 255, 0.
|
|
9
|
+
background-color: rgba(255, 255, 255, 0.2);
|
|
10
10
|
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
|
11
11
|
}
|
|
@@ -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
|
// 根据当前帧和矩形索引计算高度
|
|
@@ -19,7 +19,7 @@ const BottomLeftContent = _ref => {
|
|
|
19
19
|
className: clsx('ipc-player-bottom-left-content-wrap')
|
|
20
20
|
}, /*#__PURE__*/React.createElement(View, {
|
|
21
21
|
style: {
|
|
22
|
-
paddingBottom: screenType === 'vertical' ? '14px' : '
|
|
22
|
+
paddingBottom: screenType === 'vertical' ? '14px' : '32px',
|
|
23
23
|
paddingLeft: screenType === 'vertical' ? 0 : '25px'
|
|
24
24
|
},
|
|
25
25
|
className: clsx('ipc-player-bottom-left-content-container', {
|
|
@@ -19,7 +19,7 @@ const BottomRightContent = _ref => {
|
|
|
19
19
|
className: clsx('ipc-player-bottom-right-content-wrap')
|
|
20
20
|
}, /*#__PURE__*/React.createElement(View, {
|
|
21
21
|
style: {
|
|
22
|
-
paddingBottom: screenType === 'vertical' ? '14px' : '
|
|
22
|
+
paddingBottom: screenType === 'vertical' ? '14px' : '32px',
|
|
23
23
|
paddingRight: screenType === 'vertical' ? 0 : '25px'
|
|
24
24
|
},
|
|
25
25
|
className: clsx('ipc-player-bottom-right-content-container', {
|
package/lib/ui/ui.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
-
import React, {
|
|
2
|
+
import React, { useState, useRef, useMemo, useEffect, useImperativeHandle } 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';
|
|
6
6
|
import { PlayState, PlayerStreamStatus } from '../interface';
|
|
7
7
|
import { useCtx } from '../ctx/ctx.composition';
|
|
8
8
|
import { useStore } from '../ctx/store';
|
|
9
|
-
import { getEventInstance } from './event';
|
|
10
9
|
import { UIEventContext } from './context';
|
|
11
10
|
import { showAllComponent, hideAllComponent, playerTap, startTimeToHideAllComponent, pauseTimeToHideAllComponent } from './constant';
|
|
12
11
|
import BottomLeftContent from './bottomLeftContent';
|
|
@@ -67,19 +66,16 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
67
66
|
*/
|
|
68
67
|
const [componentHideState, setComponentHideState] = useState(false);
|
|
69
68
|
prevTriggerEvent.current = componentHideState ? hideAllComponent : showAllComponent;
|
|
70
|
-
const eventRef = useRef();
|
|
69
|
+
const eventRef = useRef(instance.event);
|
|
70
|
+
if (eventRef.current !== instance.event) {
|
|
71
|
+
eventRef.current = instance.event;
|
|
72
|
+
}
|
|
71
73
|
useImperativeHandle(eventRefProp, () => eventRef.current, [eventRef.current]);
|
|
72
74
|
const timer = useRef();
|
|
73
|
-
if (!eventRef.current) {
|
|
74
|
-
eventRef.current = getEventInstance();
|
|
75
|
-
}
|
|
76
75
|
useEffect(() => {
|
|
77
76
|
setBrandColor(brandColor);
|
|
78
77
|
setVerticalMic(verticalMic);
|
|
79
78
|
}, []);
|
|
80
|
-
const {
|
|
81
|
-
event
|
|
82
|
-
} = useContext(UIEventContext);
|
|
83
79
|
|
|
84
80
|
/**
|
|
85
81
|
* 监听屏幕布局变化
|
|
@@ -159,9 +155,11 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
159
155
|
}, instance), {}, {
|
|
160
156
|
IPCPlayerContext: instance.IPCPlayerInstance,
|
|
161
157
|
// 添加通用变量单独组件类名
|
|
162
|
-
className: clsx('bottom-left-item-container'
|
|
158
|
+
className: clsx('bottom-left-item-container', {
|
|
159
|
+
'bottom-left-item-full-container': screenType === 'full'
|
|
160
|
+
})
|
|
163
161
|
})));
|
|
164
|
-
}, [bottomLeftContent, instance]);
|
|
162
|
+
}, [bottomLeftContent, instance, screenType]);
|
|
165
163
|
|
|
166
164
|
/**
|
|
167
165
|
* 渲染播放器右下角内容
|
|
@@ -181,6 +179,10 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
181
179
|
* 视频流加载状态封装
|
|
182
180
|
*/
|
|
183
181
|
|
|
182
|
+
const disablePlayerTap = useRef(false);
|
|
183
|
+
const handDisablePlayerTap = value => {
|
|
184
|
+
disablePlayerTap.current = !!value;
|
|
185
|
+
};
|
|
184
186
|
const triggerEvent = type => {
|
|
185
187
|
if (prevTriggerEvent.current === type) return;
|
|
186
188
|
if (timer.current) {
|
|
@@ -220,11 +222,13 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
220
222
|
eventRef.current.on(pauseTimeToHideAllComponent, listenPause);
|
|
221
223
|
eventRef.current.on(showAllComponent, listenShowEvent);
|
|
222
224
|
eventRef.current.on(hideAllComponent, listenHideEvent);
|
|
225
|
+
eventRef.current.on('disablePlayerTap', handDisablePlayerTap);
|
|
223
226
|
return () => {
|
|
224
227
|
eventRef.current.off(startTimeToHideAllComponent, listenStart);
|
|
225
228
|
eventRef.current.off(pauseTimeToHideAllComponent, listenPause);
|
|
226
229
|
eventRef.current.off(showAllComponent, listenShowEvent);
|
|
227
230
|
eventRef.current.off(hideAllComponent, listenHideEvent);
|
|
231
|
+
eventRef.current.off('disablePlayerTap', handDisablePlayerTap);
|
|
228
232
|
};
|
|
229
233
|
}, []);
|
|
230
234
|
const playerReady = playState === PlayState.PLAYING;
|
|
@@ -284,6 +288,10 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
284
288
|
clarity: resolution === 'HD' ? 'hd' : 'normal',
|
|
285
289
|
privateState: privateState,
|
|
286
290
|
onPlayerTap: data => {
|
|
291
|
+
if (disablePlayerTap.current) {
|
|
292
|
+
console.log('playerTap 事件已禁止');
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
287
295
|
console.log('res===on onVideoTap', data);
|
|
288
296
|
eventRef.current.emit(playerTap);
|
|
289
297
|
console.log(prevTriggerEvent.current, 'prevTriggerEvent.current');
|
|
@@ -292,7 +300,7 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
292
300
|
} else {
|
|
293
301
|
triggerEvent(hideAllComponent);
|
|
294
302
|
}
|
|
295
|
-
return false;
|
|
303
|
+
return false; // eslint-disable-line
|
|
296
304
|
} // 对应原来的onVideoTap
|
|
297
305
|
}), /*#__PURE__*/React.createElement(View, {
|
|
298
306
|
className: clsx('ipc-player-top-content', {
|
|
@@ -312,7 +320,7 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
312
320
|
'ipc-player-bottom-content-show': !componentHideState
|
|
313
321
|
}),
|
|
314
322
|
style: {
|
|
315
|
-
height: screenType === 'vertical' ? '48px' : '
|
|
323
|
+
height: screenType === 'vertical' ? '48px' : '72px'
|
|
316
324
|
}
|
|
317
325
|
}, /*#__PURE__*/React.createElement(BottomLeftContent, {
|
|
318
326
|
ctx: instance
|
package/lib/ui/ui.less
CHANGED
|
@@ -203,6 +203,21 @@
|
|
|
203
203
|
padding: 0 0 0 16px;
|
|
204
204
|
}
|
|
205
205
|
|
|
206
|
+
// 左下角全屏子元素容器
|
|
207
|
+
.bottom-left-item-full-container {
|
|
208
|
+
padding: 0 24px !important;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
.bottom-left-item-full-container:first-of-type {
|
|
212
|
+
padding: 0 24px 0 16px !important;
|
|
213
|
+
}
|
|
214
|
+
.bottom-left-item-full-container:last-of-type {
|
|
215
|
+
padding: 0 0 0 24px !important;
|
|
216
|
+
}
|
|
217
|
+
.bottom-left-item-full-container:only-of-type{
|
|
218
|
+
padding: 0 0 0 16px !important;
|
|
219
|
+
}
|
|
220
|
+
|
|
206
221
|
// 右下角子元素容器
|
|
207
222
|
.bottom-right-item-container {
|
|
208
223
|
padding: 0 8px;
|
|
@@ -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",
|