@ray-js/ipc-player-integration 0.0.53-beta.3 → 0.0.53-beta.5
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.js
CHANGED
|
@@ -12,6 +12,7 @@ import { changeIgnoreHideStopPreview } from '../ui/constant';
|
|
|
12
12
|
import { ClarityType } from '@ray-js/ray-ipc-utils/lib/interface';
|
|
13
13
|
import { getEventInstance } from './event';
|
|
14
14
|
import { isMultiCameraTileSupported, useMultiCameraCtx } from './multiCameraCtx';
|
|
15
|
+
import { isClarityChangedSupported } from '../utils/ttt';
|
|
15
16
|
const SAVE_TO_ALBUM = 1;
|
|
16
17
|
export const createUseCtx = _ref => {
|
|
17
18
|
let {
|
|
@@ -111,12 +112,21 @@ export const createUseCtx = _ref => {
|
|
|
111
112
|
}
|
|
112
113
|
|
|
113
114
|
/**
|
|
114
|
-
*
|
|
115
|
+
* 只有宿主支持自动清晰度事件,且接口返回的清晰度档位数量不少于 2 个时,才展示 AUTO:
|
|
115
116
|
* 竖屏宿主弹框(由 resolutionList 构建 actionData)与横屏 FullResolutionControl 共用。
|
|
116
117
|
*/
|
|
118
|
+
const canShowAutoClarity = function () {
|
|
119
|
+
let list = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
120
|
+
return isClarityChangedSupported() && list.length >= 2;
|
|
121
|
+
};
|
|
117
122
|
const withAutoClarity = function () {
|
|
118
123
|
let list = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
119
|
-
|
|
124
|
+
const withoutAuto = list.filter(clarity => clarity !== ClarityType.AUTO);
|
|
125
|
+
return canShowAutoClarity(list) ? [...withoutAuto, ClarityType.AUTO] : withoutAuto;
|
|
126
|
+
};
|
|
127
|
+
const normalizeResolution = (resolution, list) => {
|
|
128
|
+
if (resolution !== ClarityType.AUTO || canShowAutoClarity(list)) return resolution;
|
|
129
|
+
return list.find(clarity => clarity !== ClarityType.AUTO) || ClarityType.HD;
|
|
120
130
|
};
|
|
121
131
|
useEffect(() => {
|
|
122
132
|
// 初始化获取缓存值
|
|
@@ -127,7 +137,7 @@ export const createUseCtx = _ref => {
|
|
|
127
137
|
var _res$maxZoomSettings;
|
|
128
138
|
const res = await getMemoryState(devId);
|
|
129
139
|
setResolutionList(withAutoClarity(res.resolutionList));
|
|
130
|
-
_setResolution(res.resolution, true);
|
|
140
|
+
_setResolution(normalizeResolution(res.resolution, res.resolutionList), true);
|
|
131
141
|
_setMute(res.mute, true);
|
|
132
142
|
setIntercomMode(res.intercomMode);
|
|
133
143
|
setIntercomSupported(res.isIntercomSupported);
|
|
@@ -144,7 +154,7 @@ export const createUseCtx = _ref => {
|
|
|
144
154
|
var _res$maxZoomSettings2;
|
|
145
155
|
setResolutionList(withAutoClarity(res.resolutionList));
|
|
146
156
|
// 传true表示值即可,会取播放器的值
|
|
147
|
-
_setResolution(res.resolution, true);
|
|
157
|
+
_setResolution(normalizeResolution(res.resolution, res.resolutionList), true);
|
|
148
158
|
_setMute(res.mute, true);
|
|
149
159
|
setIntercomMode(res.intercomMode);
|
|
150
160
|
setIntercomSupported(res.isIntercomSupported);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
2
|
import { View, Text } from '@ray-js/ray';
|
|
3
3
|
import clsx from 'clsx';
|
|
4
|
-
import React, { useContext, useEffect } from 'react';
|
|
4
|
+
import React, { useContext, useEffect, useRef } from 'react';
|
|
5
5
|
import { useMemoizedFn } from 'ahooks';
|
|
6
6
|
import { ClarityType } from '@ray-js/ray-ipc-utils/lib/interface';
|
|
7
7
|
import Strings from '../../i18n';
|
|
@@ -31,6 +31,7 @@ export const Resolution = props => {
|
|
|
31
31
|
const {
|
|
32
32
|
event
|
|
33
33
|
} = useContext(UIEventContext);
|
|
34
|
+
const autoClarityRef = useRef(null);
|
|
34
35
|
|
|
35
36
|
// 广播自动清晰度状态给 VideoBitKBP 等监听方;
|
|
36
37
|
// 自动模式下监听当前实际清晰度,仅用于码率区域展示。
|
|
@@ -42,15 +43,18 @@ export const Resolution = props => {
|
|
|
42
43
|
});
|
|
43
44
|
};
|
|
44
45
|
if (resolution !== ClarityType.AUTO) {
|
|
46
|
+
autoClarityRef.current = null;
|
|
45
47
|
emitClarity(false, null);
|
|
46
48
|
return undefined;
|
|
47
49
|
}
|
|
48
|
-
|
|
50
|
+
// 横竖屏切换会重新布局码率区域,重放最近一次实际清晰度,避免前缀丢失。
|
|
51
|
+
emitClarity(true, autoClarityRef.current);
|
|
49
52
|
if (!devId) return undefined;
|
|
50
53
|
return subscribeClarityChanged(devId, res => {
|
|
54
|
+
autoClarityRef.current = res.clarity;
|
|
51
55
|
emitClarity(true, res.clarity);
|
|
52
56
|
});
|
|
53
|
-
}, [devId, event, resolution]);
|
|
57
|
+
}, [devId, event, resolution, screenType]);
|
|
54
58
|
const onResolution = useMemoizedFn(() => {
|
|
55
59
|
event.emit(widgetClick, {
|
|
56
60
|
widgetId: widgetLabs.RESOLUTION
|