@ray-js/ipc-player-integration 0.0.55 → 0.0.56-beta.1

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 (36) 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 +13 -3
  4. package/lib/ctx/ctx.js +43 -35
  5. package/lib/i18n/index.d.ts +12 -0
  6. package/lib/i18n/strings.d.ts +6 -0
  7. package/lib/i18n/strings.js +6 -0
  8. package/lib/interface.d.ts +16 -3
  9. package/lib/ui/absoluteContent.d.ts +2 -0
  10. package/lib/ui/absoluteContent.js +3 -0
  11. package/lib/ui/ui.js +26 -22
  12. package/lib/utils/captureResult.d.ts +14 -0
  13. package/lib/utils/captureResult.js +70 -0
  14. package/lib/utils/captureResult.test.d.ts +1 -0
  15. package/lib/utils/captureResult.test.js +117 -0
  16. package/lib/widgets/captureResult/captureResult.d.ts +16 -0
  17. package/lib/widgets/captureResult/captureResult.js +85 -0
  18. package/lib/widgets/captureResult/captureResult.less +144 -0
  19. package/lib/widgets/captureResult/captureResult.test.d.ts +1 -0
  20. package/lib/widgets/captureResult/captureResult.test.js +80 -0
  21. package/lib/widgets/captureResult/index.d.ts +2 -0
  22. package/lib/widgets/captureResult/index.js +2 -0
  23. package/lib/widgets/index.d.ts +1 -0
  24. package/lib/widgets/index.js +2 -1
  25. package/lib/widgets/muted/muted.js +9 -3
  26. package/lib/widgets/muted/muted.less +5 -1
  27. package/lib/widgets/muted/muted.test.d.ts +1 -0
  28. package/lib/widgets/muted/muted.test.js +81 -0
  29. package/lib/widgets/recordVideo/recordVideo.js +50 -35
  30. package/lib/widgets/recordVideo/recordVideo.less +17 -74
  31. package/lib/widgets/recordVideo/recordVideo.test.js +1 -0
  32. package/lib/widgets/screenshot/screenshot.js +66 -44
  33. package/lib/widgets/screenshot/screenshot.less +1 -40
  34. package/lib/widgets/screenshot/screenshot.test.d.ts +1 -0
  35. package/lib/widgets/screenshot/screenshot.test.js +120 -0
  36. package/package.json +2 -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,
package/lib/ctx/ctx.js CHANGED
@@ -38,6 +38,7 @@ export const createUseCtx = _ref => {
38
38
  initBottomRightContent,
39
39
  initAbsoluteContent,
40
40
  saveToAlbum = SAVE_TO_ALBUM,
41
+ multiLens = false,
41
42
  showPtzControlTip = false,
42
43
  videoSplitProtocol
43
44
  } = _ref2;
@@ -57,6 +58,7 @@ export const createUseCtx = _ref => {
57
58
 
58
59
  // 录像中
59
60
  const [recording] = useAtom(false);
61
+ const recordingMultiLensRef = useRef(false);
60
62
 
61
63
  // 录像是否不可点击
62
64
  const [recordingDisabled, setRecordingDisabled] = useAtom(false);
@@ -274,6 +276,30 @@ export const createUseCtx = _ref => {
274
276
  });
275
277
  });
276
278
  };
