@ray-js/ipc-player-integration 0.0.52-beta.2 → 0.0.52-beta.3
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.js
CHANGED
|
@@ -254,13 +254,9 @@ export const createUseCtx = _ref => {
|
|
|
254
254
|
});
|
|
255
255
|
};
|
|
256
256
|
const stopRecording = showError => {
|
|
257
|
-
const sessionMultiLens = recordingMultiLensRef.current;
|
|
258
257
|
return new Promise((resolve, reject) => {
|
|
259
|
-
IPCPlayerInstance.current.stopRecord(
|
|
260
|
-
saveToAlbum
|
|
261
|
-
}, sessionMultiLens ? {
|
|
262
|
-
multiLens: true
|
|
263
|
-
} : {}), {}, {
|
|
258
|
+
IPCPlayerInstance.current.stopRecord({
|
|
259
|
+
saveToAlbum,
|
|
264
260
|
success: res => {
|
|
265
261
|
recordingMultiLensRef.current = false;
|
|
266
262
|
updateAtom(recording, false);
|
|
@@ -278,7 +274,7 @@ export const createUseCtx = _ref => {
|
|
|
278
274
|
});
|
|
279
275
|
}
|
|
280
276
|
}
|
|
281
|
-
})
|
|
277
|
+
});
|
|
282
278
|
});
|
|
283
279
|
};
|
|
284
280
|
const multiCameraCtx = useMultiCameraCtx({
|
|
@@ -437,15 +433,10 @@ export const createUseCtx = _ref => {
|
|
|
437
433
|
}
|
|
438
434
|
if (!target) return stopRecording(true);
|
|
439
435
|
return new Promise((resolve, reject) => {
|
|
440
|
-
const sessionMultiLens = multiLens;
|
|
441
436
|
const startRecord = () => {
|
|
442
|
-
IPCPlayerInstance.current.startRecord(
|
|
443
|
-
saveToAlbum
|
|
444
|
-
}, sessionMultiLens ? {
|
|
445
|
-
multiLens: true
|
|
446
|
-
} : {}), {}, {
|
|
437
|
+
IPCPlayerInstance.current.startRecord({
|
|
438
|
+
saveToAlbum,
|
|
447
439
|
success: () => {
|
|
448
|
-
recordingMultiLensRef.current = sessionMultiLens;
|
|
449
440
|
updateAtom(recording, true);
|
|
450
441
|
resolve(true);
|
|
451
442
|
},
|
|
@@ -453,7 +444,7 @@ export const createUseCtx = _ref => {
|
|
|
453
444
|
eventRef.current.emit(changeIgnoreHideStopPreview, false);
|
|
454
445
|
reject(err);
|
|
455
446
|
}
|
|
456
|
-
})
|
|
447
|
+
});
|
|
457
448
|
};
|
|
458
449
|
// 写入相册
|
|
459
450
|
ty.authorizeStatus({
|
package/lib/ui/ui.js
CHANGED
|
@@ -654,7 +654,8 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
654
654
|
setRecording(false, true);
|
|
655
655
|
setIntercom(false, true);
|
|
656
656
|
instance === null || instance === void 0 || instance.stopRecordingOnUnload().then(result => {
|
|
657
|
-
|
|
657
|
+
var _instance$multiCamera;
|
|
658
|
+
const summary = getCaptureResultSummary(result, 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);
|
|
658
659
|
ipcTTTOperatorLog(summary !== null && summary !== void 0 && summary.isMultiLens ? `hide: stop recording succeeded with ${summary.count} files` : 'hide: 调用停止录制方法成功');
|
|
659
660
|
}).catch(() => {
|
|
660
661
|
ipcTTTOperatorLog('hide: 调用停止录制方法失败');
|
|
@@ -1118,17 +1119,17 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
1118
1119
|
// 这一下起,自动隐藏倒计时才开始生效
|
|
1119
1120
|
hasUserTappedPlayerRef.current = true;
|
|
1120
1121
|
if (instance.multiCameraCtx.isSupport) {
|
|
1121
|
-
var _instance$
|
|
1122
|
-
const preTapIndex = (_instance$
|
|
1122
|
+
var _instance$multiCamera2, _instance$multiCamera3;
|
|
1123
|
+
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;
|
|
1123
1124
|
const wasHidden = componentHideState;
|
|
1124
1125
|
instance.multiCameraCtx.selectVideoFiredRef.current = false;
|
|
1125
1126
|
if (multiTapTimerRef.current) {
|
|
1126
1127
|
clearTimeout(multiTapTimerRef.current);
|
|
1127
1128
|
}
|
|
1128
1129
|
multiTapTimerRef.current = setTimeout(() => {
|
|
1129
|
-
var _instance$
|
|
1130
|
+
var _instance$multiCamera4, _instance$multiCamera5;
|
|
1130
1131
|
const selectFired = !!instance.multiCameraCtx.selectVideoFiredRef.current;
|
|
1131
|
-
const currentIndex = (_instance$
|
|
1132
|
+
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
1133
|
if (selectFired && currentIndex === preTapIndex) {
|
|
1133
1134
|
if (wasHidden) {
|
|
1134
1135
|
showComponents();
|
|
@@ -4,4 +4,6 @@ export type CaptureResultSummary = {
|
|
|
4
4
|
isMultiLens: boolean;
|
|
5
5
|
thumbnailPath: string;
|
|
6
6
|
};
|
|
7
|
-
|
|
7
|
+
/** 从新多目高级能力配置获取当前设备的总镜头数 */
|
|
8
|
+
export declare function getMultiLensCountFromAbility(): number;
|
|
9
|
+
export declare function getCaptureResultSummary(result: CaptureResult, fallbackCount?: number): CaptureResultSummary | null;
|
|
@@ -1,17 +1,54 @@
|
|
|
1
|
-
|
|
1
|
+
import { getDevInfo } from '@ray-js/ray-ipc-utils';
|
|
2
|
+
/** 从新多目高级能力配置获取当前设备的总镜头数 */
|
|
3
|
+
export function getMultiLensCountFromAbility() {
|
|
4
|
+
try {
|
|
5
|
+
var _devInfo$configMetas;
|
|
6
|
+
const devInfo = getDevInfo();
|
|
7
|
+
const raw = devInfo === null || devInfo === void 0 || (_devInfo$configMetas = devInfo.configMetas) === null || _devInfo$configMetas === void 0 ? void 0 : _devInfo$configMetas.tyabimr4v3;
|
|
8
|
+
if (raw) {
|
|
9
|
+
const parsed = typeof raw === 'string' ? JSON.parse(raw) : raw;
|
|
10
|
+
const count = Number(parsed === null || parsed === void 0 ? void 0 : parsed.total_split_num) || (Array.isArray(parsed === null || parsed === void 0 ? void 0 : parsed.split_info) ? parsed.split_info.length : 0);
|
|
11
|
+
if (count > 1) {
|
|
12
|
+
return count;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
} catch (e) {
|
|
16
|
+
// ignore
|
|
17
|
+
}
|
|
18
|
+
return 0;
|
|
19
|
+
}
|
|
20
|
+
const extractPath = item => {
|
|
21
|
+
if (!item) return '';
|
|
22
|
+
if (typeof item === 'string') return item;
|
|
23
|
+
if (typeof (item === null || item === void 0 ? void 0 : item.value) === 'string') return item.value;
|
|
24
|
+
return '';
|
|
25
|
+
};
|
|
26
|
+
export function getCaptureResultSummary(result, fallbackCount) {
|
|
2
27
|
if (!result || typeof result === 'boolean') return null;
|
|
3
|
-
|
|
28
|
+
const rawResult = result;
|
|
29
|
+
const singleThumb = extractPath(rawResult.tempImagePath) || extractPath(rawResult.thumbPath) || extractPath(rawResult.filePath) || '';
|
|
30
|
+
if ('items' in result && Array.isArray(result.items) && result.items.length > 0) {
|
|
4
31
|
const firstItem = result.items[0];
|
|
5
|
-
|
|
32
|
+
const firstThumb = extractPath(firstItem === null || firstItem === void 0 ? void 0 : firstItem.tempImagePath) || extractPath(firstItem === null || firstItem === void 0 ? void 0 : firstItem.thumbPath) || extractPath(firstItem === null || firstItem === void 0 ? void 0 : firstItem.filePath) || singleThumb;
|
|
6
33
|
return {
|
|
7
34
|
count: result.items.length,
|
|
8
35
|
isMultiLens: true,
|
|
9
|
-
thumbnailPath:
|
|
36
|
+
thumbnailPath: firstThumb
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// 根据新多目高级能力获取总镜头数(从协议传入的 fallbackCount 或从设备能力元数据获取)
|
|
41
|
+
const multiCount = fallbackCount && fallbackCount > 1 ? fallbackCount : getMultiLensCountFromAbility();
|
|
42
|
+
if (multiCount > 1) {
|
|
43
|
+
return {
|
|
44
|
+
count: multiCount,
|
|
45
|
+
isMultiLens: true,
|
|
46
|
+
thumbnailPath: singleThumb
|
|
10
47
|
};
|
|
11
48
|
}
|
|
12
49
|
return {
|
|
13
50
|
count: 1,
|
|
14
51
|
isMultiLens: false,
|
|
15
|
-
thumbnailPath:
|
|
52
|
+
thumbnailPath: singleThumb
|
|
16
53
|
};
|
|
17
54
|
}
|
|
@@ -108,7 +108,9 @@ export function RecordVideo(props) {
|
|
|
108
108
|
shotCount: 0
|
|
109
109
|
});
|
|
110
110
|
const showRecordResult = recordInfo => {
|
|
111
|
-
|
|
111
|
+
var _props$multiCameraCtx;
|
|
112
|
+
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;
|
|
113
|
+
const summary = getCaptureResultSummary(recordInfo, splitNum);
|
|
112
114
|
if (!summary) return;
|
|
113
115
|
setState({
|
|
114
116
|
showTimer: false,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
1
|
import React, { useContext, useRef } from 'react';
|
|
3
2
|
import { View, Text, showModal, openAppSystemSettingPage, getSystemInfoSync } from '@ray-js/ray';
|
|
4
3
|
import { useSetState, useUpdateEffect, useMemoizedFn } from 'ahooks';
|
|
@@ -127,14 +126,13 @@ export function Screenshot(props) {
|
|
|
127
126
|
});
|
|
128
127
|
};
|
|
129
128
|
const takeSnapshot = () => {
|
|
130
|
-
IPCPlayerContext.snapshot(
|
|
131
|
-
saveToAlbum
|
|
132
|
-
}, props.multiLens ? {
|
|
133
|
-
multiLens: true
|
|
134
|
-
} : {}), {}, {
|
|
129
|
+
IPCPlayerContext.snapshot({
|
|
130
|
+
saveToAlbum,
|
|
135
131
|
success: res => {
|
|
132
|
+
var _props$multiCameraCtx;
|
|
136
133
|
setIgnoreHideStopPreview(false);
|
|
137
|
-
const
|
|
134
|
+
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;
|
|
135
|
+
const summary = getCaptureResultSummary(res, splitNum);
|
|
138
136
|
if (!summary) {
|
|
139
137
|
handleSnapshotFail({});
|
|
140
138
|
return;
|
|
@@ -146,7 +144,7 @@ export function Screenshot(props) {
|
|
|
146
144
|
});
|
|
147
145
|
},
|
|
148
146
|
fail: handleSnapshotFail
|
|
149
|
-
})
|
|
147
|
+
});
|
|
150
148
|
};
|
|
151
149
|
ty.authorizeStatus({
|
|
152
150
|
// 相册写入权限
|