@ray-js/ipc-player-integration 0.0.63 → 0.0.64
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/ctx/ctx.js +57 -20
- package/lib/ctx/ports.output.d.ts +1 -0
- package/lib/ctx/resolution.d.ts +1 -1
- package/lib/ctx/resolution.js +3 -1
- package/lib/interface.d.ts +2 -0
- package/lib/ui/ui.d.ts +2 -0
- package/lib/ui/ui.js +4 -4
- package/lib/utils/ttt.js +2 -8
- package/lib/widgets/tryExperience/tryExperience.js +0 -1
- package/package.json +2 -1
|
@@ -129,6 +129,7 @@ const getMemoryState = devId => {
|
|
|
129
129
|
mute: true,
|
|
130
130
|
intercomMode: IntercomMode.TwoWay,
|
|
131
131
|
resolution: ClarityType.HD,
|
|
132
|
+
defaultResolution: ClarityType.HD,
|
|
132
133
|
resolutionList: [ClarityType.HD, ClarityType.SD],
|
|
133
134
|
isIntercomSupported: false,
|
|
134
135
|
maxZoomSettings: 6
|
|
@@ -140,12 +141,16 @@ const getMemoryState = devId => {
|
|
|
140
141
|
return resolve(defaultValue);
|
|
141
142
|
}
|
|
142
143
|
const muteValue = res.data.microphoneSettings.cachedMuteMode === MuteMode.OFF;
|
|
144
|
+
const {
|
|
145
|
+
availableResolutions
|
|
146
|
+
} = res.data.videoResolution;
|
|
143
147
|
return resolve({
|
|
144
148
|
mute: muteValue,
|
|
145
149
|
intercomMode: res.data.intercomInfo.cachedIntercomMode,
|
|
146
150
|
isIntercomSupported: res.data.intercomInfo.isIntercomSupported,
|
|
147
151
|
resolution: res.data.videoResolution.cachedResolution,
|
|
148
|
-
|
|
152
|
+
defaultResolution: res.data.videoResolution.defaultResolution,
|
|
153
|
+
resolutionList: Array.isArray(availableResolutions) && availableResolutions.length > 0 ? availableResolutions : defaultValue.resolutionList,
|
|
149
154
|
maxZoomSettings: (_res$data$maxZoomSett = res.data.maxZoomSettings) !== null && _res$data$maxZoomSett !== void 0 ? _res$data$maxZoomSett : 6
|
|
150
155
|
});
|
|
151
156
|
}).catch(err => {
|
package/lib/ctx/ctx.js
CHANGED
|
@@ -3,13 +3,14 @@ import "core-js/modules/esnext.iterator.constructor.js";
|
|
|
3
3
|
import "core-js/modules/esnext.iterator.filter.js";
|
|
4
4
|
import "core-js/modules/esnext.iterator.find.js";
|
|
5
5
|
import "core-js/modules/esnext.iterator.map.js";
|
|
6
|
-
import { useRef, useCallback, useEffect } from 'react';
|
|
6
|
+
import { useRef, useCallback, useEffect, useState } from 'react';
|
|
7
7
|
import { getSystemInfoSync, showModal, openAppSystemSettingPage } from '@ray-js/ray';
|
|
8
8
|
import Strings from '../i18n';
|
|
9
9
|
import { ensureAlbumPermission } from '../utils/authorize/album';
|
|
10
10
|
import { useAtom, updateAtom, getDefaultStore, useStore } from './store';
|
|
11
11
|
import { PlayState, IntercomMode } from '../interface';
|
|
12
12
|
import { changeIgnoreHideStopPreview } from '../ui/constant';
|
|
13
|
+
import { ClarityType } from '@ray-js/ray-ipc-utils/lib/interface';
|
|
13
14
|
import { getEventInstance } from './event';
|
|
14
15
|
import { isMultiCameraTileSupported, useMultiCameraCtx } from './multiCameraCtx';
|
|
15
16
|
import { toNativeClarity, withAutoClarity } from './resolution';
|
|
@@ -32,6 +33,7 @@ export const createUseCtx = _ref => {
|
|
|
32
33
|
return _ref2 => {
|
|
33
34
|
let {
|
|
34
35
|
devId,
|
|
36
|
+
autoClarityDisabled,
|
|
35
37
|
initTopLeftContent,
|
|
36
38
|
initTopRightContent,
|
|
37
39
|
initBottomLeftContent,
|
|
@@ -74,6 +76,8 @@ export const createUseCtx = _ref => {
|
|
|
74
76
|
const [resolution] = useAtom('HD');
|
|
75
77
|
// resolution 清晰度列表
|
|
76
78
|
const [resolutionList, setResolutionList] = useAtom([]);
|
|
79
|
+
const [memoryState, setMemoryState] = useState(null);
|
|
80
|
+
const autoFallbackPendingRef = useRef(null);
|
|
77
81
|
// 自动模式下宿主上报的实际清晰度,供横竖屏码率区域共用
|
|
78
82
|
const [autoClarity] = useAtom(null);
|
|
79
83
|
|
|
@@ -124,40 +128,73 @@ export const createUseCtx = _ref => {
|
|
|
124
128
|
if (!eventRef.current) {
|
|
125
129
|
eventRef.current = getEventInstance();
|
|
126
130
|
}
|
|
131
|
+
const syncMemoryState = res => {
|
|
132
|
+
var _res$maxZoomSettings;
|
|
133
|
+
setMemoryState({
|
|
134
|
+
devId,
|
|
135
|
+
data: res
|
|
136
|
+
});
|
|
137
|
+
// 历史 Auto 等宿主配置确定后再恢复,避免先显示 Auto 再回退。
|
|
138
|
+
if (res.resolution !== ClarityType.AUTO) {
|
|
139
|
+
restoreResolution(res.resolution, res.resolutionList, _setResolution);
|
|
140
|
+
}
|
|
141
|
+
_setMute(res.mute, true);
|
|
142
|
+
setIntercomMode(res.intercomMode);
|
|
143
|
+
setIntercomSupported(res.isIntercomSupported);
|
|
144
|
+
setMaxZoomSettings((_res$maxZoomSettings = res.maxZoomSettings) !== null && _res$maxZoomSettings !== void 0 ? _res$maxZoomSettings : 6);
|
|
145
|
+
};
|
|
146
|
+
useEffect(() => {
|
|
147
|
+
autoFallbackPendingRef.current = null;
|
|
148
|
+
}, [devId]);
|
|
127
149
|
useEffect(() => {
|
|
128
150
|
// 初始化获取缓存值
|
|
129
|
-
|
|
151
|
+
let active = true;
|
|
130
152
|
(async () => {
|
|
131
153
|
if (!devId) return;
|
|
132
154
|
try {
|
|
133
|
-
var _res$maxZoomSettings;
|
|
134
155
|
const res = await getMemoryState(devId);
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
_setMute(res.mute, true);
|
|
138
|
-
setIntercomMode(res.intercomMode);
|
|
139
|
-
setIntercomSupported(res.isIntercomSupported);
|
|
140
|
-
setMaxZoomSettings((_res$maxZoomSettings = res.maxZoomSettings) !== null && _res$maxZoomSettings !== void 0 ? _res$maxZoomSettings : 6);
|
|
156
|
+
if (!active) return;
|
|
157
|
+
syncMemoryState(res);
|
|
141
158
|
} catch (error) {
|
|
142
159
|
console.error('获取 getMemoryState 失败:', error);
|
|
143
160
|
}
|
|
144
161
|
})();
|
|
162
|
+
return () => {
|
|
163
|
+
active = false;
|
|
164
|
+
};
|
|
145
165
|
}, [devId]);
|
|
146
166
|
useEffect(() => {
|
|
167
|
+
let active = true;
|
|
147
168
|
if (devId && _playState === PlayState.PLAYING) {
|
|
148
169
|
// 获取缓存的值且同步
|
|
149
170
|
getMemoryState(devId).then(res => {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
// 传true表示值即可,会取播放器的值
|
|
153
|
-
restoreResolution(res.resolution, res.resolutionList, _setResolution);
|
|
154
|
-
_setMute(res.mute, true);
|
|
155
|
-
setIntercomMode(res.intercomMode);
|
|
156
|
-
setIntercomSupported(res.isIntercomSupported);
|
|
157
|
-
setMaxZoomSettings((_res$maxZoomSettings2 = res.maxZoomSettings) !== null && _res$maxZoomSettings2 !== void 0 ? _res$maxZoomSettings2 : 6);
|
|
171
|
+
if (!active) return;
|
|
172
|
+
syncMemoryState(res);
|
|
158
173
|
});
|
|
159
174
|
}
|
|
175
|
+
return () => {
|
|
176
|
+
active = false;
|
|
177
|
+
};
|
|
160
178
|
}, [devId, _playState]);
|
|
179
|
+
useEffect(() => {
|
|
180
|
+
// 普通档位或宿主配置变化时,决定是否追加 Auto。
|
|
181
|
+
const list = (memoryState === null || memoryState === void 0 ? void 0 : memoryState.devId) === devId ? memoryState.data.resolutionList : [];
|
|
182
|
+
if (autoClarityDisabled === null) {
|
|
183
|
+
setResolutionList(list.filter(clarity => clarity !== ClarityType.AUTO));
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
setResolutionList(withAutoClarity(list, autoClarityDisabled));
|
|
187
|
+
if ((memoryState === null || memoryState === void 0 ? void 0 : memoryState.devId) !== devId || memoryState.data.resolution !== ClarityType.AUTO) return;
|
|
188
|
+
if (autoClarityDisabled && autoFallbackPendingRef.current !== devId) {
|
|
189
|
+
autoFallbackPendingRef.current = devId;
|
|
190
|
+
_setResolution(memoryState.data.defaultResolution).catch(error => {
|
|
191
|
+
autoFallbackPendingRef.current = null;
|
|
192
|
+
console.warn('恢复默认清晰度失败:', error);
|
|
193
|
+
});
|
|
194
|
+
} else if (!autoClarityDisabled) {
|
|
195
|
+
restoreResolution(memoryState.data.resolution, list, _setResolution);
|
|
196
|
+
}
|
|
197
|
+
}, [devId, memoryState, currentResolution, autoClarityDisabled]);
|
|
161
198
|
useEffect(() => {
|
|
162
199
|
refreshAfterPlayback(_playState, currentResolution);
|
|
163
200
|
}, [devId, _playState, currentResolution]);
|
|
@@ -329,7 +366,7 @@ export const createUseCtx = _ref => {
|
|
|
329
366
|
ty.authorizeStatus({
|
|
330
367
|
// 麦克风权限
|
|
331
368
|
scope: 'scope.record',
|
|
332
|
-
success:
|
|
369
|
+
success: success => {
|
|
333
370
|
eventRef.current.emit(changeIgnoreHideStopPreview, false);
|
|
334
371
|
IPCPlayerInstance.current.startTalk({
|
|
335
372
|
success: () => {
|
|
@@ -347,12 +384,12 @@ export const createUseCtx = _ref => {
|
|
|
347
384
|
}
|
|
348
385
|
});
|
|
349
386
|
},
|
|
350
|
-
fail:
|
|
387
|
+
fail: err => {
|
|
351
388
|
console.log('authorizeStatus失败回调');
|
|
352
389
|
ty.authorize({
|
|
353
390
|
// 麦克风权限
|
|
354
391
|
scope: 'scope.record',
|
|
355
|
-
success:
|
|
392
|
+
success: success => {
|
|
356
393
|
console.log('authorize成功回调');
|
|
357
394
|
IPCPlayerInstance.current.startTalk({
|
|
358
395
|
success: () => {
|
|
@@ -8,6 +8,7 @@ export type GetMemoryState = (devId: string) => Promise<{
|
|
|
8
8
|
intercomMode: IntercomMode;
|
|
9
9
|
isIntercomSupported: boolean;
|
|
10
10
|
resolution: ClarityType;
|
|
11
|
+
defaultResolution: ClarityType;
|
|
11
12
|
resolutionList: [ClarityType.HD, ClarityType.SD];
|
|
12
13
|
maxZoomSettings?: number;
|
|
13
14
|
}>;
|
package/lib/ctx/resolution.d.ts
CHANGED
|
@@ -3,6 +3,6 @@ type NativeClarity = Parameters<IpcContext['setClarity']>[0]['clarity'];
|
|
|
3
3
|
export declare const toNativeClarity: (clarity: ClarityType) => NativeClarity;
|
|
4
4
|
/** 宿主支持自动清晰度,且返回至少两个档位时才展示 AUTO。 */
|
|
5
5
|
export declare const canShowAutoClarity: (list?: ClarityType[]) => boolean;
|
|
6
|
-
export declare const withAutoClarity: (list?: ClarityType[]) => ClarityType[];
|
|
6
|
+
export declare const withAutoClarity: (list?: ClarityType[], autoClarityDisabled?: boolean) => ClarityType[];
|
|
7
7
|
export declare const normalizeResolution: (resolution: ClarityType, list: ClarityType[]) => ClarityType;
|
|
8
8
|
export {};
|
package/lib/ctx/resolution.js
CHANGED
|
@@ -21,8 +21,10 @@ export const canShowAutoClarity = function () {
|
|
|
21
21
|
};
|
|
22
22
|
export const withAutoClarity = function () {
|
|
23
23
|
let list = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
24
|
+
let autoClarityDisabled = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
24
25
|
const withoutAuto = list.filter(clarity => clarity !== ClarityType.AUTO);
|
|
25
|
-
|
|
26
|
+
const showAuto = !autoClarityDisabled && canShowAutoClarity(withoutAuto);
|
|
27
|
+
return showAuto ? [...withoutAuto, ClarityType.AUTO] : withoutAuto;
|
|
26
28
|
};
|
|
27
29
|
export const normalizeResolution = (resolution, list) => {
|
|
28
30
|
if (resolution !== ClarityType.AUTO || canShowAutoClarity(list)) return resolution;
|
package/lib/interface.d.ts
CHANGED
|
@@ -41,6 +41,8 @@ export type EventInstance = {
|
|
|
41
41
|
};
|
|
42
42
|
export type UseCtx = (options: {
|
|
43
43
|
devId: string;
|
|
44
|
+
/** 宿主决定是否禁用 Auto;null 表示本次配置查询尚未完成。 */
|
|
45
|
+
autoClarityDisabled?: boolean | null;
|
|
44
46
|
initTopLeftContent?: ComponentConfig[];
|
|
45
47
|
initTopRightContent?: ComponentConfig[];
|
|
46
48
|
initBottomLeftContent?: ComponentConfig[];
|
package/lib/ui/ui.d.ts
CHANGED
package/lib/ui/ui.js
CHANGED
|
@@ -59,11 +59,12 @@ const StandaloneAutoClarity = _ref2 => {
|
|
|
59
59
|
instance: instance
|
|
60
60
|
}));
|
|
61
61
|
};
|
|
62
|
-
function getCtxInstance(instance, devId) {
|
|
62
|
+
function getCtxInstance(instance, devId, autoClarityDisabled) {
|
|
63
63
|
if (instance) return instance;
|
|
64
64
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
65
65
|
return useCtx({
|
|
66
|
-
devId
|
|
66
|
+
devId,
|
|
67
|
+
autoClarityDisabled
|
|
67
68
|
});
|
|
68
69
|
}
|
|
69
70
|
|
|
@@ -126,7 +127,7 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
126
127
|
const {
|
|
127
128
|
event
|
|
128
129
|
} = useContext(UIEventContext);
|
|
129
|
-
const instance = getCtxInstance(props.instance, devId);
|
|
130
|
+
const instance = getCtxInstance(props.instance, devId, props.autoClarityDisabled);
|
|
130
131
|
const {
|
|
131
132
|
setPlayState,
|
|
132
133
|
setScreenType,
|
|
@@ -563,7 +564,6 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
563
564
|
// canOpenSettings: true,
|
|
564
565
|
// };
|
|
565
566
|
const getNgRes = await getNgRawData();
|
|
566
|
-
console.log('res===getSmartImageQualityState', res);
|
|
567
567
|
updatePlayerWidgetProps(instance, 'bottomLeft', 'TryExperience', {
|
|
568
568
|
isPurchase: res.isPurchase,
|
|
569
569
|
buttonState: res.buttonState,
|
package/lib/utils/ttt.js
CHANGED
|
@@ -37,11 +37,9 @@ export function getAIFrameFeature(devId) {
|
|
|
37
37
|
ty.ipc.getAIFrameFeature({
|
|
38
38
|
devId,
|
|
39
39
|
success: data => {
|
|
40
|
-
console.log('res===getAIFrameFeature data', data);
|
|
41
40
|
resolve(data);
|
|
42
41
|
},
|
|
43
|
-
fail:
|
|
44
|
-
console.warn('res===getAIFrameFeature fail', e);
|
|
42
|
+
fail: () => {
|
|
45
43
|
resolve(null);
|
|
46
44
|
}
|
|
47
45
|
});
|
|
@@ -61,11 +59,9 @@ export function setAIFrameFeature(params) {
|
|
|
61
59
|
try {
|
|
62
60
|
ty.ipc.setAIFrameFeature(_objectSpread(_objectSpread({}, params), {}, {
|
|
63
61
|
success: data => {
|
|
64
|
-
console.log('res===setAIFrameFeature data', data);
|
|
65
62
|
resolve(data);
|
|
66
63
|
},
|
|
67
|
-
fail:
|
|
68
|
-
console.warn('res===setAIFrameFeature fail', e);
|
|
64
|
+
fail: () => {
|
|
69
65
|
resolve(null);
|
|
70
66
|
}
|
|
71
67
|
}));
|
|
@@ -135,7 +131,6 @@ export function notifyOfflineShown(deviceId) {
|
|
|
135
131
|
return false;
|
|
136
132
|
}
|
|
137
133
|
try {
|
|
138
|
-
console.warn('res===notifyOfflineShown', deviceId);
|
|
139
134
|
method({
|
|
140
135
|
deviceId,
|
|
141
136
|
scene: 'preview_mini'
|
|
@@ -246,7 +241,6 @@ export function subscribeClarityChanged(devId, handler) {
|
|
|
246
241
|
try {
|
|
247
242
|
ipc.onClarityChanged(listener);
|
|
248
243
|
} catch (error) {
|
|
249
|
-
console.warn('res===onClarityChanged fail', error);
|
|
250
244
|
return () => undefined;
|
|
251
245
|
}
|
|
252
246
|
return () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ray-js/ipc-player-integration",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.64",
|
|
4
4
|
"description": "IPC 融合播放器",
|
|
5
5
|
"main": "lib/index",
|
|
6
6
|
"files": [
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@ray-js/direction-control": "^0.0.8",
|
|
39
39
|
"@ray-js/ipc-ptz-zoom": "^0.0.3",
|
|
40
|
+
"@ray-js/panel-sdk": "^1.13.1",
|
|
40
41
|
"@ray-js/ray-ipc-player": "^2.1.7",
|
|
41
42
|
"@ray-js/ray-ipc-utils": "^1.1.16",
|
|
42
43
|
"@ray-js/svg": "0.2.0",
|