@ray-js/ipc-player-integration 0.0.30 → 0.0.31-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.
- package/lib/ctx/ctx.composition.js +10 -3
- package/lib/ctx/ctx.js +8 -0
- package/lib/ctx/ports.output.d.ts +1 -0
- package/lib/features/initPlayerWidgets/index.d.ts +2 -0
- package/lib/features/initPlayerWidgets/index.js +8 -1
- package/lib/iconfont/iconfont.css +204 -4
- package/lib/iconfont/iconfont.js +6 -6
- package/lib/iconfont/iconfont.json +351 -1
- package/lib/iconfont/iconfont.ttf +0 -0
- package/lib/iconfont/iconfont.woff +0 -0
- package/lib/iconfont/iconfont.woff2 +0 -0
- package/lib/interface.d.ts +1 -0
- package/lib/ui/constant.d.ts +2 -0
- package/lib/ui/constant.js +2 -0
- package/lib/ui/context.d.ts +1 -0
- package/lib/ui/context.js +2 -1
- package/lib/ui/hooks.js +3 -2
- package/lib/ui/ui.d.ts +1 -0
- package/lib/ui/ui.js +38 -16
- package/lib/widgets/index.d.ts +1 -0
- package/lib/widgets/index.js +2 -1
- package/lib/widgets/muted/muted.js +3 -1
- package/lib/widgets/realTimeMagnification/index.d.ts +1 -0
- package/lib/widgets/realTimeMagnification/index.js +1 -0
- package/lib/widgets/realTimeMagnification/realTimeMagnification.d.ts +8 -0
- package/lib/widgets/realTimeMagnification/realTimeMagnification.js +91 -0
- package/lib/widgets/realTimeMagnification/realTimeMagnification.less +20 -0
- package/lib/widgets/videoBitKBP/videoBitKBP.d.ts +1 -0
- package/lib/widgets/videoBitKBP/videoBitKBP.js +38 -11
- package/lib/widgets/videoBitKBP/videoBitKBP.less +41 -16
- package/package.json +1 -1
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
2
|
+
import { View, Text } from '@ray-js/ray';
|
|
3
|
+
import clsx from 'clsx';
|
|
4
|
+
import { PlayState } from '../../interface';
|
|
5
|
+
import { useStore } from '../../ctx/store';
|
|
6
|
+
import { zoomLevelChange, setScaleMultipleEvent, pauseTimeToHideAllComponent, startTimeToHideAllComponent } from '../../ui/constant';
|
|
7
|
+
import './realTimeMagnification.less';
|
|
8
|
+
|
|
9
|
+
/** 全量档位列表 */
|
|
10
|
+
const ALL_ZOOM_LEVELS = [1, 2, 4, 6, 8, 12];
|
|
11
|
+
export const RealTimeMagnification = props => {
|
|
12
|
+
const {
|
|
13
|
+
playState,
|
|
14
|
+
event,
|
|
15
|
+
className,
|
|
16
|
+
screenType: screenTypeAtom,
|
|
17
|
+
maxZoomSettings: maxZoomAtom
|
|
18
|
+
} = props;
|
|
19
|
+
const {
|
|
20
|
+
playState: currentPlayState,
|
|
21
|
+
screenType,
|
|
22
|
+
maxZoomSettings
|
|
23
|
+
} = useStore({
|
|
24
|
+
playState,
|
|
25
|
+
screenType: screenTypeAtom,
|
|
26
|
+
maxZoomSettings: maxZoomAtom
|
|
27
|
+
});
|
|
28
|
+
const [currentZoom, setCurrentZoom] = useState(1);
|
|
29
|
+
|
|
30
|
+
/** 根据 maxZoomSettings 动态生成可用档位列表 */
|
|
31
|
+
const zoomLevels = useMemo(() => {
|
|
32
|
+
const max = maxZoomSettings || 6;
|
|
33
|
+
const levels = ALL_ZOOM_LEVELS.filter(level => level <= max);
|
|
34
|
+
// 若最大值不在预设档位中,追加到末尾
|
|
35
|
+
if (max > 1 && levels[levels.length - 1] !== max) {
|
|
36
|
+
levels.push(max);
|
|
37
|
+
}
|
|
38
|
+
return levels;
|
|
39
|
+
}, [maxZoomSettings]);
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
const onZoomChange = zoomLevel => {
|
|
42
|
+
if (zoomLevel > 0) {
|
|
43
|
+
setCurrentZoom(zoomLevel);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
event.on(zoomLevelChange, onZoomChange);
|
|
47
|
+
return () => {
|
|
48
|
+
event.off(zoomLevelChange, onZoomChange);
|
|
49
|
+
};
|
|
50
|
+
}, [event]);
|
|
51
|
+
|
|
52
|
+
/** 获取当前倍数对应的档位显示值(取最接近且 <= currentZoom 的档位) */
|
|
53
|
+
const getDisplayZoom = useCallback(() => {
|
|
54
|
+
for (let i = zoomLevels.length - 1; i >= 0; i--) {
|
|
55
|
+
if (currentZoom >= zoomLevels[i]) {
|
|
56
|
+
return zoomLevels[i];
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return zoomLevels[0];
|
|
60
|
+
}, [currentZoom, zoomLevels]);
|
|
61
|
+
|
|
62
|
+
/** 获取下一档倍数,循环切换 */
|
|
63
|
+
const getNextZoom = useCallback(() => {
|
|
64
|
+
const display = getDisplayZoom();
|
|
65
|
+
const currentIndex = zoomLevels.indexOf(display);
|
|
66
|
+
const nextIndex = (currentIndex + 1) % zoomLevels.length;
|
|
67
|
+
return zoomLevels[nextIndex];
|
|
68
|
+
}, [getDisplayZoom, zoomLevels]);
|
|
69
|
+
|
|
70
|
+
/** 点击切换到下一档倍数 */
|
|
71
|
+
const handleClick = useCallback(() => {
|
|
72
|
+
event.emit(pauseTimeToHideAllComponent);
|
|
73
|
+
const nextZoom = getNextZoom();
|
|
74
|
+
console.log('RealTimeMagnification click', 'currentZoom:', currentZoom, 'nextZoom:', nextZoom);
|
|
75
|
+
event.emit(setScaleMultipleEvent, nextZoom);
|
|
76
|
+
event.emit(startTimeToHideAllComponent);
|
|
77
|
+
}, [getNextZoom, event, currentZoom]);
|
|
78
|
+
if (currentPlayState !== PlayState.PLAYING) {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
return /*#__PURE__*/React.createElement(View, {
|
|
82
|
+
onClick: handleClick,
|
|
83
|
+
className: clsx(className)
|
|
84
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
85
|
+
className: clsx('ipc-player-plugin-realtime-magnification', {
|
|
86
|
+
'ipc-player-plugin-realtime-magnification-full': screenType === 'full'
|
|
87
|
+
})
|
|
88
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
89
|
+
className: "magnificationText"
|
|
90
|
+
}, currentZoom.toFixed(1), "X")));
|
|
91
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
.ipc-player-plugin-realtime-magnification {
|
|
2
|
+
background-color: rgba(255, 255, 255, 0.3);
|
|
3
|
+
padding: calc(4px * var(--ipc-player-size-scale, 1)) calc(5px * var(--ipc-player-size-scale, 1));
|
|
4
|
+
display: flex;
|
|
5
|
+
justify-content: center;
|
|
6
|
+
align-items: center;
|
|
7
|
+
border-radius: calc(4px * var(--ipc-player-size-scale, 1));
|
|
8
|
+
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
|
9
|
+
overflow: hidden;
|
|
10
|
+
.magnificationText {
|
|
11
|
+
color: var(--iconColor);
|
|
12
|
+
font-weight: 600;
|
|
13
|
+
font-size: calc(12px * var(--ipc-player-size-scale, 1));
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
.ipc-player-plugin-realtime-magnification-full {
|
|
17
|
+
padding-left: calc(8px * var(--ipc-player-size-scale, 1));
|
|
18
|
+
padding-right: calc(8px * var(--ipc-player-size-scale, 1));
|
|
19
|
+
border-radius: calc(5px * var(--ipc-player-size-scale, 1));
|
|
20
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useEffect, useRef, useState } from 'react';
|
|
2
|
-
import { View, usePageEvent } from '@ray-js/ray';
|
|
2
|
+
import { View, Text, usePageEvent } from '@ray-js/ray';
|
|
3
3
|
import clsx from 'clsx';
|
|
4
|
-
import { getVideoBitrateKbps } from '@ray-js/ray-ipc-utils';
|
|
4
|
+
import { getVideoBitrateKbps, requestWifiSignal } from '@ray-js/ray-ipc-utils';
|
|
5
5
|
import { PlayState } from '../../interface';
|
|
6
6
|
import './videoBitKBP.less';
|
|
7
7
|
import { useStore } from '../../ctx/store';
|
|
@@ -10,15 +10,17 @@ export const VideoBitKBP = props => {
|
|
|
10
10
|
devId,
|
|
11
11
|
playState,
|
|
12
12
|
className,
|
|
13
|
-
hideKbsMenu
|
|
13
|
+
hideKbsMenu,
|
|
14
|
+
hideSignalMenu
|
|
14
15
|
} = props;
|
|
15
16
|
const [bitKBP, setBitKBP] = useState('');
|
|
17
|
+
const [signalStrength, setSignalStrength] = useState(null);
|
|
16
18
|
const store = useStore({
|
|
17
19
|
playState
|
|
18
20
|
});
|
|
19
21
|
const timerRef = useRef();
|
|
20
22
|
useEffect(() => {
|
|
21
|
-
if (store.playState === PlayState.PLAYING && !hideKbsMenu) {
|
|
23
|
+
if (store.playState === PlayState.PLAYING && (!hideKbsMenu || !hideSignalMenu)) {
|
|
22
24
|
init();
|
|
23
25
|
timerRef.current = setInterval(() => {
|
|
24
26
|
init();
|
|
@@ -29,20 +31,33 @@ export const VideoBitKBP = props => {
|
|
|
29
31
|
return () => {
|
|
30
32
|
clearInterval(timerRef.current);
|
|
31
33
|
};
|
|
32
|
-
}, [store.playState, hideKbsMenu]);
|
|
34
|
+
}, [store.playState, hideKbsMenu, hideSignalMenu]);
|
|
33
35
|
usePageEvent('onUnload', () => {
|
|
34
36
|
clearInterval(timerRef.current);
|
|
35
37
|
});
|
|
36
38
|
const init = async () => {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
if (!hideKbsMenu) {
|
|
40
|
+
const res = await getVideoBitrateKbps(devId);
|
|
41
|
+
if (res.code !== -1) {
|
|
42
|
+
setBitKBP(res.data.kbps);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (!hideSignalMenu) {
|
|
46
|
+
const signalRes = await requestWifiSignal(devId);
|
|
47
|
+
if (signalRes.code !== -1) {
|
|
48
|
+
const val = Number(signalRes.data);
|
|
49
|
+
if (!isNaN(val)) {
|
|
50
|
+
setSignalStrength(val);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
40
53
|
}
|
|
41
54
|
};
|
|
42
|
-
|
|
55
|
+
const hasKbps = !hideKbsMenu && bitKBP !== '' && bitKBP !== '0';
|
|
56
|
+
const hasSignal = !hideSignalMenu && signalStrength !== null;
|
|
57
|
+
if (!hasKbps && !hasSignal || store.playState !== PlayState.PLAYING) {
|
|
43
58
|
return null;
|
|
44
59
|
}
|
|
45
|
-
if (hideKbsMenu) return null;
|
|
60
|
+
if (hideKbsMenu && hideSignalMenu) return null;
|
|
46
61
|
return /*#__PURE__*/React.createElement(View, {
|
|
47
62
|
className: clsx({
|
|
48
63
|
'ipc-player-plugin-videoBitKBP-container': true,
|
|
@@ -50,5 +65,17 @@ export const VideoBitKBP = props => {
|
|
|
50
65
|
})
|
|
51
66
|
}, /*#__PURE__*/React.createElement(View, {
|
|
52
67
|
className: "ipc-player-plugin-videoBitKBP"
|
|
53
|
-
},
|
|
68
|
+
}, hasSignal && /*#__PURE__*/React.createElement(View, {
|
|
69
|
+
className: "ipc-player-plugin-videoBitKBP-signal"
|
|
70
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
71
|
+
className: clsx('icon-panel', 'icon-panel-wi-Fi', 'ipc-player-plugin-videoBitKBP-signal-icon')
|
|
72
|
+
}), /*#__PURE__*/React.createElement(Text, null, signalStrength), /*#__PURE__*/React.createElement(Text, {
|
|
73
|
+
className: "ipc-player-plugin-videoBitKBP-unit-percent"
|
|
74
|
+
}, signalStrength > 0 ? '%' : 'dBm')), hasSignal && hasKbps && /*#__PURE__*/React.createElement(View, {
|
|
75
|
+
className: "ipc-player-plugin-videoBitKBP-divider"
|
|
76
|
+
}), hasKbps && /*#__PURE__*/React.createElement(View, {
|
|
77
|
+
className: "ipc-player-plugin-videoBitKBP-kbps"
|
|
78
|
+
}, /*#__PURE__*/React.createElement(Text, null, bitKBP), /*#__PURE__*/React.createElement(Text, {
|
|
79
|
+
className: "ipc-player-plugin-videoBitKBP-unit-kbs"
|
|
80
|
+
}, "KB/S"))));
|
|
54
81
|
};
|
|
@@ -1,19 +1,44 @@
|
|
|
1
1
|
.ipc-player-plugin-videoBitKBP-container {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
min-width: calc(92px * var(--ipc-player-size-scale, 1));
|
|
3
|
+
display: flex;
|
|
4
|
+
justify-content: center;
|
|
5
|
+
align-items: center;
|
|
6
6
|
}
|
|
7
7
|
.ipc-player-plugin-videoBitKBP {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
8
|
+
display: flex;
|
|
9
|
+
align-items: center;
|
|
10
|
+
justify-content: center;
|
|
11
|
+
width: 100%;
|
|
12
|
+
height: calc(24px * var(--ipc-player-size-scale, 1));
|
|
13
|
+
padding: 0 calc(6px * var(--ipc-player-size-scale, 1));
|
|
14
|
+
border-radius: calc(24px * var(--ipc-player-size-scale, 1));
|
|
15
|
+
color: var(--iconColor);
|
|
16
|
+
font-size: calc(12px * var(--ipc-player-size-scale, 1));
|
|
17
|
+
font-weight: 500;
|
|
18
|
+
background-color: rgba(255, 255, 255, 0.2);
|
|
19
|
+
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
|
20
|
+
}
|
|
21
|
+
.ipc-player-plugin-videoBitKBP-signal {
|
|
22
|
+
display: flex;
|
|
23
|
+
align-items: center;
|
|
24
|
+
}
|
|
25
|
+
.ipc-player-plugin-videoBitKBP-signal-icon {
|
|
26
|
+
font-size: calc(14px * var(--ipc-player-size-scale, 1));
|
|
27
|
+
margin-right: calc(4px * var(--ipc-player-size-scale, 1));
|
|
28
|
+
}
|
|
29
|
+
.ipc-player-plugin-videoBitKBP-divider {
|
|
30
|
+
width: 1px;
|
|
31
|
+
height: calc(10px * var(--ipc-player-size-scale, 1));
|
|
32
|
+
background-color: var(--iconColor);
|
|
33
|
+
margin: 0 calc(4px * var(--ipc-player-size-scale, 1));
|
|
34
|
+
}
|
|
35
|
+
.ipc-player-plugin-videoBitKBP-kbps {
|
|
36
|
+
display: flex;
|
|
37
|
+
align-items: center;
|
|
38
|
+
}
|
|
39
|
+
.ipc-player-plugin-videoBitKBP-unit-kbs {
|
|
40
|
+
margin-left: calc(4px * var(--ipc-player-size-scale, 1));
|
|
41
|
+
}
|
|
42
|
+
.ipc-player-plugin-videoBitKBP-unit-percent {
|
|
43
|
+
margin-left: calc(2px * var(--ipc-player-size-scale, 1));
|
|
44
|
+
}
|