@ray-js/ipc-player-integration 0.0.53-beta.9 → 0.0.55-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 (42) hide show
  1. package/lib/ctx/ctx.composition.js +3 -13
  2. package/lib/ctx/ctx.js +32 -160
  3. package/lib/i18n/index.d.ts +0 -32
  4. package/lib/i18n/strings.d.ts +0 -16
  5. package/lib/i18n/strings.js +0 -16
  6. package/lib/interface.d.ts +4 -19
  7. package/lib/ui/ui.js +25 -75
  8. package/lib/utils/authorize/album.d.ts +1 -0
  9. package/lib/utils/authorize/album.js +39 -0
  10. package/lib/utils/authorize/album.test.js +82 -0
  11. package/lib/utils/ttt.d.ts +0 -26
  12. package/lib/utils/ttt.js +2 -109
  13. package/lib/widgets/index.d.ts +0 -1
  14. package/lib/widgets/index.js +1 -2
  15. package/lib/widgets/recordVideo/recordVideo.js +40 -50
  16. package/lib/widgets/recordVideo/recordVideo.less +74 -17
  17. package/lib/widgets/recordVideo/recordVideo.test.js +58 -0
  18. package/lib/widgets/resolution/resolution.js +1 -0
  19. package/lib/widgets/screenshot/screenshot.js +44 -97
  20. package/lib/widgets/screenshot/screenshot.less +40 -1
  21. package/lib/widgets/videoBitKBP/videoBitKBP.js +9 -38
  22. package/lib/widgets/videoBitKBP/videoBitKBP.less +0 -6
  23. package/package.json +2 -2
  24. package/lib/ctx/ctx.autoClarity.test.js +0 -150
  25. package/lib/ui/absoluteContent.d.ts +0 -2
  26. package/lib/ui/absoluteContent.js +0 -3
  27. package/lib/utils/captureResult.d.ts +0 -14
  28. package/lib/utils/captureResult.js +0 -70
  29. package/lib/utils/captureResult.test.js +0 -117
  30. package/lib/utils/ttt.autoClarity.test.d.ts +0 -1
  31. package/lib/utils/ttt.autoClarity.test.js +0 -75
  32. package/lib/widgets/captureResult/captureResult.d.ts +0 -16
  33. package/lib/widgets/captureResult/captureResult.js +0 -85
  34. package/lib/widgets/captureResult/captureResult.less +0 -144
  35. package/lib/widgets/captureResult/captureResult.test.d.ts +0 -1
  36. package/lib/widgets/captureResult/captureResult.test.js +0 -80
  37. package/lib/widgets/captureResult/index.d.ts +0 -2
  38. package/lib/widgets/captureResult/index.js +0 -2
  39. package/lib/widgets/videoBitKBP/videoBitKBP.test.d.ts +0 -1
  40. package/lib/widgets/videoBitKBP/videoBitKBP.test.js +0 -81
  41. /package/lib/{ctx/ctx.autoClarity.test.d.ts → utils/authorize/album.test.d.ts} +0 -0
  42. /package/lib/{utils/captureResult.test.d.ts → widgets/recordVideo/recordVideo.test.d.ts} +0 -0
package/lib/ui/ui.js CHANGED
@@ -1,17 +1,14 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
- import _extends from "@babel/runtime/helpers/esm/extends";
3
2
  import "core-js/modules/esnext.iterator.constructor.js";
4
3
  import "core-js/modules/esnext.iterator.filter.js";
5
4
  import "core-js/modules/esnext.iterator.find.js";
6
5
  import "core-js/modules/esnext.iterator.map.js";
7
- import "core-js/modules/esnext.iterator.some.js";
8
6
  import React, { useContext, useState, useRef, useMemo, useEffect, useImperativeHandle } from 'react';
9
7
  import { View, CoverView, getSystemInfoSync, usePageEvent, setNavigationBarBack, setPageOrientation, getCurrentPages } from '@ray-js/ray';
10
8
  import { unstable_batchedUpdates as batchedUpdates } from '@ray-core/ray';
11
9
  import clsx from 'clsx';
12
10
  import IPCPlayer from '@ray-js/ray-ipc-player';
13
11
  import { ipcTTTOperatorLog } from '@ray-js/ray-ipc-utils';
14
- import { ClarityType } from '@ray-js/ray-ipc-utils/lib/interface';
15
12
  import { PlayState, PlayerStreamStatus, MultiCameraScreenMode } from '../interface';
