@ray-js/ipc-player-integration 0.0.1-beta-43 → 0.0.1-beta-45
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 +75 -13
- package/lib/i18n/index.d.ts +24 -0
- package/lib/i18n/strings.d.ts +12 -0
- package/lib/i18n/strings.js +14 -2
- package/lib/plugins/recordVideo/recordVideo.js +26 -13
- package/lib/plugins/screenshot/screenshot.js +44 -14
- package/lib/plugins/voiceIntercom/voiceIntercom.js +3 -3
- package/lib/ui/ui.js +2 -2
- package/package.json +2 -2
package/lib/ctx/ctx.js
CHANGED
|
@@ -3,6 +3,7 @@ import "core-js/modules/esnext.iterator.filter.js";
|
|
|
3
3
|
import "core-js/modules/esnext.iterator.find.js";
|
|
4
4
|
import "core-js/modules/esnext.iterator.map.js";
|
|
5
5
|
import { useRef, useCallback, useEffect } from 'react';
|
|
6
|
+
import { getSystemInfoSync, showModal, openSystemSettingPage } from '@ray-js/ray';
|
|
6
7
|
import Strings from '../i18n';
|
|
7
8
|
import { useAtom, updateAtom, getDefaultStore, useStore } from './store';
|
|
8
9
|
import { PlayState, IntercomMode } from '../interface';
|
|
@@ -202,18 +203,49 @@ export const createUseCtx = _ref => {
|
|
|
202
203
|
if (!target && target === _intercom) return true;
|
|
203
204
|
return new Promise((resolve, reject) => {
|
|
204
205
|
if (target) {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
206
|
+
ty.authorizeStatus({
|
|
207
|
+
// 麦克风权限
|
|
208
|
+
scope: 'scope.record',
|
|
209
|
+
success: success => {
|
|
210
|
+
console.log(success, 'success');
|
|
211
|
+
IPCPlayerInstance.current.startTalk({
|
|
212
|
+
success: () => {
|
|
213
|
+
updateAtom(intercom, true);
|
|
214
|
+
resolve(true);
|
|
215
|
+
},
|
|
216
|
+
fail: err => {
|
|
217
|
+
const errObj = err.innerError || err || {};
|
|
218
|
+
const errMsg = errObj.errorMsg || Strings.getLang('ipc_player_error_intercom');
|
|
219
|
+
toast({
|
|
220
|
+
title: errMsg
|
|
221
|
+
});
|
|
222
|
+
reject(err);
|
|
223
|
+
}
|
|
224
|
+
});
|
|
209
225
|
},
|
|
210
226
|
fail: err => {
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
227
|
+
showModal({
|
|
228
|
+
title: '',
|
|
229
|
+
content: Strings.getLang('ipc_player_no_record_permission'),
|
|
230
|
+
cancelText: Strings.getLang('ipc_player_authorize_cancel_text'),
|
|
231
|
+
confirmText: Strings.getLang('ipc_player_authorize_confirm_text'),
|
|
232
|
+
isShowGlobal: true,
|
|
233
|
+
success: res => {
|
|
234
|
+
if (res.confirm) {
|
|
235
|
+
const {
|
|
236
|
+
platform
|
|
237
|
+
} = getSystemInfoSync();
|
|
238
|
+
console.log(platform, 'platform');
|
|
239
|
+
openSystemSettingPage({
|
|
240
|
+
scope: platform === 'ios' ? 'App-Settings' : 'App-Settings-Permission',
|
|
241
|
+
success: () => {
|
|
242
|
+
console.log('跳转成功');
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
}
|
|
216
247
|
});
|
|
248
|
+
reject(err);
|
|
217
249
|
}
|
|
218
250
|
});
|
|
219
251
|
} else {
|
|
@@ -244,13 +276,43 @@ export const createUseCtx = _ref => {
|
|
|
244
276
|
}
|
|
245
277
|
return new Promise((resolve, reject) => {
|
|
246
278
|
if (target) {
|
|
247
|
-
|
|
248
|
-
|
|
279
|
+
// 麦克风权限
|
|
280
|
+
ty.authorizeStatus({
|
|
281
|
+
scope: 'scope.writePhotosAlbum',
|
|
249
282
|
success: () => {
|
|
250
|
-
|
|
251
|
-
|
|
283
|
+
IPCPlayerInstance.current.startRecord({
|
|
284
|
+
saveToAlbum,
|
|
285
|
+
success: () => {
|
|
286
|
+
updateAtom(recording, true);
|
|
287
|
+
resolve(true);
|
|
288
|
+
},
|
|
289
|
+
fail: err => {
|
|
290
|
+
reject(err);
|
|
291
|
+
}
|
|
292
|
+
});
|
|
252
293
|
},
|
|
253
294
|
fail: err => {
|
|
295
|
+
showModal({
|
|
296
|
+
title: '',
|
|
297
|
+
content: Strings.getLang('ipc_player_no_album_permission'),
|
|
298
|
+
cancelText: Strings.getLang('ipc_player_authorize_cancel_text'),
|
|
299
|
+
confirmText: Strings.getLang('ipc_player_authorize_confirm_text'),
|
|
300
|
+
isShowGlobal: true,
|
|
301
|
+
success: res => {
|
|
302
|
+
if (res.confirm) {
|
|
303
|
+
const {
|
|
304
|
+
platform
|
|
305
|
+
} = getSystemInfoSync();
|
|
306
|
+
console.log(platform, 'platform');
|
|
307
|
+
openSystemSettingPage({
|
|
308
|
+
scope: platform === 'ios' ? 'App-Settings' : 'App-Settings-Permission',
|
|
309
|
+
success: () => {
|
|
310
|
+
console.log('跳转成功');
|
|
311
|
+
}
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
});
|
|
254
316
|
reject(err);
|
|
255
317
|
}
|
|
256
318
|
});
|
package/lib/i18n/index.d.ts
CHANGED
|
@@ -12,6 +12,12 @@ declare const Strings: kit.I18N<{
|
|
|
12
12
|
ipc_player_recording_now_tip: string;
|
|
13
13
|
ipc_player_stop_recording_err: string;
|
|
14
14
|
ipc_player_resolution_change_error: string;
|
|
15
|
+
ipc_player_require_record_permission: string;
|
|
16
|
+
ipc_player_error_intercom: string;
|
|
17
|
+
ipc_player_no_record_permission: string;
|
|
18
|
+
ipc_player_no_album_permission: string;
|
|
19
|
+
ipc_player_authorize_cancel_text: string;
|
|
20
|
+
ipc_player_authorize_confirm_text: string;
|
|
15
21
|
};
|
|
16
22
|
zh: {
|
|
17
23
|
ipc_player_resolution_HD: string;
|
|
@@ -25,6 +31,12 @@ declare const Strings: kit.I18N<{
|
|
|
25
31
|
ipc_player_recording_now_tip: string;
|
|
26
32
|
ipc_player_stop_recording_err: string;
|
|
27
33
|
ipc_player_resolution_change_error: string;
|
|
34
|
+
ipc_player_require_record_permission: string;
|
|
35
|
+
ipc_player_error_intercom: string;
|
|
36
|
+
ipc_player_no_record_permission: string;
|
|
37
|
+
ipc_player_no_album_permission: string;
|
|
38
|
+
ipc_player_authorize_cancel_text: string;
|
|
39
|
+
ipc_player_authorize_confirm_text: string;
|
|
28
40
|
};
|
|
29
41
|
}, {
|
|
30
42
|
ipc_player_resolution_HD: string;
|
|
@@ -38,6 +50,12 @@ declare const Strings: kit.I18N<{
|
|
|
38
50
|
ipc_player_recording_now_tip: string;
|
|
39
51
|
ipc_player_stop_recording_err: string;
|
|
40
52
|
ipc_player_resolution_change_error: string;
|
|
53
|
+
ipc_player_require_record_permission: string;
|
|
54
|
+
ipc_player_error_intercom: string;
|
|
55
|
+
ipc_player_no_record_permission: string;
|
|
56
|
+
ipc_player_no_album_permission: string;
|
|
57
|
+
ipc_player_authorize_cancel_text: string;
|
|
58
|
+
ipc_player_authorize_confirm_text: string;
|
|
41
59
|
} | {
|
|
42
60
|
ipc_player_resolution_HD: string;
|
|
43
61
|
ipc_player_resolution_SD: string;
|
|
@@ -50,5 +68,11 @@ declare const Strings: kit.I18N<{
|
|
|
50
68
|
ipc_player_recording_now_tip: string;
|
|
51
69
|
ipc_player_stop_recording_err: string;
|
|
52
70
|
ipc_player_resolution_change_error: string;
|
|
71
|
+
ipc_player_require_record_permission: string;
|
|
72
|
+
ipc_player_error_intercom: string;
|
|
73
|
+
ipc_player_no_record_permission: string;
|
|
74
|
+
ipc_player_no_album_permission: string;
|
|
75
|
+
ipc_player_authorize_cancel_text: string;
|
|
76
|
+
ipc_player_authorize_confirm_text: string;
|
|
53
77
|
}>;
|
|
54
78
|
export default Strings;
|
package/lib/i18n/strings.d.ts
CHANGED
|
@@ -11,6 +11,12 @@ declare const _default: {
|
|
|
11
11
|
ipc_player_recording_now_tip: string;
|
|
12
12
|
ipc_player_stop_recording_err: string;
|
|
13
13
|
ipc_player_resolution_change_error: string;
|
|
14
|
+
ipc_player_require_record_permission: string;
|
|
15
|
+
ipc_player_error_intercom: string;
|
|
16
|
+
ipc_player_no_record_permission: string;
|
|
17
|
+
ipc_player_no_album_permission: string;
|
|
18
|
+
ipc_player_authorize_cancel_text: string;
|
|
19
|
+
ipc_player_authorize_confirm_text: string;
|
|
14
20
|
};
|
|
15
21
|
zh: {
|
|
16
22
|
ipc_player_resolution_HD: string;
|
|
@@ -24,6 +30,12 @@ declare const _default: {
|
|
|
24
30
|
ipc_player_recording_now_tip: string;
|
|
25
31
|
ipc_player_stop_recording_err: string;
|
|
26
32
|
ipc_player_resolution_change_error: string;
|
|
33
|
+
ipc_player_require_record_permission: string;
|
|
34
|
+
ipc_player_error_intercom: string;
|
|
35
|
+
ipc_player_no_record_permission: string;
|
|
36
|
+
ipc_player_no_album_permission: string;
|
|
37
|
+
ipc_player_authorize_cancel_text: string;
|
|
38
|
+
ipc_player_authorize_confirm_text: string;
|
|
27
39
|
};
|
|
28
40
|
};
|
|
29
41
|
export default _default;
|
package/lib/i18n/strings.js
CHANGED
|
@@ -10,7 +10,13 @@ export default {
|
|
|
10
10
|
ipc_player_record_success_check: 'View',
|
|
11
11
|
ipc_player_recording_now_tip: 'Recording in progress...',
|
|
12
12
|
ipc_player_stop_recording_err: 'Failed to stop recording. Please exit and try again.',
|
|
13
|
-
ipc_player_resolution_change_error: 'Switch failed, check device and network.'
|
|
13
|
+
ipc_player_resolution_change_error: 'Switch failed, check device and network.',
|
|
14
|
+
ipc_player_require_record_permission: 'Recording permission is not enabled. Please go to the app settings to enable it.',
|
|
15
|
+
ipc_player_error_intercom: 'Intercom activation failed.',
|
|
16
|
+
ipc_player_no_record_permission: 'The microphone permission is not enabled. Please go to the app settings to enable it first.',
|
|
17
|
+
ipc_player_no_album_permission: 'You currently do not have access to the album. Please enable this permission in the settings.',
|
|
18
|
+
ipc_player_authorize_cancel_text: 'Cancel',
|
|
19
|
+
ipc_player_authorize_confirm_text: 'Go to Settings'
|
|
14
20
|
},
|
|
15
21
|
zh: {
|
|
16
22
|
ipc_player_resolution_HD: '高清',
|
|
@@ -23,6 +29,12 @@ export default {
|
|
|
23
29
|
ipc_player_record_success_check: '查看',
|
|
24
30
|
ipc_player_recording_now_tip: '正在录像中...',
|
|
25
31
|
ipc_player_stop_recording_err: '结束录像失败,请退出重试',
|
|
26
|
-
ipc_player_resolution_change_error: '切换失败,请检查设备及网络状态'
|
|
32
|
+
ipc_player_resolution_change_error: '切换失败,请检查设备及网络状态',
|
|
33
|
+
ipc_player_require_record_permission: '录制权限未开启,请先前往应用设置进行开启',
|
|
34
|
+
ipc_player_error_intercom: '对讲开启失败',
|
|
35
|
+
ipc_player_no_record_permission: '您当前没有 麦克风 的访问权限, 请在设置中打开此权限',
|
|
36
|
+
ipc_player_no_album_permission: '您当前没有 相册 的访问权限, 请在设置中打开此权限',
|
|
37
|
+
ipc_player_authorize_cancel_text: '取消',
|
|
38
|
+
ipc_player_authorize_confirm_text: '去设置'
|
|
27
39
|
}
|
|
28
40
|
};
|
|
@@ -221,20 +221,33 @@ export function RecordVideo(props) {
|
|
|
221
221
|
showShot: false
|
|
222
222
|
});
|
|
223
223
|
}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
224
|
+
try {
|
|
225
|
+
const recordInfo = await setRecording(target);
|
|
226
|
+
console.log(recordInfo, 'recordInfo====');
|
|
227
|
+
if (target) {
|
|
228
|
+
setRecordingDisabled(true);
|
|
229
|
+
setState({
|
|
230
|
+
showTimer: true
|
|
231
|
+
});
|
|
232
|
+
/** 录制开始后3秒后才可结束 */
|
|
233
|
+
timeToResetRecordDisabled();
|
|
234
|
+
} else {
|
|
235
|
+
setState({
|
|
236
|
+
showTimer: false,
|
|
237
|
+
showShot: true,
|
|
238
|
+
shotUrl: recordInfo.tempImagePath
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
} catch (err) {
|
|
242
|
+
console.log('录制失败', err);
|
|
243
|
+
if ((err === null || err === void 0 ? void 0 : err.errorCode) === 7) {
|
|
244
|
+
ty.showToast({
|
|
245
|
+
icon: 'none',
|
|
246
|
+
title: Strings.getLang('ipc_player_require_record_permission')
|
|
247
|
+
});
|
|
248
|
+
}
|
|
234
249
|
setState({
|
|
235
|
-
showTimer: false
|
|
236
|
-
showShot: true,
|
|
237
|
-
shotUrl: recordInfo.tempImagePath
|
|
250
|
+
showTimer: false
|
|
238
251
|
});
|
|
239
252
|
}
|
|
240
253
|
return true;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useContext, useRef } from 'react';
|
|
2
|
-
import { View, Image, Text } from '@ray-js/ray';
|
|
2
|
+
import { View, Image, Text, showModal, openSystemSettingPage, getSystemInfoSync } from '@ray-js/ray';
|
|
3
3
|
import { useSetState, useUpdateEffect, useMemoizedFn } from 'ahooks';
|
|
4
4
|
import clsx from 'clsx';
|
|
5
5
|
import IpcUtils from '@ray-js/ray-ipc-utils';
|
|
@@ -106,21 +106,51 @@ export function Screenshot(props) {
|
|
|
106
106
|
showShot: false
|
|
107
107
|
});
|
|
108
108
|
event.emit(pauseTimeToHideAllComponent);
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
success:
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
109
|
+
ty.authorizeStatus({
|
|
110
|
+
// 相册写入权限
|
|
111
|
+
scope: 'scope.writePhotosAlbum',
|
|
112
|
+
success: () => {
|
|
113
|
+
IPCPlayerContext.snapshot({
|
|
114
|
+
saveToAlbum,
|
|
115
|
+
// 保存到 IPC 相册
|
|
116
|
+
success: res => {
|
|
117
|
+
console.log(res, 'res');
|
|
118
|
+
setState({
|
|
119
|
+
showShot: true,
|
|
120
|
+
shotUrl: res.tempImagePath
|
|
121
|
+
});
|
|
122
|
+
},
|
|
123
|
+
fail: err => {
|
|
124
|
+
console.log(err, 'err');
|
|
125
|
+
const errObj = err.innerError || err || {};
|
|
126
|
+
const errMsg = errObj.errorMsg || Strings.getLang('ipc_player_error_screenshot_error_tip');
|
|
127
|
+
toast({
|
|
128
|
+
title: errMsg
|
|
129
|
+
});
|
|
130
|
+
}
|
|
117
131
|
});
|
|
118
132
|
},
|
|
119
|
-
fail:
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
133
|
+
fail: () => {
|
|
134
|
+
showModal({
|
|
135
|
+
title: '',
|
|
136
|
+
content: Strings.getLang('ipc_player_no_album_permission'),
|
|
137
|
+
cancelText: Strings.getLang('ipc_player_authorize_cancel_text'),
|
|
138
|
+
confirmText: Strings.getLang('ipc_player_authorize_confirm_text'),
|
|
139
|
+
isShowGlobal: true,
|
|
140
|
+
success: res => {
|
|
141
|
+
if (res.confirm) {
|
|
142
|
+
const {
|
|
143
|
+
platform
|
|
144
|
+
} = getSystemInfoSync();
|
|
145
|
+
console.log(platform, 'platform');
|
|
146
|
+
openSystemSettingPage({
|
|
147
|
+
scope: platform === 'ios' ? 'App-Settings' : 'App-Settings-Permission',
|
|
148
|
+
success: () => {
|
|
149
|
+
console.log('跳转成功');
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
}
|
|
124
154
|
});
|
|
125
155
|
}
|
|
126
156
|
});
|
|
@@ -59,14 +59,14 @@ export const VoiceIntercom = props => {
|
|
|
59
59
|
}
|
|
60
60
|
console.log('==== 开始对讲 =====');
|
|
61
61
|
originMuteStatusBeforeVoice.current = _mute;
|
|
62
|
-
|
|
63
|
-
//
|
|
62
|
+
await setIntercom(true);
|
|
63
|
+
// 确定对讲有成功回调后,单向对讲判断开始对讲前需要静音
|
|
64
|
+
// 确定对讲有成功回调后, 双路对讲开始对讲前需要打开拾音器
|
|
64
65
|
const muteTarget = intercomMode === IntercomMode.OneWay;
|
|
65
66
|
if (_mute !== muteTarget) {
|
|
66
67
|
console.log(`=== 切换静音状态: ${_mute}`, `${intercomMode}`);
|
|
67
68
|
await setMute(muteTarget);
|
|
68
69
|
}
|
|
69
|
-
await setIntercom(true);
|
|
70
70
|
event.emit(pauseTimeToHideAllComponent);
|
|
71
71
|
};
|
|
72
72
|
const endVoice = async () => {
|
package/lib/ui/ui.js
CHANGED
|
@@ -92,8 +92,8 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
92
92
|
platform,
|
|
93
93
|
deviceType
|
|
94
94
|
} = systemInfo.current;
|
|
95
|
-
// ios pad
|
|
96
|
-
if (
|
|
95
|
+
// 针对pad 暂不支持横屏,且在ios pad模式下 会触发onResize事件, 待解决
|
|
96
|
+
if (deviceType === 'pad') {
|
|
97
97
|
setScreenType('vertical');
|
|
98
98
|
} else {
|
|
99
99
|
setScreenType(type === 'landscape' ? 'full' : 'vertical');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ray-js/ipc-player-integration",
|
|
3
|
-
"version": "0.0.1-beta-
|
|
3
|
+
"version": "0.0.1-beta-45",
|
|
4
4
|
"description": "IPC 播放器功能集成",
|
|
5
5
|
"main": "lib/index",
|
|
6
6
|
"files": [
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@ray-js/ipc-ptz-zoom": "0.0.2-beta-7",
|
|
40
40
|
"@ray-js/panel-sdk": "^1.13.1",
|
|
41
|
-
"@ray-js/ray-ipc-player": "2.0.20-beta-
|
|
41
|
+
"@ray-js/ray-ipc-player": "2.0.20-beta-10",
|
|
42
42
|
"@ray-js/ray-ipc-utils": "1.1.0-beta-15",
|
|
43
43
|
"@ray-js/svg": "0.2.0",
|
|
44
44
|
"clsx": "^1.2.1",
|