@ray-js/ipc-player-integration 0.0.60-beta.0 → 0.0.61-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.
Files changed (44) hide show
  1. package/lib/ctx/ctx.album.test.d.ts +1 -0
  2. package/lib/ctx/ctx.album.test.js +197 -0
  3. package/lib/ctx/ctx.composition.js +19 -4
  4. package/lib/ctx/ctx.js +100 -55
  5. package/lib/ctx/ports.output.d.ts +1 -0
  6. package/lib/ctx/resolution.d.ts +1 -1
  7. package/lib/ctx/resolution.js +3 -1
  8. package/lib/i18n/index.d.ts +12 -0
  9. package/lib/i18n/strings.d.ts +6 -0
  10. package/lib/i18n/strings.js +6 -0
  11. package/lib/interface.d.ts +18 -3
  12. package/lib/ui/absoluteContent.d.ts +2 -0
  13. package/lib/ui/absoluteContent.js +3 -0
  14. package/lib/ui/ui.d.ts +2 -0
  15. package/lib/ui/ui.js +30 -26
  16. package/lib/utils/captureResult.d.ts +14 -0
  17. package/lib/utils/captureResult.js +70 -0
  18. package/lib/utils/captureResult.test.d.ts +1 -0
  19. package/lib/utils/captureResult.test.js +117 -0
  20. package/lib/utils/ttt.js +2 -8
  21. package/lib/widgets/captureResult/captureResult.d.ts +16 -0
  22. package/lib/widgets/captureResult/captureResult.js +85 -0
  23. package/lib/widgets/captureResult/captureResult.less +144 -0
  24. package/lib/widgets/captureResult/captureResult.test.d.ts +1 -0
  25. package/lib/widgets/captureResult/captureResult.test.js +80 -0
  26. package/lib/widgets/captureResult/index.d.ts +2 -0
  27. package/lib/widgets/captureResult/index.js +2 -0
  28. package/lib/widgets/index.d.ts +1 -0
  29. package/lib/widgets/index.js +2 -1
  30. package/lib/widgets/muted/muted.js +9 -3
  31. package/lib/widgets/muted/muted.less +5 -1
  32. package/lib/widgets/muted/muted.test.d.ts +1 -0
  33. package/lib/widgets/muted/muted.test.js +81 -0
  34. package/lib/widgets/recordVideo/recordVideo.js +53 -52
  35. package/lib/widgets/recordVideo/recordVideo.less +17 -74
  36. package/lib/widgets/recordVideo/recordVideo.lifecycle.test.d.ts +1 -0
  37. package/lib/widgets/recordVideo/recordVideo.lifecycle.test.js +106 -0
  38. package/lib/widgets/recordVideo/recordVideo.test.js +1 -0
  39. package/lib/widgets/screenshot/screenshot.js +66 -44
  40. package/lib/widgets/screenshot/screenshot.less +1 -40
  41. package/lib/widgets/screenshot/screenshot.test.d.ts +1 -0
  42. package/lib/widgets/screenshot/screenshot.test.js +120 -0
  43. package/lib/widgets/tryExperience/tryExperience.js +0 -1
  44. 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 = _ref => {
125
+ const toast = _ref2 => {
116
126
  let {
117
127
  title,
118
128
  duration
119
- } = _ref,
120
- config = _objectWithoutProperties(_ref, _excluded);
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
- resolutionList: res.data.videoResolution.availableResolutions,
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,12 +33,14 @@ 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;
@@ -59,6 +62,7 @@ export const createUseCtx = _ref => {
59
62
 
60
63
  // 录像中
61
64
  const [recording] = useAtom(false);
65
+ const recordingMultiLensRef = useRef(false);
62
66
 
63
67
  // 录像是否不可点击
64
68
  const [recordingDisabled, setRecordingDisabled] = useAtom(false);
@@ -76,6 +80,8 @@ export const createUseCtx = _ref => {
76
80
  const [resolution] = useAtom('HD');
77
81
  // resolution 清晰度列表
78
82
  const [resolutionList, setResolutionList] = useAtom([]);
83
+ const [memoryState, setMemoryState] = useState(null);
84
+ const autoFallbackPendingRef = useRef(null);
79
85
  // 自动模式下宿主上报的实际清晰度,供横竖屏码率区域共用
80
86
  const [autoClarity] = useAtom(null);
81
87
 
@@ -126,40 +132,73 @@ export const createUseCtx = _ref => {
126
132
  if (!eventRef.current) {
127
133
  eventRef.current = getEventInstance();
128
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]);
129
153
  useEffect(() => {
130
154
  // 初始化获取缓存值
131
-
155
+ let active = true;
132
156
  (async () => {
133
157
  if (!devId) return;
134
158
  try {
135
- var _res$maxZoomSettings;
136
159
  const res = await getMemoryState(devId);
137
- setResolutionList(withAutoClarity(res.resolutionList));
138
- restoreResolution(res.resolution, res.resolutionList, _setResolution);
139
- _setMute(res.mute, true);
140
- setIntercomMode(res.intercomMode);
141
- setIntercomSupported(res.isIntercomSupported);
142
- setMaxZoomSettings((_res$maxZoomSettings = res.maxZoomSettings) !== null && _res$maxZoomSettings !== void 0 ? _res$maxZoomSettings : 6);
160
+ if (!active) return;
161
+ syncMemoryState(res);
143
162
  } catch (error) {
144
163
  console.error('获取 getMemoryState 失败:', error);
145
164
  }
146
165
  })();
166
+ return () => {
167
+ active = false;
168
+ };
147
169
  }, [devId]);
148
170
  useEffect(() => {
171
+ let active = true;
149
172
  if (devId && _playState === PlayState.PLAYING) {
150
173
  // 获取缓存的值且同步
151
174
  getMemoryState(devId).then(res => {
152
- var _res$maxZoomSettings2;
153
- setResolutionList(withAutoClarity(res.resolutionList));
154
- // 传true表示值即可,会取播放器的值
155
- restoreResolution(res.resolution, res.resolutionList, _setResolution);
156
- _setMute(res.mute, true);
157
- setIntercomMode(res.intercomMode);
158
- setIntercomSupported(res.isIntercomSupported);
159
- setMaxZoomSettings((_res$maxZoomSettings2 = res.maxZoomSettings) !== null && _res$maxZoomSettings2 !== void 0 ? _res$maxZoomSettings2 : 6);
175
+ if (!active) return;
176
+ syncMemoryState(res);
160
177
  });
161
178
  }
179
+ return () => {
180
+ active = false;
181
+ };
162
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]);
163
202
  useEffect(() => {
164
203
  refreshAfterPlayback(_playState, currentResolution);
165
204
  }, [devId, _playState, currentResolution]);
@@ -276,6 +315,30 @@ export const createUseCtx = _ref => {
276
315
  });
277
316
  });
278
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
+ };
279
342
  const multiCameraCtx = useMultiCameraCtx({
280
343
  devId,
281
344
  IPCPlayerInstance: IPCPlayerInstance.current,
@@ -287,6 +350,7 @@ export const createUseCtx = _ref => {
287
350
  brandColor,
288
351
  verticalMic,
289
352
  saveToAlbum,
353
+ multiLens,
290
354
  screenType,
291
355
  isVerticalFullLayout,
292
356
  setIsVerticalFullLayout,
@@ -332,7 +396,7 @@ export const createUseCtx = _ref => {
332
396
  ty.authorizeStatus({
333
397
  // 麦克风权限
334
398
  scope: 'scope.record',
335
- success: () => {
399
+ success: success => {
336
400
  eventRef.current.emit(changeIgnoreHideStopPreview, false);
337
401
  IPCPlayerInstance.current.startTalk({
338
402
  success: () => {
@@ -350,12 +414,12 @@ export const createUseCtx = _ref => {
350
414
  }
351
415
  });
352
416
  },
353
- fail: () => {
417
+ fail: err => {
354
418
  console.log('authorizeStatus失败回调');
355
419
  ty.authorize({
356
420
  // 麦克风权限
357
421
  scope: 'scope.record',
358
- success: () => {
422
+ success: success => {
359
423
  console.log('authorize成功回调');
360
424
  IPCPlayerInstance.current.startTalk({
361
425
  success: () => {
@@ -431,44 +495,25 @@ export const createUseCtx = _ref => {
431
495
  eventRef.current.emit(changeIgnoreHideStopPreview, false);
432
496
  return false;
433
497
  }
434
- if (target) {
435
- const granted = await ensureAlbumPermission();
436
- eventRef.current.emit(changeIgnoreHideStopPreview, false);
437
- if (!granted) return false;
438
- }
498
+ if (!target) return stopRecording(true);
499
+ const granted = await ensureAlbumPermission();
500
+ eventRef.current.emit(changeIgnoreHideStopPreview, false);
501
+ if (!granted) return false;
439
502
  return new Promise((resolve, reject) => {
440
- if (target) {
441
- IPCPlayerInstance.current.startRecord({
442
- saveToAlbum,
443
- success: () => {
444
- updateAtom(recording, true);
445
- resolve(true);
446
- },
447
- fail: err => {
448
- eventRef.current.emit(changeIgnoreHideStopPreview, false);
449
- reject(err);
450
- }
451
- });
452
- } else {
453
- IPCPlayerInstance.current.stopRecord({
454
- saveToAlbum,
455
- success: res => {
456
- updateAtom(recording, false);
457
- resolve(res);
458
- },
459
- fail: err => {
460
- updateAtom(recording, false);
461
- reject(err);
462
- const errObj = err.innerError || err || {};
463
- const errMsg = errObj.errorMsg || Strings.getLang('ipc_player_stop_recording_err');
464
- toast({
465
- title: errMsg
466
- });
467
- }
468
- });
469
- }
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
+ });
470
514
  });
471
515
  },
516
+ stopRecordingOnUnload: () => stopRecording(false),
472
517
  setRecordingDisabled,
473
518
  setScreenType,
474
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
  }>;
@@ -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 {};
@@ -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
- return canShowAutoClarity(list) ? [...withoutAuto, ClarityType.AUTO] : withoutAuto;
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;
@@ -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;
@@ -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;
@@ -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: '正在录像中...',