@ray-js/ipc-player-integration 0.0.52-beta.5 → 0.0.53-beta.0
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 +6 -1
- package/lib/features/initPlayerWidgets/index.js +9 -0
- package/lib/i18n/index.d.ts +4 -0
- package/lib/i18n/strings.d.ts +2 -0
- package/lib/i18n/strings.js +2 -0
- package/lib/ui/constant.d.ts +7 -0
- package/lib/ui/constant.js +8 -0
- package/lib/ui/ui.js +8 -1
- package/lib/utils/ttt.d.ts +12 -0
- package/lib/utils/ttt.js +58 -2
- package/lib/widgets/resolution/autoClarity.d.ts +13 -0
- package/lib/widgets/resolution/autoClarity.js +110 -0
- package/lib/widgets/resolution/index.d.ts +1 -0
- package/lib/widgets/resolution/index.js +2 -1
- package/lib/widgets/resolution/resolution.less +4 -0
- package/lib/widgets/videoBitKBP/videoBitKBP.js +29 -2
- package/lib/widgets/videoBitKBP/videoBitKBP.less +3 -0
- package/package.json +1 -1
|
@@ -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, Floodlight, Siren, TryExperience, Resolution, Ptz, MultiPtz, TileTip, PtzMoveableTip, LandscapeTip, TileActions, MoveablePtzControl, SwitchLayout, ToggleVerticalFull, RealTimeMagnification, ZoomTurntableEntry } from '../widgets';
|
|
7
|
+
import { FullSmallIntercom, VerticalSmallIntercom, BatteryFull, Battery, Screenshot, TempHumidity, Signal4G, RecordVideo, FullScreen, VideoBitKBP, Muted, Floodlight, Siren, TryExperience, Resolution, AutoClarity, Ptz, MultiPtz, TileTip, PtzMoveableTip, LandscapeTip, TileActions, MoveablePtzControl, SwitchLayout, ToggleVerticalFull, RealTimeMagnification, ZoomTurntableEntry } from '../widgets';
|
|
8
8
|
import { authorizeStatus } from '../utils/authorize';
|
|
9
9
|
import { PlayState } from '../interface';
|
|
10
10
|
import { landscapeTipId, moveablePtzControlId, multiPtzId, ptzMoveableTipId, tileActionsId, tileTipId } from '../ui/constant';
|
|
@@ -74,6 +74,11 @@ export const defaultBottomLeftContent = [{
|
|
|
74
74
|
id: 'RealTimeMagnification',
|
|
75
75
|
content: RealTimeMagnification,
|
|
76
76
|
hidden: true
|
|
77
|
+
}, /* 自动清晰度:仅宿主存在 ttt 方法 clarityChanged 时由 widget 内部渲染 */
|
|
78
|
+
{
|
|
79
|
+
id: 'AutoClarity',
|
|
80
|
+
content: AutoClarity,
|
|
81
|
+
hidden: true
|
|
77
82
|
}];
|
|
78
83
|
export const defaultBottomRightContent = [{
|
|
79
84
|
id: 'SwitchLayout',
|
|
@@ -52,6 +52,15 @@ export async function initPlayerWidgets(ctx, options) {
|
|
|
52
52
|
newDefaultBottomLeftContent[magnificationIndex].hidden = false;
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
|
+
// 自动清晰度入口:这里只放开占位,真正是否渲染由 widget 内部按
|
|
56
|
+
// 「宿主有 ttt 方法 clarityChanged」+「设备支持的清晰度档位 ≥ 2」决定
|
|
57
|
+
{
|
|
58
|
+
const autoClarityIndex = newDefaultBottomLeftContent.findIndex(item => item.id === 'AutoClarity');
|
|
59
|
+
console.log('res===autoClarityIndex', autoClarityIndex);
|
|
60
|
+
if (autoClarityIndex !== -1) {
|
|
61
|
+
newDefaultBottomLeftContent[autoClarityIndex].hidden = false;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
55
64
|
// 焦距转盘入口:这里只放开占位,真正是否渲染由 widget 内部按
|
|
56
65
|
// 「宿主有 ty.ipc.switchChannel」+「ipc_multi_zoom 解析出 cnt > 1」决定
|
|
57
66
|
// (单镜头设备、不支持切镜头的老宿主都不出现)
|
package/lib/i18n/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ declare const Strings: kit.I18N<{
|
|
|
3
3
|
en: {
|
|
4
4
|
ipc_player_resolution_HD: string;
|
|
5
5
|
ipc_player_resolution_SD: string;
|
|
6
|
+
ipc_player_resolution_auto: string;
|
|
6
7
|
ipc_player_current_resolution_is_equal: string;
|
|
7
8
|
ipc_player_screenshot_success_tip: string;
|
|
8
9
|
ipc_player_screenshot_multi_success_tip: string;
|
|
@@ -43,6 +44,7 @@ declare const Strings: kit.I18N<{
|
|
|
43
44
|
zh: {
|
|
44
45
|
ipc_player_resolution_HD: string;
|
|
45
46
|
ipc_player_resolution_SD: string;
|
|
47
|
+
ipc_player_resolution_auto: string;
|
|
46
48
|
ipc_player_current_resolution_is_equal: string;
|
|
47
49
|
ipc_player_screenshot_success_tip: string;
|
|
48
50
|
ipc_player_screenshot_multi_success_tip: string;
|
|
@@ -83,6 +85,7 @@ declare const Strings: kit.I18N<{
|
|
|
83
85
|
}, {
|
|
84
86
|
ipc_player_resolution_HD: string;
|
|
85
87
|
ipc_player_resolution_SD: string;
|
|
88
|
+
ipc_player_resolution_auto: string;
|
|
86
89
|
ipc_player_current_resolution_is_equal: string;
|
|
87
90
|
ipc_player_screenshot_success_tip: string;
|
|
88
91
|
ipc_player_screenshot_multi_success_tip: string;
|
|
@@ -122,6 +125,7 @@ declare const Strings: kit.I18N<{
|
|
|
122
125
|
} | {
|
|
123
126
|
ipc_player_resolution_HD: string;
|
|
124
127
|
ipc_player_resolution_SD: string;
|
|
128
|
+
ipc_player_resolution_auto: string;
|
|
125
129
|
ipc_player_current_resolution_is_equal: string;
|
|
126
130
|
ipc_player_screenshot_success_tip: string;
|
|
127
131
|
ipc_player_screenshot_multi_success_tip: string;
|
package/lib/i18n/strings.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ declare const _default: {
|
|
|
2
2
|
en: {
|
|
3
3
|
ipc_player_resolution_HD: string;
|
|
4
4
|
ipc_player_resolution_SD: string;
|
|
5
|
+
ipc_player_resolution_auto: string;
|
|
5
6
|
ipc_player_current_resolution_is_equal: string;
|
|
6
7
|
ipc_player_screenshot_success_tip: string;
|
|
7
8
|
ipc_player_screenshot_multi_success_tip: string;
|
|
@@ -42,6 +43,7 @@ declare const _default: {
|
|
|
42
43
|
zh: {
|
|
43
44
|
ipc_player_resolution_HD: string;
|
|
44
45
|
ipc_player_resolution_SD: string;
|
|
46
|
+
ipc_player_resolution_auto: string;
|
|
45
47
|
ipc_player_current_resolution_is_equal: string;
|
|
46
48
|
ipc_player_screenshot_success_tip: string;
|
|
47
49
|
ipc_player_screenshot_multi_success_tip: string;
|
package/lib/i18n/strings.js
CHANGED
|
@@ -2,6 +2,7 @@ export default {
|
|
|
2
2
|
en: {
|
|
3
3
|
ipc_player_resolution_HD: 'HD',
|
|
4
4
|
ipc_player_resolution_SD: 'SD',
|
|
5
|
+
ipc_player_resolution_auto: 'Auto',
|
|
5
6
|
ipc_player_current_resolution_is_equal: 'Already at current clarity',
|
|
6
7
|
ipc_player_screenshot_success_tip: 'Screenshot saved to album',
|
|
7
8
|
ipc_player_screenshot_multi_success_tip: 'Screenshots saved to album',
|
|
@@ -42,6 +43,7 @@ export default {
|
|
|
42
43
|
zh: {
|
|
43
44
|
ipc_player_resolution_HD: '高清',
|
|
44
45
|
ipc_player_resolution_SD: '标清',
|
|
46
|
+
ipc_player_resolution_auto: '自动',
|
|
45
47
|
ipc_player_current_resolution_is_equal: '已是当前清晰度',
|
|
46
48
|
ipc_player_screenshot_success_tip: '截图已保存在APP相册',
|
|
47
49
|
ipc_player_screenshot_multi_success_tip: '图片已保存至相册',
|
package/lib/ui/constant.d.ts
CHANGED
|
@@ -33,6 +33,7 @@ export declare const widgetLabs: {
|
|
|
33
33
|
readonly SCREENSHOT: "Screenshot";
|
|
34
34
|
readonly RECORD_VIDEO: "RecordVideo";
|
|
35
35
|
readonly RESOLUTION: "Resolution";
|
|
36
|
+
readonly AUTO_CLARITY: "AutoClarity";
|
|
36
37
|
readonly TRY_EXPERIENCE: "TryExperience";
|
|
37
38
|
readonly FULL_RESOLUTION_CONTROL: "FullResolutionControl";
|
|
38
39
|
readonly MUTED: "Muted";
|
|
@@ -60,6 +61,12 @@ export declare const widgetLabs: {
|
|
|
60
61
|
*/
|
|
61
62
|
export declare const bottomLeftContentResize = "bottomLeftContentResize";
|
|
62
63
|
export declare const zoomLevelChange = "zoomLevelChange";
|
|
64
|
+
/**
|
|
65
|
+
* 自动清晰度状态变化事件:AutoClarity 控件开启/关闭自动模式或收到 clarityChanged
|
|
66
|
+
* 回调结果时触发,携带 { enabled, clarity }(clarity 为 'HD' | 'SD' | null)。
|
|
67
|
+
* VideoBitKBP 监听此事件,在码率前展示当前高清/标清文案。
|
|
68
|
+
*/
|
|
69
|
+
export declare const autoClarityChange = "autoClarityChange";
|
|
63
70
|
export declare const setScaleMultipleEvent = "setScaleMultipleEvent";
|
|
64
71
|
export declare const decodeClarityDic: {
|
|
65
72
|
SS: string;
|
package/lib/ui/constant.js
CHANGED
|
@@ -35,6 +35,7 @@ export const widgetLabs = {
|
|
|
35
35
|
SCREENSHOT: 'Screenshot',
|
|
36
36
|
RECORD_VIDEO: 'RecordVideo',
|
|
37
37
|
RESOLUTION: 'Resolution',
|
|
38
|
+
AUTO_CLARITY: 'AutoClarity',
|
|
38
39
|
TRY_EXPERIENCE: 'TryExperience',
|
|
39
40
|
FULL_RESOLUTION_CONTROL: 'FullResolutionControl',
|
|
40
41
|
MUTED: 'Muted',
|
|
@@ -63,6 +64,13 @@ export const widgetLabs = {
|
|
|
63
64
|
*/
|
|
64
65
|
export const bottomLeftContentResize = 'bottomLeftContentResize';
|
|
65
66
|
export const zoomLevelChange = 'zoomLevelChange';
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* 自动清晰度状态变化事件:AutoClarity 控件开启/关闭自动模式或收到 clarityChanged
|
|
70
|
+
* 回调结果时触发,携带 { enabled, clarity }(clarity 为 'HD' | 'SD' | null)。
|
|
71
|
+
* VideoBitKBP 监听此事件,在码率前展示当前高清/标清文案。
|
|
72
|
+
*/
|
|
73
|
+
export const autoClarityChange = 'autoClarityChange';
|
|
66
74
|
export const setScaleMultipleEvent = 'setScaleMultipleEvent';
|
|
67
75
|
export const decodeClarityDic = {
|
|
68
76
|
SS: 'ss',
|
package/lib/ui/ui.js
CHANGED
|
@@ -23,7 +23,7 @@ import { useMemoizedFn } from '../hooks';
|
|
|
23
23
|
import { Storage } from '../utils/storage';
|
|
24
24
|
import './ui.less';
|
|
25
25
|
import { updatePlayerWidgetProps } from '../features';
|
|
26
|
-
import { getNgRawData, getSmartImageQualityState, isLowPhone } from '../utils/ttt';
|
|
26
|
+
import { getNgRawData, getSmartImageQualityState, isLowPhone, isOfflineForStream } from '../utils/ttt';
|
|
27
27
|
import { getCaptureResultSummary } from '../utils/captureResult';
|
|
28
28
|
import { lensCount } from '../widgets/zoomTurntable/lensSkill';
|
|
29
29
|
import { shouldRenderContent } from './absoluteContent';
|
|
@@ -153,6 +153,13 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
153
153
|
});
|
|
154
154
|
}, []);
|
|
155
155
|
|
|
156
|
+
// 设备离线时通知宿主视频流状态;isOfflineForStream 内部兼容没有该 TTT 方法的宿主。
|
|
157
|
+
useEffect(() => {
|
|
158
|
+
if (!deviceOnline) {
|
|
159
|
+
isOfflineForStream(devId);
|
|
160
|
+
}
|
|
161
|
+
}, [deviceOnline, devId]);
|
|
162
|
+
|
|
156
163
|
// 展示顶部内容
|
|
157
164
|
const [showTopContent, setShowTopContent] = useState(true);
|
|
158
165
|
|
package/lib/utils/ttt.d.ts
CHANGED
|
@@ -38,4 +38,16 @@ export declare function getAIFrameFeature(devId: string): Promise<GetAIFrameFeat
|
|
|
38
38
|
export declare function setAIFrameFeature(params: SetAIFrameFeatureParams): Promise<any>;
|
|
39
39
|
export declare function setTrailFinish(devId: string): Promise<unknown>;
|
|
40
40
|
export declare function isLowPhone(): Promise<boolean>;
|
|
41
|
+
/**
|
|
42
|
+
* 通知宿主当前视频流对应的设备已离线。
|
|
43
|
+
*
|
|
44
|
+
* 这个 TTT 方法不是所有宿主都提供,因此调用前必须做能力判断;
|
|
45
|
+
* 老宿主或 Web 环境下直接跳过,不能影响播放器自身的离线处理。
|
|
46
|
+
*/
|
|
47
|
+
export declare function isOfflineForStream(devId: string): boolean;
|
|
41
48
|
export declare function getNgRawData(): Promise<unknown>;
|
|
49
|
+
export declare function isClarityChangedSupported(): boolean;
|
|
50
|
+
export type ClarityChangedResult = {
|
|
51
|
+
clarity: 'HD' | 'SD';
|
|
52
|
+
};
|
|
53
|
+
export declare function clarityChanged(devId: string): Promise<ClarityChangedResult | null>;
|
package/lib/utils/ttt.js
CHANGED
|
@@ -120,10 +120,33 @@ export function isLowPhone() {
|
|
|
120
120
|
}
|
|
121
121
|
});
|
|
122
122
|
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* 通知宿主当前视频流对应的设备已离线。
|
|
126
|
+
*
|
|
127
|
+
* 这个 TTT 方法不是所有宿主都提供,因此调用前必须做能力判断;
|
|
128
|
+
* 老宿主或 Web 环境下直接跳过,不能影响播放器自身的离线处理。
|
|
129
|
+
*/
|
|
130
|
+
export function isOfflineForStream(devId) {
|
|
131
|
+
var _ty3;
|
|
132
|
+
const method = (_ty3 = ty) === null || _ty3 === void 0 || (_ty3 = _ty3.ipc) === null || _ty3 === void 0 ? void 0 : _ty3.isOfflineForStream;
|
|
133
|
+
if (typeof method !== 'function') {
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
try {
|
|
137
|
+
method({
|
|
138
|
+
devId
|
|
139
|
+
});
|
|
140
|
+
return true;
|
|
141
|
+
} catch (error) {
|
|
142
|
+
console.warn('res===isOfflineForStream fail', error);
|
|
143
|
+
return false;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
123
146
|
export function getNgRawData() {
|
|
124
147
|
return new Promise(resolve => {
|
|
125
|
-
var
|
|
126
|
-
const isSupport = typeof ((
|
|
148
|
+
var _ty4;
|
|
149
|
+
const isSupport = typeof ((_ty4 = ty) === null || _ty4 === void 0 ? void 0 : _ty4.getNgRawData) === 'function';
|
|
127
150
|
if (!isSupport) {
|
|
128
151
|
resolve(false);
|
|
129
152
|
return;
|
|
@@ -142,4 +165,37 @@ export function getNgRawData() {
|
|
|
142
165
|
resolve(false);
|
|
143
166
|
}
|
|
144
167
|
});
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// 是否支持自动清晰度(ttt 方法 clarityChanged 存在即支持)
|
|
171
|
+
export function isClarityChangedSupported() {
|
|
172
|
+
var _ty$ipc6;
|
|
173
|
+
return typeof ((_ty$ipc6 = ty.ipc) === null || _ty$ipc6 === void 0 ? void 0 : _ty$ipc6.clarityChanged) === 'function';
|
|
174
|
+
}
|
|
175
|
+
export function clarityChanged(devId) {
|
|
176
|
+
return new Promise(resolve => {
|
|
177
|
+
var _ty$ipc7;
|
|
178
|
+
if (typeof ((_ty$ipc7 = ty.ipc) === null || _ty$ipc7 === void 0 ? void 0 : _ty$ipc7.clarityChanged) !== 'function') {
|
|
179
|
+
resolve(null);
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
if (!isClarityChangedSupported()) {
|
|
183
|
+
resolve(null);
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
try {
|
|
187
|
+
ty.ipc.clarityChanged({
|
|
188
|
+
devId,
|
|
189
|
+
success: res => {
|
|
190
|
+
resolve(res !== null && res !== void 0 ? res : null);
|
|
191
|
+
},
|
|
192
|
+
fail: e => {
|
|
193
|
+
console.warn('res===clarityChanged fail', e);
|
|
194
|
+
resolve(null);
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
} catch (e) {
|
|
198
|
+
resolve(null);
|
|
199
|
+
}
|
|
200
|
+
});
|
|
145
201
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ComponentConfigProps } from '../../interface';
|
|
3
|
+
import './resolution.less';
|
|
4
|
+
type Props = ComponentConfigProps & {
|
|
5
|
+
className?: string;
|
|
6
|
+
};
|
|
7
|
+
export declare const AUTO_CLARITY_STORAGE_KEY = "autoClarity";
|
|
8
|
+
export type AutoClarityMemory = {
|
|
9
|
+
enabled: boolean;
|
|
10
|
+
clarity: 'HD' | 'SD' | null;
|
|
11
|
+
};
|
|
12
|
+
export declare const AutoClarity: (props: Props) => React.JSX.Element;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import React, { useContext, useEffect, useState } from 'react';
|
|
2
|
+
import { View, Text } from '@ray-js/ray';
|
|
3
|
+
import clsx from 'clsx';
|
|
4
|
+
import Strings from '../../i18n';
|
|
5
|
+
import { useStore } from '../../ctx/store';
|
|
6
|
+
import { storage } from '../../utils/storage';
|
|
7
|
+
import { UIEventContext } from '../../ui/context';
|
|
8
|
+
import { widgetClick, widgetLabs, autoClarityChange } from '../../ui/constant';
|
|
9
|
+
import { clarityChanged } from '../../utils/ttt';
|
|
10
|
+
import './resolution.less';
|
|
11
|
+
// 自动清晰度记忆 storage key(按设备维度隔离由 storage 内部 prefix 处理)
|
|
12
|
+
export const AUTO_CLARITY_STORAGE_KEY = 'autoClarity';
|
|
13
|
+
export const AutoClarity = props => {
|
|
14
|
+
const {
|
|
15
|
+
className,
|
|
16
|
+
devId
|
|
17
|
+
} = props;
|
|
18
|
+
const {
|
|
19
|
+
screenType,
|
|
20
|
+
resolutionList
|
|
21
|
+
} = useStore({
|
|
22
|
+
screenType: props.screenType,
|
|
23
|
+
resolutionList: props.resolutionList
|
|
24
|
+
});
|
|
25
|
+
const {
|
|
26
|
+
event
|
|
27
|
+
} = useContext(UIEventContext);
|
|
28
|
+
|
|
29
|
+
// 是否处于自动模式
|
|
30
|
+
const [auto, setAuto] = useState(false);
|
|
31
|
+
|
|
32
|
+
// 广播自动清晰度状态给 VideoBitKBP 等监听方
|
|
33
|
+
const emitClarity = (enabled, clarity) => {
|
|
34
|
+
event.emit(autoClarityChange, {
|
|
35
|
+
enabled,
|
|
36
|
+
clarity
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
// 进入时恢复上次退出时的选择
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
const cached = storage.getSync(AUTO_CLARITY_STORAGE_KEY);
|
|
43
|
+
if (cached !== null && cached !== void 0 && cached.enabled) {
|
|
44
|
+
var _cached$clarity;
|
|
45
|
+
setAuto(true);
|
|
46
|
+
emitClarity(true, (_cached$clarity = cached.clarity) !== null && _cached$clarity !== void 0 ? _cached$clarity : null);
|
|
47
|
+
// 恢复自动模式后重新拉取一次当前清晰度
|
|
48
|
+
clarityChanged(devId).then(res => {
|
|
49
|
+
if (res !== null && res !== void 0 && res.clarity) {
|
|
50
|
+
emitClarity(true, res.clarity);
|
|
51
|
+
storage.set(AUTO_CLARITY_STORAGE_KEY, {
|
|
52
|
+
enabled: true,
|
|
53
|
+
clarity: res.clarity
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
} else {
|
|
58
|
+
emitClarity(false, null);
|
|
59
|
+
}
|
|
60
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
61
|
+
}, [devId]);
|
|
62
|
+
|
|
63
|
+
// TODO: 后面取消注释 宿主不存在 ttt 方法 clarityChanged 时整个入口不渲染
|
|
64
|
+
// if (!isClarityChangedSupported()) {
|
|
65
|
+
// return null;
|
|
66
|
+
// }
|
|
67
|
+
|
|
68
|
+
// TODO: 后面取消注释 设备支持的清晰度档位数量 ≥ 2 时才展示自动
|
|
69
|
+
// if (!resolutionList || resolutionList.length < 2) {
|
|
70
|
+
// return null;
|
|
71
|
+
// }
|
|
72
|
+
|
|
73
|
+
return /*#__PURE__*/React.createElement(View, {
|
|
74
|
+
onClick: async () => {
|
|
75
|
+
var _res$clarity;
|
|
76
|
+
event.emit(widgetClick, {
|
|
77
|
+
widgetId: widgetLabs.AUTO_CLARITY
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
// 关闭自动模式
|
|
81
|
+
if (auto) {
|
|
82
|
+
setAuto(false);
|
|
83
|
+
emitClarity(false, null);
|
|
84
|
+
storage.set(AUTO_CLARITY_STORAGE_KEY, {
|
|
85
|
+
enabled: false,
|
|
86
|
+
clarity: null
|
|
87
|
+
});
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// 开启自动模式并读取回调结果
|
|
92
|
+
setAuto(true);
|
|
93
|
+
const res = await clarityChanged(devId);
|
|
94
|
+
const next = (_res$clarity = res === null || res === void 0 ? void 0 : res.clarity) !== null && _res$clarity !== void 0 ? _res$clarity : null;
|
|
95
|
+
emitClarity(true, next);
|
|
96
|
+
storage.set(AUTO_CLARITY_STORAGE_KEY, {
|
|
97
|
+
enabled: true,
|
|
98
|
+
clarity: next
|
|
99
|
+
});
|
|
100
|
+
},
|
|
101
|
+
className: clsx(className)
|
|
102
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
103
|
+
className: clsx('ipc-player-plugin-resolution', {
|
|
104
|
+
'ipc-player-plugin-resolution-full': screenType === 'full',
|
|
105
|
+
'ipc-player-plugin-resolution-active': auto
|
|
106
|
+
})
|
|
107
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
108
|
+
className: "resolutionText"
|
|
109
|
+
}, Strings.getLang('ipc_player_resolution_auto'))));
|
|
110
|
+
};
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export * from './resolution';
|
|
1
|
+
export * from './resolution';
|
|
2
|
+
export * from './autoClarity';
|
|
@@ -21,6 +21,10 @@
|
|
|
21
21
|
border-radius: calc(5px * var(--ipc-player-size-scale, 1));
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
.ipc-player-plugin-resolution-active {
|
|
25
|
+
background-color: var(--brandColor, rgba(255, 89, 42, 0.9));
|
|
26
|
+
}
|
|
27
|
+
|
|
24
28
|
.ipc-player-plugin-full-resolution-control {
|
|
25
29
|
height: 100%;
|
|
26
30
|
width: 200px;
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
import React, { useEffect, useRef, useState } from 'react';
|
|
1
|
+
import React, { useContext, useEffect, useRef, useState } from 'react';
|
|
2
2
|
import { View, Text, usePageEvent } from '@ray-js/ray';
|
|
3
3
|
import clsx from 'clsx';
|
|
4
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';
|
|
8
|
+
import Strings from '../../i18n';
|
|
9
|
+
import { UIEventContext } from '../../ui/context';
|
|
10
|
+
import { autoClarityChange } from '../../ui/constant';
|
|
11
|
+
import { storage } from '../../utils/storage';
|
|
12
|
+
import { AUTO_CLARITY_STORAGE_KEY } from '../resolution/autoClarity';
|
|
8
13
|
export const VideoBitKBP = props => {
|
|
9
14
|
const {
|
|
10
15
|
devId,
|
|
@@ -15,10 +20,30 @@ export const VideoBitKBP = props => {
|
|
|
15
20
|
} = props;
|
|
16
21
|
const [bitKBP, setBitKBP] = useState('');
|
|
17
22
|
const [signalStrength, setSignalStrength] = useState(null);
|
|
23
|
+
// 自动清晰度当前档位:null 表示未开启自动模式,不展示
|
|
24
|
+
const [autoClarity, setAutoClarity] = useState(() => {
|
|
25
|
+
var _cached$clarity;
|
|
26
|
+
const cached = storage.getSync(AUTO_CLARITY_STORAGE_KEY);
|
|
27
|
+
return cached !== null && cached !== void 0 && cached.enabled ? (_cached$clarity = cached.clarity) !== null && _cached$clarity !== void 0 ? _cached$clarity : null : null;
|
|
28
|
+
});
|
|
18
29
|
const store = useStore({
|
|
19
30
|
playState
|
|
20
31
|
});
|
|
32
|
+
const {
|
|
33
|
+
event
|
|
34
|
+
} = useContext(UIEventContext);
|
|
21
35
|
const timerRef = useRef();
|
|
36
|
+
|
|
37
|
+
// 监听 AutoClarity 控件广播的自动清晰度状态
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
const onAutoClarityChange = payload => {
|
|
40
|
+
setAutoClarity(payload.enabled ? payload.clarity : null);
|
|
41
|
+
};
|
|
42
|
+
event.on(autoClarityChange, onAutoClarityChange);
|
|
43
|
+
return () => {
|
|
44
|
+
event.off(autoClarityChange, onAutoClarityChange);
|
|
45
|
+
};
|
|
46
|
+
}, [event]);
|
|
22
47
|
useEffect(() => {
|
|
23
48
|
if (store.playState === PlayState.PLAYING && (!hideKbsMenu || !hideSignalMenu)) {
|
|
24
49
|
init();
|
|
@@ -75,7 +100,9 @@ export const VideoBitKBP = props => {
|
|
|
75
100
|
className: "ipc-player-plugin-videoBitKBP-divider"
|
|
76
101
|
}), hasKbps && /*#__PURE__*/React.createElement(View, {
|
|
77
102
|
className: "ipc-player-plugin-videoBitKBP-kbps"
|
|
78
|
-
},
|
|
103
|
+
}, autoClarity && /*#__PURE__*/React.createElement(Text, {
|
|
104
|
+
className: "ipc-player-plugin-videoBitKBP-clarity"
|
|
105
|
+
}, autoClarity === 'HD' ? Strings.getLang('ipc_player_resolution_HD') : Strings.getLang('ipc_player_resolution_SD')), /*#__PURE__*/React.createElement(Text, null, bitKBP), /*#__PURE__*/React.createElement(Text, {
|
|
79
106
|
className: "ipc-player-plugin-videoBitKBP-unit-kbs"
|
|
80
107
|
}, "KB/S"))));
|
|
81
108
|
};
|
|
@@ -36,6 +36,9 @@
|
|
|
36
36
|
display: flex;
|
|
37
37
|
align-items: center;
|
|
38
38
|
}
|
|
39
|
+
.ipc-player-plugin-videoBitKBP-clarity {
|
|
40
|
+
margin-right: calc(4px * var(--ipc-player-size-scale, 1));
|
|
41
|
+
}
|
|
39
42
|
.ipc-player-plugin-videoBitKBP-unit-kbs {
|
|
40
43
|
margin-left: calc(4px * var(--ipc-player-size-scale, 1));
|
|
41
44
|
}
|