16
13
  import { useCtx } from '../ctx/ctx.composition';
17
14
  import { useStore, updateAtom, getDefaultStore } from '../ctx/store';
@@ -21,45 +18,13 @@ import BottomLeftContent from './bottomLeftContent';
21
18
  import BottomRightContent from './bottomRightContent';
22
19
  import TopLeftContent from './topLeftContent';
23
20
  import TopRightContent from './topRightContent';
24
- import { FlowLowTip, VideoBitKBP } from '../widgets';
21
+ import { FlowLowTip } from '../widgets';
25
22
  import { useMemoizedFn } from '../hooks';
26
23
  import { Storage } from '../utils/storage';
27
24
  import './ui.less';
28
25
  import { updatePlayerWidgetProps } from '../features';
29
- import { getNgRawData, getSmartImageQualityState, isLowPhone, notifyOfflineShown } from '../utils/ttt';
30
- import { getCaptureResultSummary } from '../utils/captureResult';
26
+ import { getNgRawData, getSmartImageQualityState, isLowPhone } from '../utils/ttt';
31
27
  import { lensCount } from '../widgets/zoomTurntable/lensSkill';
32
- import { shouldRenderContent } from './absoluteContent';
33
- const AutoClarityOnly = _ref => {
34
- let {
35
- instance
36
- } = _ref;
37
- return /*#__PURE__*/React.createElement(VideoBitKBP, _extends({}, instance, {
38
- IPCPlayerContext: instance.IPCPlayerInstance,
39
- className: "top-right-item-container",
40
- hideKbsMenu: true,
41
- hideSignalMenu: true
42
- }));
43
- };
44
- const StandaloneAutoClarity = _ref2 => {
45
- let {
46
- instance,
47
- show
48
- } = _ref2;
49
- const {
50
- resolution,
51
- autoClarity
52
- } = useStore({
53
- resolution: instance.resolution,
54
- autoClarity: instance.autoClarity
55
- });
56
- if (!show || resolution !== ClarityType.AUTO || !autoClarity) return null;
57
- return /*#__PURE__*/React.createElement(TopRightContent, {
58
- ctx: instance
59
- }, /*#__PURE__*/React.createElement(AutoClarityOnly, {
60
- instance: instance
61
- }));
62
- };
63
28
  function getCtxInstance(instance, devId) {
64
29
  if (instance) return instance;
65
30
  // eslint-disable-next-line react-hooks/rules-of-hooks
@@ -186,13 +151,6 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
186
151
  });
187
152
  }, []);
188
153
 
189
- // 监听设备在线状态,离线提示展示时通知宿主;notifyOfflineShown 内部兼容没有该 TTT 方法的宿主。
190
- useEffect(() => {
191
- if (!deviceOnline) {
192
- notifyOfflineShown(devId);
193
- }
194
- }, [deviceOnline, devId]);
195
-
196
154
  // 展示顶部内容
197
155
  const [showTopContent, setShowTopContent] = useState(true);
198
156
 
@@ -693,16 +651,14 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
693
651
  ipcTTTOperatorLog('hide: 调用停止录制方法');
694
652
  setRecording(false, true);
695
653
  setIntercom(false, true);
