@ray-js/ipc-player-integration 0.0.63 → 0.0.65-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.album.test.d.ts +1 -0
- package/lib/ctx/ctx.album.test.js +197 -0
- package/lib/ctx/ctx.composition.js +19 -4
- package/lib/ctx/ctx.js +103 -55
- 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/i18n/index.d.ts +12 -0
- package/lib/i18n/strings.d.ts +6 -0
- package/lib/i18n/strings.js +6 -0
- package/lib/interface.d.ts +19 -3
- package/lib/ui/absoluteContent.d.ts +2 -0
- package/lib/ui/absoluteContent.js +3 -0
- package/lib/ui/bottomLeftContent.js +3 -1
- package/lib/ui/ui.d.ts +2 -0
- package/lib/ui/ui.js +30 -26
- package/lib/utils/captureResult.d.ts +14 -0
- package/lib/utils/captureResult.js +70 -0
- package/lib/utils/captureResult.test.d.ts +1 -0
- package/lib/utils/captureResult.test.js +117 -0
- package/lib/utils/fullLinkTracking.d.ts +5 -0
- package/lib/utils/fullLinkTracking.js +71 -0
- package/lib/utils/navigation.d.ts +2 -1
- package/lib/utils/navigation.js +13 -3
- package/lib/utils/ttt.js +2 -8
- package/lib/widgets/captureResult/captureResult.d.ts +16 -0
- package/lib/widgets/captureResult/captureResult.js +85 -0
- package/lib/widgets/captureResult/captureResult.less +144 -0
- package/lib/widgets/captureResult/captureResult.test.d.ts +1 -0
- package/lib/widgets/captureResult/captureResult.test.js +80 -0
- package/lib/widgets/captureResult/index.d.ts +2 -0
- package/lib/widgets/captureResult/index.js +2 -0
- package/lib/widgets/index.d.ts +1 -0
- package/lib/widgets/index.js +2 -1
- package/lib/widgets/multiCamera/index.less +1 -0
- package/lib/widgets/recordVideo/recordVideo.js +53 -52
- package/lib/widgets/recordVideo/recordVideo.less +17 -74
- package/lib/widgets/recordVideo/recordVideo.lifecycle.test.d.ts +1 -0
- package/lib/widgets/recordVideo/recordVideo.lifecycle.test.js +106 -0
- package/lib/widgets/recordVideo/recordVideo.test.js +1 -0
- package/lib/widgets/screenshot/screenshot.js +66 -44
- package/lib/widgets/screenshot/screenshot.less +1 -40
- package/lib/widgets/screenshot/screenshot.test.d.ts +1 -0
- package/lib/widgets/screenshot/screenshot.test.js +120 -0
- package/lib/widgets/trialBadge/index.d.ts +2 -1
- package/lib/widgets/trialBadge/index.js +17 -9
- package/lib/widgets/trialBadge/useTrialBadge.d.ts +3 -2
- package/lib/widgets/trialBadge/useTrialBadge.js +13 -2
- package/lib/widgets/tryExperience/tryExperience.js +0 -1
- package/package.json +3 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import { act, renderHook } from '@testing-library/react-hooks/dom';
|
|
3
|
+
import { authorize, authorizeStatus, getSystemInfoSync, showModal } from '@ray-js/ray';
|
|
4
|
+
import { createUseCtx } from './ctx';
|
|
5
|
+
import { useStore } from './store';
|
|
6
|
+
jest.mock('@ray-js/ray', () => ({
|
|
7
|
+
authorize: jest.fn(),
|
|
8
|
+
authorizeStatus: jest.fn(),
|
|
9
|
+
getSystemInfoSync: jest.fn(),
|
|
10
|
+
openAppSystemSettingPage: jest.fn(),
|
|
11
|
+
showModal: jest.fn()
|
|
12
|
+
}));
|
|
13
|
+
jest.mock('@ray-js/ray-ipc-utils/lib/interface', () => ({
|
|
14
|
+
ClarityType: {
|
|
15
|
+
HD: 'HD',
|
|
16
|
+
SD: 'SD',
|
|
17
|
+
AUTO: 'AUTO'
|
|
18
|
+
},
|
|
19
|
+
IntercomMode: {
|
|
20
|
+
OneWay: 'OneWay',
|
|
21
|
+
TwoWay: 'TwoWay'
|
|
22
|
+
}
|
|
23
|
+
}));
|
|
24
|
+
jest.mock('../i18n', () => ({
|
|
25
|
+
__esModule: true,
|
|
26
|
+
default: {
|
|
27
|
+
getLang: key => key
|
|
28
|
+
}
|
|
29
|
+
}));
|
|
30
|
+
jest.mock('./multiCameraCtx', () => ({
|
|
31
|
+
isMultiCameraTileSupported: () => false,
|
|
32
|
+
useMultiCameraCtx: () => ({})
|
|
33
|
+
}));
|
|
34
|
+
jest.mock('../utils/ttt', () => ({
|
|
35
|
+
getCachedAutoClarity: jest.fn(),
|
|
36
|
+
isClarityChangedSupported: () => false,
|
|
37
|
+
setCachedAutoClarity: jest.fn(),
|
|
38
|
+
subscribeClarityChanged: () => () => undefined
|
|
39
|
+
}));
|
|
40
|
+
beforeEach(() => {
|
|
41
|
+
jest.clearAllMocks();
|
|
42
|
+
getSystemInfoSync.mockReturnValue({
|
|
43
|
+
platform: 'android',
|
|
44
|
+
system: 'android 12'
|
|
45
|
+
});
|
|
46
|
+
authorizeStatus.mockImplementation(_ref => {
|
|
47
|
+
let {
|
|
48
|
+
fail
|
|
49
|
+
} = _ref;
|
|
50
|
+
return fail({
|
|
51
|
+
errorCode: 9004
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
authorize.mockImplementation(_ref2 => {
|
|
55
|
+
let {
|
|
56
|
+
fail
|
|
57
|
+
} = _ref2;
|
|
58
|
+
return fail({
|
|
59
|
+
errorCode: 9004
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
const mountContext = function () {
|
|
64
|
+
let saveToAlbum = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
|
|
65
|
+
const capture = {
|
|
66
|
+
tempImagePath: 'thingfile://capture.jpg',
|
|
67
|
+
filePath: 'thingfile://record.mp4'
|
|
68
|
+
};
|
|
69
|
+
const startRecord = jest.fn(_ref3 => {
|
|
70
|
+
let {
|
|
71
|
+
success
|
|
72
|
+
} = _ref3;
|
|
73
|
+
return success();
|
|
74
|
+
});
|
|
75
|
+
const stopRecord = jest.fn(_ref4 => {
|
|
76
|
+
let {
|
|
77
|
+
success
|
|
78
|
+
} = _ref4;
|
|
79
|
+
return success(capture);
|
|
80
|
+
});
|
|
81
|
+
const useCtx = createUseCtx({
|
|
82
|
+
createPlayContext: () => ({
|
|
83
|
+
startRecord,
|
|
84
|
+
stopRecord
|
|
85
|
+
}),
|
|
86
|
+
getMemoryState: jest.fn().mockResolvedValue({
|
|
87
|
+
resolution: 'HD',
|
|
88
|
+
resolutionList: ['HD', 'SD'],
|
|
89
|
+
mute: true,
|
|
90
|
+
intercomMode: 'TwoWay',
|
|
91
|
+
isIntercomSupported: false
|
|
92
|
+
}),
|
|
93
|
+
setResolutionMemoryState: jest.fn(),
|
|
94
|
+
setMuteMemoryState: jest.fn(),
|
|
95
|
+
authorizeStatus: jest.fn(),
|
|
96
|
+
toast: jest.fn()
|
|
97
|
+
});
|
|
98
|
+
const hook = renderHook(() => {
|
|
99
|
+
const ctx = useCtx({
|
|
100
|
+
devId: 'camera-1',
|
|
101
|
+
multiLens: true,
|
|
102
|
+
saveToAlbum
|
|
103
|
+
});
|
|
104
|
+
const state = useStore({
|
|
105
|
+
recording: ctx.recording
|
|
106
|
+
});
|
|
107
|
+
return _objectSpread(_objectSpread({}, ctx), {}, {
|
|
108
|
+
state
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
return _objectSpread(_objectSpread({}, hook), {}, {
|
|
112
|
+
startRecord,
|
|
113
|
+
stopRecord,
|
|
114
|
+
capture
|
|
115
|
+
});
|
|
116
|
+
};
|
|
117
|
+
it('starts without legacy authorization and retains the native stop result', async () => {
|
|
118
|
+
const {
|
|
119
|
+
result,
|
|
120
|
+
startRecord,
|
|
121
|
+
stopRecord,
|
|
122
|
+
capture,
|
|
123
|
+
unmount
|
|
124
|
+
} = mountContext();
|
|
125
|
+
await act(async () => {
|
|
126
|
+
expect(await result.current.setRecording(true)).toBe(true);
|
|
127
|
+
});
|
|
128
|
+
expect(startRecord).toHaveBeenCalledWith(expect.objectContaining({
|
|
129
|
+
saveToAlbum: 1
|
|
130
|
+
}));
|
|
131
|
+
expect(result.current.state.recording).toBe(true);
|
|
132
|
+
expect(result.current.multiLens).toBe(true);
|
|
133
|
+
await act(async () => {
|
|
134
|
+
expect(await result.current.setRecording(false)).toEqual(capture);
|
|
135
|
+
});
|
|
136
|
+
expect(stopRecord).toHaveBeenCalledTimes(1);
|
|
137
|
+
expect(result.current.state.recording).toBe(false);
|
|
138
|
+
expect(authorizeStatus).not.toHaveBeenCalled();
|
|
139
|
+
expect(authorize).not.toHaveBeenCalled();
|
|
140
|
+
unmount();
|
|
141
|
+
});
|
|
142
|
+
it('settles a denied start without calling the native recorder', async () => {
|
|
143
|
+
getSystemInfoSync.mockReturnValue({
|
|
144
|
+
platform: 'ios',
|
|
145
|
+
system: 'iOS 18'
|
|
146
|
+
});
|
|
147
|
+
const {
|
|
148
|
+
result,
|
|
149
|
+
startRecord,
|
|
150
|
+
unmount
|
|
151
|
+
} = mountContext();
|
|
152
|
+
await act(async () => {
|
|
153
|
+
expect(await result.current.setRecording(true)).toBe(false);
|
|
154
|
+
});
|
|
155
|
+
expect(startRecord).not.toHaveBeenCalled();
|
|
156
|
+
expect(result.current.state.recording).toBe(false);
|
|
157
|
+
expect(showModal).toHaveBeenCalledTimes(1);
|
|
158
|
+
unmount();
|
|
159
|
+
});
|
|
160
|
+
it('propagates a native start failure without entering recording state', async () => {
|
|
161
|
+
const {
|
|
162
|
+
result,
|
|
163
|
+
startRecord,
|
|
164
|
+
unmount
|
|
165
|
+
} = mountContext();
|
|
166
|
+
const error = {
|
|
167
|
+
errorCode: 1001,
|
|
168
|
+
errorMsg: 'Start failed'
|
|
169
|
+
};
|
|
170
|
+
startRecord.mockImplementationOnce(_ref5 => {
|
|
171
|
+
let {
|
|
172
|
+
fail
|
|
173
|
+
} = _ref5;
|
|
174
|
+
return fail(error);
|
|
175
|
+
});
|
|
176
|
+
await act(async () => {
|
|
177
|
+
await expect(result.current.setRecording(true)).rejects.toEqual(error);
|
|
178
|
+
});
|
|
179
|
+
expect(result.current.state.recording).toBe(false);
|
|
180
|
+
unmount();
|
|
181
|
+
});
|
|
182
|
+
it('keeps the requested album when stopping on page unload', async () => {
|
|
183
|
+
const {
|
|
184
|
+
result,
|
|
185
|
+
stopRecord,
|
|
186
|
+
capture,
|
|
187
|
+
unmount
|
|
188
|
+
} = mountContext(0);
|
|
189
|
+
await act(async () => {
|
|
190
|
+
expect(await result.current.stopRecordingOnUnload()).toEqual(capture);
|
|
191
|
+
});
|
|
192
|
+
expect(stopRecord).toHaveBeenCalledWith(expect.objectContaining({
|
|
193
|
+
saveToAlbum: 0
|
|
194
|
+
}));
|
|
195
|
+
expect(authorizeStatus).not.toHaveBeenCalled();
|
|
196
|
+
unmount();
|
|
197
|
+
});
|
|
@@ -6,6 +6,7 @@ import { IntercomMode, MuteMode, ClarityType } from '@ray-js/ray-ipc-utils/lib/i
|
|
|
6
6
|
import { createUseCtx } from './ctx';
|
|
7
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';
|
|
8
8
|
import { authorizeStatus } from '../utils/authorize';
|
|
9
|
+
import { PlayState } from '../interface';
|
|
9
10
|
import { landscapeTipId, moveablePtzControlId, multiPtzId, ptzMoveableTipId, tileActionsId, tileTipId } from '../ui/constant';
|
|
10
11
|
import { multiPrefix } from '../widgets/multiCamera/constants';
|
|
11
12
|
const createPlayContext = ty.createIpcPlayerContext;
|
|
@@ -87,20 +88,29 @@ export const defaultBottomRightContent = [{
|
|
|
87
88
|
content: FullScreen
|
|
88
89
|
}];
|
|
89
90
|
const absoluteContent = [];
|
|
91
|
+
const renderWhenPlaying = _ref => {
|
|
92
|
+
let {
|
|
93
|
+
playState
|
|
94
|
+
} = _ref;
|
|
95
|
+
return playState === PlayState.PLAYING;
|
|
96
|
+
};
|
|
90
97
|
export const multiCameraAbsoluteContent = [{
|
|
91
98
|
id: tileTipId,
|
|
92
99
|
content: TileTip,
|
|
93
100
|
absoluteContentClassName: `${multiPrefix}-tile-tip-wrap`,
|
|
101
|
+
renderWhen: renderWhenPlaying,
|
|
94
102
|
hidden: true
|
|
95
103
|
}, {
|
|
96
104
|
id: ptzMoveableTipId,
|
|
97
105
|
content: PtzMoveableTip,
|
|
98
106
|
absoluteContentClassName: `${multiPrefix}-tile-tip-wrap`,
|
|
107
|
+
renderWhen: renderWhenPlaying,
|
|
99
108
|
hidden: true
|
|
100
109
|
}, {
|
|
101
110
|
id: landscapeTipId,
|
|
102
111
|
content: LandscapeTip,
|
|
103
112
|
absoluteContentClassName: `${multiPrefix}-tile-tip-wrap`,
|
|
113
|
+
renderWhen: renderWhenPlaying,
|
|
104
114
|
hidden: true
|
|
105
115
|
}, {
|
|
106
116
|
id: tileActionsId,
|
|
@@ -112,12 +122,12 @@ export const multiCameraAbsoluteContent = [{
|
|
|
112
122
|
absoluteNoCoverView: true,
|
|
113
123
|
hidden: true
|
|
114
124
|
}];
|
|
115
|
-
const toast =
|
|
125
|
+
const toast = _ref2 => {
|
|
116
126
|
let {
|
|
117
127
|
title,
|
|
118
128
|
duration
|
|
119
|
-
} =
|
|
120
|
-
config = _objectWithoutProperties(
|
|
129
|
+
} = _ref2,
|
|
130
|
+
config = _objectWithoutProperties(_ref2, _excluded);
|
|
121
131
|
ty.showToast(_objectSpread({
|
|
122
132
|
title,
|
|
123
133
|
duration,
|
|
@@ -129,6 +139,7 @@ const getMemoryState = devId => {
|
|
|
129
139
|
mute: true,
|
|
130
140
|
intercomMode: IntercomMode.TwoWay,
|
|
131
141
|
resolution: ClarityType.HD,
|
|
142
|
+
defaultResolution: ClarityType.HD,
|
|
132
143
|
resolutionList: [ClarityType.HD, ClarityType.SD],
|
|
133
144
|
isIntercomSupported: false,
|
|
134
145
|
maxZoomSettings: 6
|
|
@@ -140,12 +151,16 @@ const getMemoryState = devId => {
|
|
|
140
151
|
return resolve(defaultValue);
|
|
141
152
|
}
|
|
142
153
|
const muteValue = res.data.microphoneSettings.cachedMuteMode === MuteMode.OFF;
|
|
154
|
+
const {
|
|
155
|
+
availableResolutions
|
|
156
|
+
} = res.data.videoResolution;
|
|
143
157
|
return resolve({
|
|
144
158
|
mute: muteValue,
|
|
145
159
|
intercomMode: res.data.intercomInfo.cachedIntercomMode,
|
|
146
160
|
isIntercomSupported: res.data.intercomInfo.isIntercomSupported,
|
|
147
161
|
resolution: res.data.videoResolution.cachedResolution,
|
|
148
|
-
|
|
162
|
+
defaultResolution: res.data.videoResolution.defaultResolution,
|
|
163
|
+
resolutionList: Array.isArray(availableResolutions) && availableResolutions.length > 0 ? availableResolutions : defaultValue.resolutionList,
|
|
149
164
|
maxZoomSettings: (_res$data$maxZoomSett = res.data.maxZoomSettings) !== null && _res$data$maxZoomSett !== void 0 ? _res$data$maxZoomSett : 6
|
|
150
165
|
});
|
|
151
166
|
}).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,16 +33,20 @@ 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,
|
|
38
40
|
initBottomRightContent,
|
|
39
41
|
initAbsoluteContent,
|
|
40
42
|
saveToAlbum = SAVE_TO_ALBUM,
|
|
43
|
+
multiLens = false,
|
|
41
44
|
showPtzControlTip = false,
|
|
42
45
|
videoSplitProtocol
|
|
43
46
|
} = _ref2;
|
|
44
47
|
const streamStatus = useRef();
|
|
48
|
+
// The page owns this context; player UI remounts must retain exposure history.
|
|
49
|
+
const trialBadgeViewedRef = useRef(false);
|
|
45
50
|
// 全屏、竖屏
|
|
46
51
|
const [screenType, setScreenType] = useAtom('vertical');
|
|
47
52
|
const IPCPlayerInstance = useRef();
|
|
@@ -57,6 +62,7 @@ export const createUseCtx = _ref => {
|
|
|
57
62
|
|
|
58
63
|
// 录像中
|
|
59
64
|
const [recording] = useAtom(false);
|
|
65
|
+
const recordingMultiLensRef = useRef(false);
|
|
60
66
|
|
|
61
67
|
// 录像是否不可点击
|
|
62
68
|
const [recordingDisabled, setRecordingDisabled] = useAtom(false);
|
|
@@ -74,6 +80,8 @@ export const createUseCtx = _ref => {
|
|
|
74
80
|
const [resolution] = useAtom('HD');
|
|
75
81
|
// resolution 清晰度列表
|
|
76
82
|
const [resolutionList, setResolutionList] = useAtom([]);
|
|
83
|
+
const [memoryState, setMemoryState] = useState(null);
|
|
84
|
+
const autoFallbackPendingRef = useRef(null);
|
|
77
85
|
// 自动模式下宿主上报的实际清晰度,供横竖屏码率区域共用
|
|
78
86
|
const [autoClarity] = useAtom(null);
|
|
79
87
|
|
|
@@ -124,40 +132,73 @@ export const createUseCtx = _ref => {
|
|
|
124
132
|
if (!eventRef.current) {
|
|
125
133
|
eventRef.current = getEventInstance();
|
|
126
134
|
}
|
|
135
|
+
const syncMemoryState = res => {
|
|
136
|
+
var _res$maxZoomSettings;
|
|
137
|
+
setMemoryState({
|
|
138
|
+
devId,
|
|
139
|
+
data: res
|
|
140
|
+
});
|
|
141
|
+
// 历史 Auto 等宿主配置确定后再恢复,避免先显示 Auto 再回退。
|
|
142
|
+
if (res.resolution !== ClarityType.AUTO) {
|
|
143
|
+
restoreResolution(res.resolution, res.resolutionList, _setResolution);
|
|
144
|
+
}
|
|
145
|
+
_setMute(res.mute, true);
|
|
146
|
+
setIntercomMode(res.intercomMode);
|
|
147
|
+
setIntercomSupported(res.isIntercomSupported);
|
|
148
|
+
setMaxZoomSettings((_res$maxZoomSettings = res.maxZoomSettings) !== null && _res$maxZoomSettings !== void 0 ? _res$maxZoomSettings : 6);
|
|
149
|
+
};
|
|
150
|
+
useEffect(() => {
|
|
151
|
+
autoFallbackPendingRef.current = null;
|
|
152
|
+
}, [devId]);
|
|
127
153
|
useEffect(() => {
|
|
128
154
|
// 初始化获取缓存值
|
|
129
|
-
|
|
155
|
+
let active = true;
|
|
130
156
|
(async () => {
|
|
131
157
|
if (!devId) return;
|
|
132
158
|
try {
|
|
133
|
-
var _res$maxZoomSettings;
|
|
134
159
|
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);
|
|
160
|
+
if (!active) return;
|
|
161
|
+
syncMemoryState(res);
|
|
141
162
|
} catch (error) {
|
|
142
163
|
console.error('获取 getMemoryState 失败:', error);
|
|
143
164
|
}
|
|
144
165
|
})();
|
|
166
|
+
return () => {
|
|
167
|
+
active = false;
|
|
168
|
+
};
|
|
145
169
|
}, [devId]);
|
|
146
170
|
useEffect(() => {
|
|
171
|
+
let active = true;
|
|
147
172
|
if (devId && _playState === PlayState.PLAYING) {
|
|
148
173
|
// 获取缓存的值且同步
|
|
149
174
|
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);
|
|
175
|
+
if (!active) return;
|
|
176
|
+
syncMemoryState(res);
|
|
158
177
|
});
|
|
159
178
|
}
|
|
179
|
+
return () => {
|
|
180
|
+
active = false;
|
|
181
|
+
};
|
|
160
182
|
}, [devId, _playState]);
|
|
183
|
+
useEffect(() => {
|
|
184
|
+
// 普通档位或宿主配置变化时,决定是否追加 Auto。
|
|
185
|
+
const list = (memoryState === null || memoryState === void 0 ? void 0 : memoryState.devId) === devId ? memoryState.data.resolutionList : [];
|
|
186
|
+
if (autoClarityDisabled === null) {
|
|
187
|
+
setResolutionList(list.filter(clarity => clarity !== ClarityType.AUTO));
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
setResolutionList(withAutoClarity(list, autoClarityDisabled));
|
|
191
|
+
if ((memoryState === null || memoryState === void 0 ? void 0 : memoryState.devId) !== devId || memoryState.data.resolution !== ClarityType.AUTO) return;
|
|
192
|
+
if (autoClarityDisabled && autoFallbackPendingRef.current !== devId) {
|
|
193
|
+
autoFallbackPendingRef.current = devId;
|
|
194
|
+
_setResolution(memoryState.data.defaultResolution).catch(error => {
|
|
195
|
+
autoFallbackPendingRef.current = null;
|
|
196
|
+
console.warn('恢复默认清晰度失败:', error);
|
|
197
|
+
});
|
|
198
|
+
} else if (!autoClarityDisabled) {
|
|
199
|
+
restoreResolution(memoryState.data.resolution, list, _setResolution);
|
|
200
|
+
}
|
|
201
|
+
}, [devId, memoryState, currentResolution, autoClarityDisabled]);
|
|
161
202
|
useEffect(() => {
|
|
162
203
|
refreshAfterPlayback(_playState, currentResolution);
|
|
163
204
|
}, [devId, _playState, currentResolution]);
|
|
@@ -274,6 +315,30 @@ export const createUseCtx = _ref => {
|
|
|
274
315
|
});
|
|
275
316
|
});
|
|
276
317
|
};
|
|
318
|
+
const stopRecording = showError => {
|
|
319
|
+
return new Promise((resolve, reject) => {
|
|
320
|
+
IPCPlayerInstance.current.stopRecord({
|
|
321
|
+
saveToAlbum,
|
|
322
|
+
success: res => {
|
|
323
|
+
recordingMultiLensRef.current = false;
|
|
324
|
+
updateAtom(recording, false);
|
|
325
|
+
resolve(res);
|
|
326
|
+
},
|
|
327
|
+
fail: err => {
|
|
328
|
+
recordingMultiLensRef.current = false;
|
|
329
|
+
updateAtom(recording, false);
|
|
330
|
+
reject(err);
|
|
331
|
+
if (showError) {
|
|
332
|
+
const errObj = err.innerError || err || {};
|
|
333
|
+
const errMsg = errObj.errorMsg || Strings.getLang('ipc_player_stop_recording_err');
|
|
334
|
+
toast({
|
|
335
|
+
title: errMsg
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
});
|
|
340
|
+
});
|
|
341
|
+
};
|
|
277
342
|
const multiCameraCtx = useMultiCameraCtx({
|
|
278
343
|
devId,
|
|
279
344
|
IPCPlayerInstance: IPCPlayerInstance.current,
|
|
@@ -281,9 +346,11 @@ export const createUseCtx = _ref => {
|
|
|
281
346
|
});
|
|
282
347
|
return {
|
|
283
348
|
devId,
|
|
349
|
+
trialBadgeViewedRef,
|
|
284
350
|
brandColor,
|
|
285
351
|
verticalMic,
|
|
286
352
|
saveToAlbum,
|
|
353
|
+
multiLens,
|
|
287
354
|
screenType,
|
|
288
355
|
isVerticalFullLayout,
|
|
289
356
|
setIsVerticalFullLayout,
|
|
@@ -329,7 +396,7 @@ export const createUseCtx = _ref => {
|
|
|
329
396
|
ty.authorizeStatus({
|
|
330
397
|
// 麦克风权限
|
|
331
398
|
scope: 'scope.record',
|
|
332
|
-
success:
|
|
399
|
+
success: success => {
|
|
333
400
|
eventRef.current.emit(changeIgnoreHideStopPreview, false);
|
|
334
401
|
IPCPlayerInstance.current.startTalk({
|
|
335
402
|
success: () => {
|
|
@@ -347,12 +414,12 @@ export const createUseCtx = _ref => {
|
|
|
347
414
|
}
|
|
348
415
|
});
|
|
349
416
|
},
|
|
350
|
-
fail:
|
|
417
|
+
fail: err => {
|
|
351
418
|
console.log('authorizeStatus失败回调');
|
|
352
419
|
ty.authorize({
|
|
353
420
|
// 麦克风权限
|
|
354
421
|
scope: 'scope.record',
|
|
355
|
-
success:
|
|
422
|
+
success: success => {
|
|
356
423
|
console.log('authorize成功回调');
|
|
357
424
|
IPCPlayerInstance.current.startTalk({
|
|
358
425
|
success: () => {
|
|
@@ -428,44 +495,25 @@ export const createUseCtx = _ref => {
|
|
|
428
495
|
eventRef.current.emit(changeIgnoreHideStopPreview, false);
|
|
429
496
|
return false;
|
|
430
497
|
}
|
|
431
|
-
if (target)
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
}
|
|
498
|
+
if (!target) return stopRecording(true);
|
|
499
|
+
const granted = await ensureAlbumPermission();
|
|
500
|
+
eventRef.current.emit(changeIgnoreHideStopPreview, false);
|
|
501
|
+
if (!granted) return false;
|
|
436
502
|
return new Promise((resolve, reject) => {
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
});
|
|
449
|
-
} else {
|
|
450
|
-
IPCPlayerInstance.current.stopRecord({
|
|
451
|
-
saveToAlbum,
|
|
452
|
-
success: res => {
|
|
453
|
-
updateAtom(recording, false);
|
|
454
|
-
resolve(res);
|
|
455
|
-
},
|
|
456
|
-
fail: err => {
|
|
457
|
-
updateAtom(recording, false);
|
|
458
|
-
reject(err);
|
|
459
|
-
const errObj = err.innerError || err || {};
|
|
460
|
-
const errMsg = errObj.errorMsg || Strings.getLang('ipc_player_stop_recording_err');
|
|
461
|
-
toast({
|
|
462
|
-
title: errMsg
|
|
463
|
-
});
|
|
464
|
-
}
|
|
465
|
-
});
|
|
466
|
-
}
|
|
503
|
+
IPCPlayerInstance.current.startRecord({
|
|
504
|
+
saveToAlbum,
|
|
505
|
+
success: () => {
|
|
506
|
+
updateAtom(recording, true);
|
|
507
|
+
resolve(true);
|
|
508
|
+
},
|
|
509
|
+
fail: err => {
|
|
510
|
+
eventRef.current.emit(changeIgnoreHideStopPreview, false);
|
|
511
|
+
reject(err);
|
|
512
|
+
}
|
|
513
|
+
});
|
|
467
514
|
});
|
|
468
515
|
},
|
|
516
|
+
stopRecordingOnUnload: () => stopRecording(false),
|
|
469
517
|
setRecordingDisabled,
|
|
470
518
|
setScreenType,
|
|
471
519
|
topLeftContent,
|
|
@@ -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/i18n/index.d.ts
CHANGED
|
@@ -10,8 +10,11 @@ declare const Strings: kit.I18N<{
|
|
|
10
10
|
ipc_player_resolution_AUDIO: string;
|
|
11
11
|
ipc_player_current_resolution_is_equal: string;
|
|
12
12
|
ipc_player_screenshot_success_tip: string;
|
|
13
|
+
ipc_player_screenshot_multi_success_tip: string;
|
|
13
14
|
ipc_player_error_screenshot_error_tip: string;
|
|
14
15
|
ipc_player_record_success_tip: string;
|
|
16
|
+
ipc_player_record_multi_success_tip: string;
|
|
17
|
+
ipc_player_multi_capture_success_count: string;
|
|
15
18
|
ipc_player_shot_success_check: string;
|
|
16
19
|
ipc_player_record_success_check: string;
|
|
17
20
|
ipc_player_recording_now_tip: string;
|
|
@@ -52,8 +55,11 @@ declare const Strings: kit.I18N<{
|
|
|
52
55
|
ipc_player_resolution_AUDIO: string;
|
|
53
56
|
ipc_player_current_resolution_is_equal: string;
|
|
54
57
|
ipc_player_screenshot_success_tip: string;
|
|
58
|
+
ipc_player_screenshot_multi_success_tip: string;
|
|
55
59
|
ipc_player_error_screenshot_error_tip: string;
|
|
56
60
|
ipc_player_record_success_tip: string;
|
|
61
|
+
ipc_player_record_multi_success_tip: string;
|
|
62
|
+
ipc_player_multi_capture_success_count: string;
|
|
57
63
|
ipc_player_shot_success_check: string;
|
|
58
64
|
ipc_player_record_success_check: string;
|
|
59
65
|
ipc_player_recording_now_tip: string;
|
|
@@ -94,8 +100,11 @@ declare const Strings: kit.I18N<{
|
|
|
94
100
|
ipc_player_resolution_AUDIO: string;
|
|
95
101
|
ipc_player_current_resolution_is_equal: string;
|
|
96
102
|
ipc_player_screenshot_success_tip: string;
|
|
103
|
+
ipc_player_screenshot_multi_success_tip: string;
|
|
97
104
|
ipc_player_error_screenshot_error_tip: string;
|
|
98
105
|
ipc_player_record_success_tip: string;
|
|
106
|
+
ipc_player_record_multi_success_tip: string;
|
|
107
|
+
ipc_player_multi_capture_success_count: string;
|
|
99
108
|
ipc_player_shot_success_check: string;
|
|
100
109
|
ipc_player_record_success_check: string;
|
|
101
110
|
ipc_player_recording_now_tip: string;
|
|
@@ -135,8 +144,11 @@ declare const Strings: kit.I18N<{
|
|
|
135
144
|
ipc_player_resolution_AUDIO: string;
|
|
136
145
|
ipc_player_current_resolution_is_equal: string;
|
|
137
146
|
ipc_player_screenshot_success_tip: string;
|
|
147
|
+
ipc_player_screenshot_multi_success_tip: string;
|
|
138
148
|
ipc_player_error_screenshot_error_tip: string;
|
|
139
149
|
ipc_player_record_success_tip: string;
|
|
150
|
+
ipc_player_record_multi_success_tip: string;
|
|
151
|
+
ipc_player_multi_capture_success_count: string;
|
|
140
152
|
ipc_player_shot_success_check: string;
|
|
141
153
|
ipc_player_record_success_check: string;
|
|
142
154
|
ipc_player_recording_now_tip: string;
|
package/lib/i18n/strings.d.ts
CHANGED
|
@@ -9,8 +9,11 @@ declare const _default: {
|
|
|
9
9
|
ipc_player_resolution_AUDIO: string;
|
|
10
10
|
ipc_player_current_resolution_is_equal: string;
|
|
11
11
|
ipc_player_screenshot_success_tip: string;
|
|
12
|
+
ipc_player_screenshot_multi_success_tip: string;
|
|
12
13
|
ipc_player_error_screenshot_error_tip: string;
|
|
13
14
|
ipc_player_record_success_tip: string;
|
|
15
|
+
ipc_player_record_multi_success_tip: string;
|
|
16
|
+
ipc_player_multi_capture_success_count: string;
|
|
14
17
|
ipc_player_shot_success_check: string;
|
|
15
18
|
ipc_player_record_success_check: string;
|
|
16
19
|
ipc_player_recording_now_tip: string;
|
|
@@ -51,8 +54,11 @@ declare const _default: {
|
|
|
51
54
|
ipc_player_resolution_AUDIO: string;
|
|
52
55
|
ipc_player_current_resolution_is_equal: string;
|
|
53
56
|
ipc_player_screenshot_success_tip: string;
|
|
57
|
+
ipc_player_screenshot_multi_success_tip: string;
|
|
54
58
|
ipc_player_error_screenshot_error_tip: string;
|
|
55
59
|
ipc_player_record_success_tip: string;
|
|
60
|
+
ipc_player_record_multi_success_tip: string;
|
|
61
|
+
ipc_player_multi_capture_success_count: string;
|
|
56
62
|
ipc_player_shot_success_check: string;
|
|
57
63
|
ipc_player_record_success_check: string;
|
|
58
64
|
ipc_player_recording_now_tip: string;
|
package/lib/i18n/strings.js
CHANGED
|
@@ -9,8 +9,11 @@ export default {
|
|
|
9
9
|
ipc_player_resolution_AUDIO: 'Audio Mode',
|
|
10
10
|
ipc_player_current_resolution_is_equal: 'Already at current clarity',
|
|
11
11
|
ipc_player_screenshot_success_tip: 'Screenshot saved to album',
|
|
12
|
+
ipc_player_screenshot_multi_success_tip: 'Screenshots saved to album',
|
|
12
13
|
ipc_player_error_screenshot_error_tip: 'Screenshot failed. Please try again later.',
|
|
13
14
|
ipc_player_record_success_tip: 'Recording saved to album',
|
|
15
|
+
ipc_player_record_multi_success_tip: 'Recordings saved to album',
|
|
16
|
+
ipc_player_multi_capture_success_count: '{0} items',
|
|
14
17
|
ipc_player_shot_success_check: 'View',
|
|
15
18
|
ipc_player_record_success_check: 'View',
|
|
16
19
|
ipc_player_recording_now_tip: 'Recording in progress...',
|
|
@@ -51,8 +54,11 @@ export default {
|
|
|
51
54
|
ipc_player_resolution_AUDIO: '音频模式',
|
|
52
55
|
ipc_player_current_resolution_is_equal: '已是当前清晰度',
|
|
53
56
|
ipc_player_screenshot_success_tip: '截图已保存在APP相册',
|
|
57
|
+
ipc_player_screenshot_multi_success_tip: '图片已保存至相册',
|
|
54
58
|
ipc_player_error_screenshot_error_tip: '截图失败了,请稍后再试',
|
|
55
59
|
ipc_player_record_success_tip: '录像已保存在APP相册',
|
|
60
|
+
ipc_player_record_multi_success_tip: '视频已保存至相册',
|
|
61
|
+
ipc_player_multi_capture_success_count: '共{0}个',
|
|
56
62
|
ipc_player_shot_success_check: '查看',
|
|
57
63
|
ipc_player_record_success_check: '查看',
|
|
58
64
|
ipc_player_recording_now_tip: '正在录像中...',
|