279
+ const stopRecording = showError => {
280
+ return new Promise((resolve, reject) => {
281
+ IPCPlayerInstance.current.stopRecord({
282
+ saveToAlbum,
283
+ success: res => {
284
+ recordingMultiLensRef.current = false;
285
+ updateAtom(recording, false);
286
+ resolve(res);
287
+ },
288
+ fail: err => {
289
+ recordingMultiLensRef.current = false;
290
+ updateAtom(recording, false);
291
+ reject(err);
292
+ if (showError) {
293
+ const errObj = err.innerError || err || {};
294
+ const errMsg = errObj.errorMsg || Strings.getLang('ipc_player_stop_recording_err');
295
+ toast({
296
+ title: errMsg
297
+ });
298
+ }
299
+ }
300
+ });
301
+ });
302
+ };
277
303
  const multiCameraCtx = useMultiCameraCtx({
278
304
  devId,
279
305
  IPCPlayerInstance: IPCPlayerInstance.current,
@@ -284,6 +310,7 @@ export const createUseCtx = _ref => {
284
310
  brandColor,
285
311
  verticalMic,
286
312
  saveToAlbum,
313
+ multiLens,
287
314
  screenType,
288
315
  isVerticalFullLayout,
289
316
  setIsVerticalFullLayout,
@@ -428,44 +455,25 @@ export const createUseCtx = _ref => {
428
455
  eventRef.current.emit(changeIgnoreHideStopPreview, false);
429
456
  return false;
430
457
  }
431
- if (target) {
432
- const granted = await ensureAlbumPermission();
433
- eventRef.current.emit(changeIgnoreHideStopPreview, false);
434
- if (!granted) return false;
435
- }
458
+ if (!target) return stopRecording(true);
459
+ const granted = await ensureAlbumPermission();
460
+ eventRef.current.emit(changeIgnoreHideStopPreview, false);
461
+ if (!granted) return false;
436
462
  return new Promise((resolve, reject) => {
437
- if (target) {
438
- IPCPlayerInstance.current.startRecord({
439
- saveToAlbum,
440
- success: () => {
441
- updateAtom(recording, true);
442
- resolve(true);
443
- },
444
- fail: err => {
445
- eventRef.current.emit(changeIgnoreHideStopPreview, false);
446
- reject(err);
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
- }
463
+ IPCPlayerInstance.current.startRecord({
464
+ saveToAlbum,
465
+ success: () => {
466
+ updateAtom(recording, true);
467
+ resolve(true);
468
+ },
469
+ fail: err => {
470
+ eventRef.current.emit(changeIgnoreHideStopPreview, false);
471
+ reject(err);
472
+ }
473
+ });
467
474
  });
468
475
  },
476
+ stopRecordingOnUnload: () => stopRecording(false),
469
477
  setRecordingDisabled,
470
478
  setScreenType,
471
479
  topLeftContent,
@@ -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: '正在录像中...',
@@ -47,6 +47,7 @@ export type UseCtx = (options: {
47
47
  initBottomRightContent?: ComponentConfig[];
48
48
  initAbsoluteContent?: ComponentConfig[];
49
49
  saveToAlbum?: 0 | 1;
50
+ multiLens?: boolean;
50
51
  showPtzControlTip?: boolean;
51
52
  videoSplitProtocol?: VideoSplitProtocol;
52
53
  }) => {
@@ -54,6 +55,7 @@ export type UseCtx = (options: {
54
55
  brandColor: RetAtom<string>;
55
56
  verticalMic: RetAtom<boolean>;
56
57
  saveToAlbum: 0 | 1;
58
+ multiLens: boolean;
57
59
  showPtzControlTip: boolean;
58
60
  screenType: RetAtom<ScreenType>;
59
61
  isVerticalFullLayout: RetAtom<boolean>;
@@ -89,7 +91,8 @@ export type UseCtx = (options: {
89
91
  setRecordingDisabled: (type: boolean) => void;
90
92
  setResolution: (type: string) => Promise<boolean>;
91
93
  setResolutionList: (type: string[]) => void;
92
- setRecording: (value: boolean, onlyUpdateAtom?: boolean) => Promise<RecordInfoData>;
94
+ setRecording: (value: boolean, onlyUpdateAtom?: boolean) => Promise<CaptureResult>;
95
+ stopRecordingOnUnload: () => Promise<CaptureResult>;
93
96
  setIntercom: (value: boolean, onlyUpdateAtom?: boolean) => Promise<boolean>;
94
97
  setMute: (value: boolean) => Promise<boolean>;
95
98
  changeStreamStatus: (value: PlayerStreamStatus) => void;
@@ -120,8 +123,12 @@ export type ComponentConfig<T = ReturnType<UseCtx> & Record<string, any>> = {
120
123
  absoluteContentClassName?: string;
121
124
  absoluteContentStyle?: React.CSSProperties;
122
125
  absoluteNoCoverView?: boolean;
126
+ renderWhen?: (state: ComponentRenderState) => boolean;
123
127
  hidden?: boolean;
124
128
  };
129
+ export type ComponentRenderState = {
130
+ playState: PlayState;
131
+ };
125
132
  export type ComponentConfigProps = {
126
133
  IPCPlayerContext: IpcContext;
127
134
  } & ReturnType<UseCtx>;
@@ -129,11 +136,17 @@ export type PlayStatusData = {
129
136
  playState: PlayState;
130
137
  playCode: number;
131
138
  };
132
- export type RecordInfoData = boolean | {
139
+ export type CaptureFileInfo = {
140
+ index?: number;
133
141
  tempImagePath: string;
134
142
  filePath: string;
135
- thumbPath: string;
143
+ thumbPath?: string;
144
+ width?: number;
145
+ height?: number;
146
+ data?: string;
136
147
  };
148
+ export type CaptureResult = boolean | CaptureFileInfo;
149
+ export type RecordInfoData = CaptureResult;
137
150
  /**
138
151
  * 多目屏幕模式
139
152
  */
@@ -0,0 +1,2 @@
1
+ import type { ComponentConfig, ComponentRenderState } from '../interface';
2
+ export declare function shouldRenderContent<T>(item: ComponentConfig<T>, state: ComponentRenderState): boolean;
@@ -0,0 +1,3 @@
1
+ export function shouldRenderContent(item, state) {
2
+ return !item.hidden && (!item.renderWhen || item.renderWhen(state));
3
+ }
package/lib/ui/ui.js CHANGED
@@ -28,7 +28,9 @@ import { Storage } from '../utils/storage';
28
28
  import './ui.less';
29
29
  import { updatePlayerWidgetProps } from '../features';
30
30
  import { getNgRawData, getSmartImageQualityState, isLowPhone } from '../utils/ttt';
31
+ import { getCaptureResultSummary } from '../utils/captureResult';
31
32
  import { lensCount } from '../widgets/zoomTurntable/lensSkill';
33
+ import { shouldRenderContent } from './absoluteContent';
32
34
  const AutoClarityOnly = _ref => {
33
35
  let {
34
36
  instance
@@ -686,14 +688,16 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
686
688
  ipcTTTOperatorLog('hide: 调用停止录制方法');
687
689
  setRecording(false, true);
688
690
  setIntercom(false, true);
689
- instance === null || instance === void 0 || instance.IPCPlayerInstance.stopRecord({
690
- saveToAlbum: 1,
691
- success: () => {
692
- ipcTTTOperatorLog('hide: 调用停止录制方法成功');
693
- },
694
- fail: () => {
695
- ipcTTTOperatorLog('hide: 调用停止录制方法失败');
696
- }
691
+ instance === null || instance === void 0 || instance.stopRecordingOnUnload().then(async result => {
692
+ var _instance$multiLens, _instance$multiCamera;
693
+ const summary = await getCaptureResultSummary(result, {
694
+ multiLens: (_instance$multiLens = instance === null || instance === void 0 ? void 0 : instance.multiLens) !== null && _instance$multiLens !== void 0 ? _instance$multiLens : false,
695
+ protocolCount: instance === null || instance === void 0 || (_instance$multiCamera = instance.multiCameraCtx) === null || _instance$multiCamera === void 0 || (_instance$multiCamera = _instance$multiCamera.protocol) === null || _instance$multiCamera === void 0 ? void 0 : _instance$multiCamera.total_split_num,
696
+ devId
697
+ });
698
+ ipcTTTOperatorLog(summary !== null && summary !== void 0 && summary.isMultiLens ? `hide: stop recording succeeded with ${summary.count} files` : 'hide: 调用停止录制方法成功');
699
+ }).catch(() => {
700
+ ipcTTTOperatorLog('hide: 调用停止录制方法失败');
697
701
  });
698
702
  ipcTTTOperatorLog('hide: 调用停止对讲方法');
699
703
  instance === null || instance === void 0 || instance.IPCPlayerInstance.stopTalk({
@@ -1155,17 +1159,17 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
1155
1159
  // 这一下起,自动隐藏倒计时才开始生效
1156
1160
  hasUserTappedPlayerRef.current = true;
1157
1161
  if (instance.multiCameraCtx.isSupport) {
1158
- var _instance$multiCamera, _instance$multiCamera2;
1159
- const preTapIndex = (_instance$multiCamera = (_instance$multiCamera2 = instance.multiCameraCtx.selectedLenInfoRef.current) === null || _instance$multiCamera2 === void 0 ? void 0 : _instance$multiCamera2.index) !== null && _instance$multiCamera !== void 0 ? _instance$multiCamera : prevSelectedIndexRef.current;
1162
+ var _instance$multiCamera2, _instance$multiCamera3;
1163
+ const preTapIndex = (_instance$multiCamera2 = (_instance$multiCamera3 = instance.multiCameraCtx.selectedLenInfoRef.current) === null || _instance$multiCamera3 === void 0 ? void 0 : _instance$multiCamera3.index) !== null && _instance$multiCamera2 !== void 0 ? _instance$multiCamera2 : prevSelectedIndexRef.current;
1160
1164
  const wasHidden = componentHideState;
1161
1165
  instance.multiCameraCtx.selectVideoFiredRef.current = false;
1162
1166
  if (multiTapTimerRef.current) {
1163
1167
  clearTimeout(multiTapTimerRef.current);
1164
1168
  }
1165
1169
  multiTapTimerRef.current = setTimeout(() => {
1166
- var _instance$multiCamera3, _instance$multiCamera4;
1170
+ var _instance$multiCamera4, _instance$multiCamera5;
1167
1171
  const selectFired = !!instance.multiCameraCtx.selectVideoFiredRef.current;
1168
- const currentIndex = (_instance$multiCamera3 = (_instance$multiCamera4 = instance.multiCameraCtx.selectedLenInfoRef.current) === null || _instance$multiCamera4 === void 0 ? void 0 : _instance$multiCamera4.index) !== null && _instance$multiCamera3 !== void 0 ? _instance$multiCamera3 : preTapIndex;
1172
+ const currentIndex = (_instance$multiCamera4 = (_instance$multiCamera5 = instance.multiCameraCtx.selectedLenInfoRef.current) === null || _instance$multiCamera5 === void 0 ? void 0 : _instance$multiCamera5.index) !== null && _instance$multiCamera4 !== void 0 ? _instance$multiCamera4 : preTapIndex;
1169
1173
  if (selectFired && currentIndex === preTapIndex) {
1170
1174
  if (wasHidden) {
1171
1175
  showComponents();
@@ -1255,13 +1259,16 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
1255
1259
  }, renderBottomRightContent))), (() => {
1256
1260
  if (!absoluteContent || !(absoluteContent !== null && absoluteContent !== void 0 && absoluteContent.length)) return null;
1257
1261
  return absoluteContent.map(item => {
1258
- if (item.hidden) return null;
1262
+ if (!shouldRenderContent(item, {
1263
+ playState
1264
+ })) return null;
1265
+ const contentProps = _objectSpread(_objectSpread(_objectSpread({
1266
+ key: item.id
1267
+ }, item.initProps), instance), {}, {
1268
+ IPCPlayerContext: instance.IPCPlayerInstance
1269
+ });
1259
1270
  if (item.absoluteNoCoverView) {
1260
- return /*#__PURE__*/React.createElement(item.content, _objectSpread(_objectSpread(_objectSpread({
1261
- key: item.id
1262
- }, item.initProps), instance), {}, {
1263
- IPCPlayerContext: instance.IPCPlayerInstance
1264
- }));
1271
+ return /*#__PURE__*/React.createElement(item.content, contentProps);
1265
1272
  }
1266
1273
  return /*#__PURE__*/React.createElement(CoverView, {
1267
1274
  key: item.id,
@@ -1269,10 +1276,7 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
1269
1276
  position: 'absolute'
1270
1277
  }, item.absolutePosition),
1271
1278
  className: item.absoluteContentClassName
1272
- }, /*#__PURE__*/React.createElement(item.content, _objectSpread(_objectSpread(_objectSpread({
1273
- key: item.id
1274
- }, item.initProps), instance), {}, {
1275
- IPCPlayerContext: instance.IPCPlayerInstance,
1279
+ }, /*#__PURE__*/React.createElement(item.content, _objectSpread(_objectSpread({}, contentProps), {}, {
1276
1280
  // 添加通用变量单独组件类名
1277
1281
  className: clsx('absolute-item-container')
1278
1282
  })));
@@ -0,0 +1,14 @@
1
+ import type { CaptureResult } from '../interface';
2
+ export type CaptureResultSummary = {
3
+ count: number;
4
+ isMultiLens: boolean;
5
+ thumbnailPath: string;
6
+ };
7
+ export type CaptureResultOptions = {
8
+ multiLens: boolean;
9
+ protocolCount?: number | string;
10
+ devId: string;
11
+ };
12
+ /** 从新多目高级能力配置获取当前设备的总镜头数 */
13
+ export declare function getMultiLensCountFromAbility(devId: string): Promise<number>;
14
+ export declare function getCaptureResultSummary(result: CaptureResult, { multiLens, protocolCount, devId }: CaptureResultOptions): Promise<CaptureResultSummary | null>;