696
- instance === null || instance === void 0 || instance.stopRecordingOnUnload().then(async result => {
697
- var _instance$multiLens, _instance$multiCamera;
698
- const summary = await getCaptureResultSummary(result, {
699
- multiLens: (_instance$multiLens = instance === null || instance === void 0 ? void 0 : instance.multiLens) !== null && _instance$multiLens !== void 0 ? _instance$multiLens : false,
700
- 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,
701
- devId
702
- });
703
- ipcTTTOperatorLog(summary !== null && summary !== void 0 && summary.isMultiLens ? `hide: stop recording succeeded with ${summary.count} files` : 'hide: 调用停止录制方法成功');
704
- }).catch(() => {
705
- ipcTTTOperatorLog('hide: 调用停止录制方法失败');
654
+ instance === null || instance === void 0 || instance.IPCPlayerInstance.stopRecord({
655
+ saveToAlbum: 1,
656
+ success: () => {
657
+ ipcTTTOperatorLog('hide: 调用停止录制方法成功');
658
+ },
659
+ fail: () => {
660
+ ipcTTTOperatorLog('hide: 调用停止录制方法失败');
661
+ }
706
662
  });
707
663
  ipcTTTOperatorLog('hide: 调用停止对讲方法');
708
664
  instance === null || instance === void 0 || instance.IPCPlayerInstance.stopTalk({
@@ -1046,7 +1002,6 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
1046
1002
  };
1047
1003
  }, []);
1048
1004
  const playerReady = playState === PlayState.PLAYING;
1049
- const hasVisibleBitrateWidget = topRightContent === null || topRightContent === void 0 ? void 0 : topRightContent.some(item => item.id === 'VideoBitKBP' && !item.hidden);
1050
1005
  /**
1051
1006
  * 监听当前的zoom比例状态
1052
1007
  */
@@ -1164,17 +1119,17 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
1164
1119
  // 这一下起,自动隐藏倒计时才开始生效
1165
1120
  hasUserTappedPlayerRef.current = true;
1166
1121
  if (instance.multiCameraCtx.isSupport) {
1167
- var _instance$multiCamera2, _instance$multiCamera3;
1168
- 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;
1122
+ var _instance$multiCamera, _instance$multiCamera2;
1123
+ 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;
1169
1124
  const wasHidden = componentHideState;
1170
1125
  instance.multiCameraCtx.selectVideoFiredRef.current = false;
1171
1126
  if (multiTapTimerRef.current) {
1172
1127
  clearTimeout(multiTapTimerRef.current);
1173
1128
  }
1174
1129
  multiTapTimerRef.current = setTimeout(() => {
1175
- var _instance$multiCamera4, _instance$multiCamera5;
1130
+ var _instance$multiCamera3, _instance$multiCamera4;
1176
1131
  const selectFired = !!instance.multiCameraCtx.selectVideoFiredRef.current;
1177
- 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;
1132
+ 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;
1178
1133
  if (selectFired && currentIndex === preTapIndex) {
1179
1134
  if (wasHidden) {
1180
1135
  showComponents();
@@ -1240,12 +1195,7 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
1240
1195
  ctx: instance
1241
1196
  }, renderTopLeftContent), /*#__PURE__*/React.createElement(TopRightContent, {
1242
1197
  ctx: instance
1243
- }, renderTopRightContent, !hasVisibleBitrateWidget && /*#__PURE__*/React.createElement(AutoClarityOnly, {
1244
- instance: instance
1245
- })))), /*#__PURE__*/React.createElement(StandaloneAutoClarity, {
1246
- instance: instance,
1247
- show: !showTopContent || componentHideState || !playerReady
1248
- }), /*#__PURE__*/React.createElement(View, {
1198
+ }, renderTopRightContent))), /*#__PURE__*/React.createElement(View, {
1249
1199
  className: clsx('ipc-player-bottom-content', {
1250
1200
  'ipc-player-bottom-content-hide': componentHideState,
1251
1201
  'ipc-player-bottom-content-show': !componentHideState,
@@ -1264,16 +1214,13 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
1264
1214
  }, renderBottomRightContent))), (() => {
1265
1215
  if (!absoluteContent || !(absoluteContent !== null && absoluteContent !== void 0 && absoluteContent.length)) return null;
1266
1216
  return absoluteContent.map(item => {
1267
- if (!shouldRenderContent(item, {
1268
- playState
1269
- })) return null;
1270
- const contentProps = _objectSpread(_objectSpread(_objectSpread({
1271
- key: item.id
1272
- }, item.initProps), instance), {}, {
1273
- IPCPlayerContext: instance.IPCPlayerInstance
1274
- });
1217
+ if (item.hidden) return null;
1275
1218
  if (item.absoluteNoCoverView) {
1276
- return /*#__PURE__*/React.createElement(item.content, contentProps);
1219
+ return /*#__PURE__*/React.createElement(item.content, _objectSpread(_objectSpread(_objectSpread({
1220
+ key: item.id
1221
+ }, item.initProps), instance), {}, {
1222
+ IPCPlayerContext: instance.IPCPlayerInstance
1223
+ }));
1277
1224
  }
1278
1225
  return /*#__PURE__*/React.createElement(CoverView, {
1279
1226
  key: item.id,
@@ -1281,7 +1228,10 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
1281
1228
  position: 'absolute'
1282
1229
  }, item.absolutePosition),
1283
1230
  className: item.absoluteContentClassName
1284
- }, /*#__PURE__*/React.createElement(item.content, _objectSpread(_objectSpread({}, contentProps), {}, {
1231
+ }, /*#__PURE__*/React.createElement(item.content, _objectSpread(_objectSpread(_objectSpread({
1232
+ key: item.id
1233
+ }, item.initProps), instance), {}, {
1234
+ IPCPlayerContext: instance.IPCPlayerInstance,
1285
1235
  // 添加通用变量单独组件类名
1286
1236
  className: clsx('absolute-item-container')
1287
1237
  })));
@@ -0,0 +1 @@
1
+ export declare function ensureAlbumPermission(): Promise<boolean>;
@@ -0,0 +1,39 @@
1
+ import { authorize, authorizeStatus, getSystemInfoSync, openAppSystemSettingPage, showModal } from '@ray-js/ray';
2
+ import Strings from '../../i18n';
3
+ export async function ensureAlbumPermission() {
4
+ var _system$match;
5
+ const {
6
+ platform,
7
+ system
8
+ } = getSystemInfoSync();
9
+ // Scoped storage does not require the legacy album permission to save media.
10
+ if (platform === 'android' && Number((_system$match = system.match(/\d+/)) === null || _system$match === void 0 ? void 0 : _system$match[0]) >= 10) return true;
11
+ const granted = await new Promise(resolve => {
12
+ authorizeStatus({
13
+ scope: 'scope.writePhotosAlbum',
14
+ success: () => resolve(true),
15
+ fail: () => {
16
+ authorize({
17
+ scope: 'scope.writePhotosAlbum',
18
+ success: () => resolve(true),
19
+ fail: () => resolve(false)
20
+ });
21
+ }
22
+ });
23
+ });
24
+ if (!granted) {
25
+ showModal({
26
+ title: '',
27
+ content: Strings.getLang('ipc_player_no_album_permission'),
28
+ cancelText: Strings.getLang('ipc_player_authorize_cancel_text'),
29
+ confirmText: Strings.getLang('ipc_player_authorize_confirm_text'),
30
+ isShowGlobal: true,
31
+ success: res => {
32
+ if (res.confirm) openAppSystemSettingPage({
33
+ scope: 'App-Settings'
34
+ });
35
+ }
36
+ });
37
+ }
38
+ return granted;
39
+ }
@@ -0,0 +1,82 @@
1
+ import { authorize, authorizeStatus, getSystemInfoSync, openAppSystemSettingPage, showModal } from '@ray-js/ray';
2
+ import { ensureAlbumPermission } from './album';
3
+ jest.mock('@ray-js/ray', () => ({
4
+ authorize: jest.fn(),
5
+ authorizeStatus: jest.fn(),
6
+ getSystemInfoSync: jest.fn(),
7
+ openAppSystemSettingPage: jest.fn(),
8
+ showModal: jest.fn()
9
+ }));
10
+ jest.mock('../../i18n', () => ({
11
+ __esModule: true,
12
+ default: {
13
+ getLang: key => key
14
+ }
15
+ }));
16
+ beforeEach(() => {
17
+ jest.resetAllMocks();
18
+ authorizeStatus.mockImplementation(_ref => {
19
+ let {
20
+ fail
21
+ } = _ref;
22
+ return fail({
23
+ errorCode: 9004
24
+ });
25
+ });
26
+ authorize.mockImplementation(_ref2 => {
27
+ let {
28
+ fail
29
+ } = _ref2;
30
+ return fail({
31
+ errorCode: 9004
32
+ });
33
+ });
34
+ });
35
+ describe('album permission', () => {
36
+ it.each(['android 10', 'android 12', 'android 15'])('allows native saving on %s without legacy storage access', async system => {
37
+ getSystemInfoSync.mockReturnValue({
38
+ platform: 'android',
39
+ system
40
+ });
41
+ expect(await ensureAlbumPermission()).toBe(true);
42
+ expect(authorizeStatus).not.toHaveBeenCalled();
43
+ expect(authorize).not.toHaveBeenCalled();
44
+ expect(showModal).not.toHaveBeenCalled();
45
+ });
46
+ it.each([['ios', 'iOS 18'], ['android', 'android 9'], ['android', 'unknown']])('keeps rejection handling on %s %s', async (platform, system) => {
47
+ getSystemInfoSync.mockReturnValue({
48
+ platform,
49
+ system
50
+ });
51
+ expect(await ensureAlbumPermission()).toBe(false);
52
+ expect(showModal).toHaveBeenCalledTimes(1);
53
+ const {
54
+ success
55
+ } = showModal.mock.calls[0][0];
56
+ success({
57
+ confirm: false
58
+ });
59
+ expect(openAppSystemSettingPage).not.toHaveBeenCalled();
60
+ success({
61
+ confirm: true
62
+ });
63
+ expect(openAppSystemSettingPage).toHaveBeenCalledWith({
64
+ scope: 'App-Settings'
65
+ });
66
+ });
67
+ it('allows saving after authorization and checks it again on retry', async () => {
68
+ getSystemInfoSync.mockReturnValue({
69
+ platform: 'ios',
70
+ system: 'iOS 18'
71
+ });
72
+ authorize.mockImplementationOnce(_ref3 => {
73
+ let {
74
+ success
75
+ } = _ref3;
76
+ return success();
77
+ });
78
+ expect(await ensureAlbumPermission()).toBe(true);
79
+ expect(await ensureAlbumPermission()).toBe(false);
80
+ expect(showModal).toHaveBeenCalledTimes(1);
81
+ });
82
+ });
@@ -1,4 +1,3 @@
1
- import { ClarityType } from '@ray-js/ray-ipc-utils/lib/interface';
2
1
  export type SmartImageQualityResult = {
3
2
  isPurchase: boolean;
4
3
  buttonState: number;
@@ -39,29 +38,4 @@ export declare function getAIFrameFeature(devId: string): Promise<GetAIFrameFeat
39
38
  export declare function setAIFrameFeature(params: SetAIFrameFeatureParams): Promise<any>;
40
39
  export declare function setTrailFinish(devId: string): Promise<unknown>;
41
40
  export declare function isLowPhone(): Promise<boolean>;
42
- /**
43
- * 通知宿主离线提示已经展示。
44
- *
45
- * 这个 TTT 方法不是所有宿主都提供,因此调用前必须做能力判断;
46
- * 老宿主或 Web 环境下直接跳过,不能影响播放器自身的离线处理。
47
- */
48
- export declare function notifyOfflineShown(deviceId: string): boolean;
49
41
  export declare function getNgRawData(): Promise<unknown>;
50
- export declare function isClarityChangedSupported(): boolean;
51
- export type ClarityChangedResult = {
52
- deviceId?: string;
53
- clarity: ClarityType;
54
- };
55
- export type ClarityChangedHandler = (result: ClarityChangedResult) => void;
56
- type ClarityChangedListener = (payload: ClarityChangedResult) => void;
57
- export declare function getCachedAutoClarity(devId: string): ClarityType | null;
58
- export declare function setCachedAutoClarity(devId: string, clarity: ClarityType): void;
59
- export declare function offClarityChanged(listener: ClarityChangedListener): void;
60
- /**
61
- * 监听自动清晰度变化,返回取消监听函数。
62
- *
63
- * onClarityChanged / offClarityChanged 均使用同一个 listener 引用,
64
- * 否则宿主无法正确移除监听。
65
- */
66
- export declare function subscribeClarityChanged(devId: string, handler: ClarityChangedHandler): () => void;
67
- export {};
package/lib/utils/ttt.js CHANGED
@@ -1,5 +1,4 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
- import { ClarityType } from '@ray-js/ray-ipc-utils/lib/interface';
3
2
  export function getSmartImageQualityState(devId) {
4
3
  return new Promise(resolve => {
5
4
  var _ty$ipc;
@@ -121,31 +120,10 @@ export function isLowPhone() {
121
120
  }
122
121
  });
123
122
  }
124
-
125
- /**
126
- * 通知宿主离线提示已经展示。
127
- *
128
- * 这个 TTT 方法不是所有宿主都提供,因此调用前必须做能力判断;
129
- * 老宿主或 Web 环境下直接跳过,不能影响播放器自身的离线处理。
130
- */
131
- export function notifyOfflineShown(deviceId) {
132
- var _ty3;
133
- const method = typeof ty !== 'undefined' ? (_ty3 = ty) === null || _ty3 === void 0 || (_ty3 = _ty3.ipc) === null || _ty3 === void 0 ? void 0 : _ty3.notifyOfflineShown : undefined;
134
- if (typeof method !== 'function') {
135
- return false;
136
- }
137
- try {
138
- console.warn('res===notifyOfflineShown');
139
- method(deviceId, 'preview_mini');
140
- return true;
141
- } catch (error) {
142
- return false;
143
- }
144
- }
145
123
  export function getNgRawData() {
146
124
  return new Promise(resolve => {
147
- var _ty4;
148
- const isSupport = typeof ((_ty4 = ty) === null || _ty4 === void 0 ? void 0 : _ty4.getNgRawData) === 'function';
125
+ var _ty3;
126
+ const isSupport = typeof ((_ty3 = ty) === null || _ty3 === void 0 ? void 0 : _ty3.getNgRawData) === 'function';
149
127
  if (!isSupport) {
150
128
  resolve(false);
151
129
  return;
@@ -164,89 +142,4 @@ export function getNgRawData() {
164
142
  resolve(false);
165
143
  }
166
144
  });
167
- }
168
-
169
- // 是否支持自动清晰度(ttt 方法 onClarityChanged 存在即支持)
170
- export function isClarityChangedSupported() {
171
- var _ty5;
172
- return typeof ty !== 'undefined' && typeof ((_ty5 = ty) === null || _ty5 === void 0 || (_ty5 = _ty5.ipc) === null || _ty5 === void 0 ? void 0 : _ty5.onClarityChanged) === 'function';
173
- }
174
- const actualClarityTypes = [ClarityType.SS, ClarityType.SD, ClarityType.HD, ClarityType.UD, ClarityType.SSP];
175
- const autoClarityStorageKey = devId => `${devId}_auto_clarity`;
176
- export function getCachedAutoClarity(devId) {
177
- try {
178
- const stored = ty.getStorageSync({
179
- key: autoClarityStorageKey(devId)
180
- });
181
- const clarity = typeof stored === 'string' ? stored : stored === null || stored === void 0 ? void 0 : stored.data;
182
- return actualClarityTypes.includes(clarity) ? clarity : null;
183
- } catch (error) {
184
- return null;
185
- }
186
- }
187
- export function setCachedAutoClarity(devId, clarity) {
188
- if (!actualClarityTypes.includes(clarity)) return;
189
- try {
190
- ty.setStorageSync({
191
- key: autoClarityStorageKey(devId),
192
- data: clarity
193
- });
194
- } catch (error) {
195
- console.warn('res===setCachedAutoClarity fail', error);
196
- }
197
- }
198
- export function offClarityChanged(listener) {
199
- var _ty6;
200
- const ipc = typeof ty !== 'undefined' ? (_ty6 = ty) === null || _ty6 === void 0 ? void 0 : _ty6.ipc : undefined;
201
- if (!ipc || typeof ipc.offClarityChanged !== 'function') {
202
- return;
203
- }
204
- try {
205
- ipc.offClarityChanged(listener);
206
- } catch (error) {
207
- console.warn('res===offClarityChanged fail', error);
208
- }
209
- }
210
-
211
- /**
212
- * 监听自动清晰度变化,返回取消监听函数。
213
- *
214
- * onClarityChanged / offClarityChanged 均使用同一个 listener 引用,
215
- * 否则宿主无法正确移除监听。
216
- */
217
- export function subscribeClarityChanged(devId, handler) {
218
- var _ty7;
219
- const ipc = typeof ty !== 'undefined' ? (_ty7 = ty) === null || _ty7 === void 0 ? void 0 : _ty7.ipc : undefined;
220
- if (!ipc || typeof ipc.onClarityChanged !== 'function') {
221
- return () => undefined;
222
- }
223
- const listener = payload => {
224
- console.log('[resolution] onClarityChanged 事件到达', JSON.stringify(payload !== null && payload !== void 0 ? payload : null));
225
- const {
226
- deviceId,
227
- clarity
228
- } = payload || {};
229
- if (!actualClarityTypes.includes(clarity)) {
230
- console.warn('[resolution] onClarityChanged 未返回实际清晰度');
231
- return;
232
- }
233
- // 一页多设备时只认自己的;宿主没带 deviceId 就不过滤
234
- if (deviceId && deviceId !== devId) {
235
- console.warn('[resolution] onClarityChanged 非本设备,已忽略', `${deviceId} != ${devId}`);
236
- return;
237
- }
238
- handler({
239
- deviceId,
240
- clarity
241
- });
242
- };
243
- try {
244
- ipc.onClarityChanged(listener);
245
- } catch (error) {
246
- console.warn('res===onClarityChanged fail', error);
247
- return () => undefined;
248
- }
249
- return () => {
250
- offClarityChanged(listener);
251
- };
252
145
  }
@@ -24,4 +24,3 @@ export * from './toggleVerticalFull';
24
24
  export * from './flowLowTip';
25
25
  export * from './realTimeMagnification';
26
26
  export * from './zoomTurntable';
27
- export * from './captureResult';
@@ -23,5 +23,4 @@ export * from './smallIntercom';
23
23
  export * from './toggleVerticalFull';
24
24
  export * from './flowLowTip';
25
25
  export * from './realTimeMagnification';
26
- export * from './zoomTurntable';
27
- export * from './captureResult';
26
+ export * from './zoomTurntable';
@@ -1,12 +1,10 @@
1
1
  import React, { useState, useEffect, useRef, useContext } from 'react';
2
- import { View, Text, getSystemInfoSync } from '@ray-js/ray';
2
+ import { View, Text, Image, getSystemInfoSync } from '@ray-js/ray';
3
3
  import { useSetState, useUpdateEffect } from 'ahooks';
4
4
  import clsx from 'clsx';
5
5
  import { goToIpcPageNativeRoute } from '@ray-js/ray-ipc-utils';
6
6
  import Strings from '../../i18n';
7
7
  import { PlayState } from '../../interface';
8
- import { getCaptureResultSummary } from '../../utils/captureResult';
9
- import { CaptureResultToast } from '../captureResult/captureResult';
10
8
  import { UIEventContext } from '../../ui/context';
11
9
  import { pauseTimeToHideAllComponent, changeIgnoreHideStopPreview, widgetLabs, widgetClick } from '../../ui/constant';
12
10
  import { useStore, getDefaultStore } from '../../ctx/store';
@@ -104,48 +102,20 @@ export function RecordVideo(props) {
104
102
  const [state, setState] = useSetState({
105
103
  showTimer: false,
106
104
  showShot: false,
107
- shotUrl: '',
108
- shotCount: 0
105
+ shotUrl: ''
109
106
  });
110
- const recordResultRequestIdRef = useRef(0);
111
- useEffect(() => {
112
- return () => {
113
- recordResultRequestIdRef.current += 1;
114
- };
115
- }, []);
116
- const showRecordResult = async recordInfo => {
117
- var _props$multiCameraCtx;
118
- const requestId = ++recordResultRequestIdRef.current;
119
- const splitNum = (_props$multiCameraCtx = props.multiCameraCtx) === null || _props$multiCameraCtx === void 0 || (_props$multiCameraCtx = _props$multiCameraCtx.protocol) === null || _props$multiCameraCtx === void 0 ? void 0 : _props$multiCameraCtx.total_split_num;
120
- const summary = await getCaptureResultSummary(recordInfo, {
121
- multiLens: props.multiLens,
122
- protocolCount: splitNum,
123
- devId
124
- });
125
- if (requestId !== recordResultRequestIdRef.current) return;
126
- if (!summary) return;
127
- setState({
128
- showTimer: false,
129
- showShot: true,
130
- shotUrl: summary.thumbnailPath,
131
- shotCount: summary.isMultiLens ? summary.count : 0
132
- });
133
- };
134
107
 
135
108
  /**
136
109
  * 针对 playState为非连接中状态时,如果处于录制中, 结束录制
137
110
  */
138
111
  useEffect(() => {
139
112
  (async () => {
140
- if (playState !== PlayState.PLAYING && recording) {
141
- try {
113
+ if (playState !== PlayState.PLAYING) {
114
+ if (recording) {
142
115
  setState({
143
116
  showTimer: false
144
117
  });
145
- const recordInfo = await setRecording(false);
146
- await showRecordResult(recordInfo);
147
- } catch {
148
- // setRecording reports the native failure through the configured toast.
118
+ await setRecording(false);
149
119
  }
150
120
  }
151
121
  })();
@@ -159,8 +129,7 @@ export function RecordVideo(props) {
159
129
  timer.current = setTimeout(() => {
160
130
  setState({
161
131
  showShot: false,
162
- shotUrl: '',
163
- shotCount: 0
132
+ shotUrl: ''
164
133
  });
165
134
  deleteContent('absolute', RECORD_VIDEO_SUCCESS_TOAST_ID);
166
135
  }, CLOSE_TIME);
@@ -195,8 +164,7 @@ export function RecordVideo(props) {
195
164
  const handCheck = () => {
196
165
  setState({
197
166
  showShot: false,
198
- shotUrl: '',
199
- shotCount: 0
167
+ shotUrl: ''
200
168
  });
201
169
  deleteContent('absolute', RECORD_VIDEO_SUCCESS_TOAST_ID);
202
170
  clearInterval(timer.current);
@@ -218,13 +186,27 @@ export function RecordVideo(props) {
218
186
  marginLeft: screenType === 'vertical' ? '0' : '-200px'
219
187
  },
220
188
  content: () => {
221
- return /*#__PURE__*/React.createElement(CaptureResultToast, {
222
- brandColor: brandColor,
223
- count: state.shotCount,
224
- kind: "record",
225
- onCheck: handCheck,
226
- thumbnailPath: state.shotUrl
227
- });
189
+ return /*#__PURE__*/React.createElement(View, {
190
+ className: "ipc-player-plugin-record-success-toast"
191
+ }, /*#__PURE__*/React.createElement(View, {
192
+ className: "ipc-player-plugin-record-success-toast-image-box"
193
+ }, /*#__PURE__*/React.createElement(Image, {
194
+ className: "ipc-player-plugin-record-success-toast-image",
195
+ src: state.shotUrl
196
+ }), /*#__PURE__*/React.createElement(View, {
197
+ className: "ipc-player-plugin-record-success-play-icon-box"
198
+ }, /*#__PURE__*/React.createElement(Text, {
199
+ className: clsx('icon-panel', 'icon-panel-record-play', 'ipc-player-plugin-record-success-play-icon')
200
+ }))), /*#__PURE__*/React.createElement(View, {
201
+ className: "ipc-player-plugin-record-success-toast-title"
202
+ }, Strings.getLang('ipc_player_record_success_tip')), /*#__PURE__*/React.createElement(View, {
203
+ onClick: handCheck,
204
+ className: "ipc-player-plugin-record-success-toast-bottom",
205
+ style: {
206
+ color: brandColor,
207
+ borderColor: brandColor
208
+ }
209
+ }, Strings.getLang('ipc_player_record_success_check')));
228
210
  }
229
211
  });
230
212
  timeToCloseRecordToast();
@@ -248,8 +230,9 @@ export function RecordVideo(props) {
248
230
  });
249
231
  };
250
232
  const handRecordVideo = async () => {
251
- var _props$event;
252
- ((_props$event = props.event) !== null && _props$event !== void 0 ? _props$event : event).emit(widgetClick, {
233
+ var _props$event, _props$event2;
234
+ const ev = (_props$event = props.event) !== null && _props$event !== void 0 ? _props$event : event;
235
+ ((_props$event2 = props.event) !== null && _props$event2 !== void 0 ? _props$event2 : event).emit(widgetClick, {
253
236
  widgetId: widgetLabs.RECORD_VIDEO
254
237
  });
255
238
  event.emit(pauseTimeToHideAllComponent);
@@ -259,7 +242,6 @@ export function RecordVideo(props) {
259
242
  if (recordingDisabled) {
260
243
  return false;
261
244
  }
262
- recordResultRequestIdRef.current += 1;
263
245
  if (state.showShot && _recording) {
264
246
  setState({
265
247
  showShot: false
@@ -274,6 +256,10 @@ export function RecordVideo(props) {
274
256
  }
275
257
  try {
276
258
  const recordInfo = await setRecording(target);
259
+ if (recordInfo === false) {
260
+ ev.emit(changeIgnoreHideStopPreview, false);
261
+ return false;
262
+ }
277
263
  if (target) {
278
264
  setRecordingDisabled(true);
279
265
  setState({
@@ -283,7 +269,11 @@ export function RecordVideo(props) {
283
269
  timeToResetRecordDisabled();
284
270
  } else {
285
271
  props.event ? props.event.emit(changeIgnoreHideStopPreview, false) : event.emit(changeIgnoreHideStopPreview, false);
286
- await showRecordResult(recordInfo);
272
+ setState({
273
+ showTimer: false,
274
+ showShot: true,
275
+ shotUrl: recordInfo.tempImagePath
276
+ });
287
277
  }
288
278
  } catch (err) {
289
279
  props.event ? props.event.emit(changeIgnoreHideStopPreview, false) : event.emit(changeIgnoreHideStopPreview, false);