@ray-js/ipc-player-integration 0.0.1-beta-22 → 0.0.1-beta-24
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 +13 -5
- package/lib/i18n/index.d.ts +24 -8
- package/lib/i18n/strings.d.ts +12 -4
- package/lib/i18n/strings.js +12 -4
- package/lib/interface.d.ts +7 -1
- package/lib/plugins/fullScreen/fullScreen.js +1 -3
- package/lib/plugins/fullScreen/fullScreen.less +2 -1
- package/lib/plugins/fullScreen/voiceIntercom.js +2 -2
- package/lib/plugins/ptz/ptz.js +9 -6
- package/lib/plugins/ptz/ptz.less +1 -6
- package/lib/plugins/ptz/ptzControl.d.ts +0 -1
- package/lib/plugins/ptz/ptzControl.js +76 -30
- package/lib/plugins/recordVideo/recordVideo.js +148 -21
- package/lib/plugins/recordVideo/recordVideo.less +61 -4
- package/lib/plugins/resolution/fullResolutionControl.js +2 -1
- package/lib/plugins/resolution/resolution.js +3 -0
- package/lib/plugins/resolution/resolution.less +1 -2
- package/lib/plugins/screenshot/screenshot.js +40 -13
- package/lib/plugins/screenshot/screenshot.less +1 -4
- package/lib/plugins/voiceIntercom/voiceIntercom.d.ts +1 -1
- package/lib/plugins/voiceIntercom/voiceIntercom.js +25 -18
- package/lib/ui/bottomLeftContent.js +5 -5
- package/lib/ui/bottomRightContent.js +5 -5
- package/lib/ui/topLeftContent.js +6 -10
- package/lib/ui/topRightContent.js +5 -5
- package/lib/ui/ui.d.ts +1 -0
- package/lib/ui/ui.js +25 -21
- package/lib/utils/device/index.d.ts +6 -0
- package/lib/utils/device/index.js +52 -0
- package/lib/utils/index.d.ts +3 -0
- package/lib/utils/index.js +15 -0
- package/package.json +3 -3
package/lib/ctx/ctx.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useRef, useCallback, useEffect } from 'react';
|
|
2
|
+
import Strings from '../i18n';
|
|
2
3
|
import { useAtom, updateAtom, getDefaultStore, useStore } from './store';
|
|
3
4
|
import { PlayState, IntercomMode } from '../interface';
|
|
4
5
|
import { ClarityType } from '@ray-js/ray-ipc-utils/lib/interface';
|
|
@@ -33,6 +34,9 @@ export const createUseCtx = _ref => {
|
|
|
33
34
|
// 录像中
|
|
34
35
|
const [recording] = useAtom(false);
|
|
35
36
|
|
|
37
|
+
// 录像是否不可点击
|
|
38
|
+
const [recordingDisabled, setRecordingDisabled] = useAtom(false);
|
|
39
|
+
|
|
36
40
|
// 静音 true 代表静音 false 代表不静音
|
|
37
41
|
const [mute] = useAtom(true);
|
|
38
42
|
|
|
@@ -141,6 +145,7 @@ export const createUseCtx = _ref => {
|
|
|
141
145
|
saveToAlbum,
|
|
142
146
|
screenType,
|
|
143
147
|
recording,
|
|
148
|
+
recordingDisabled,
|
|
144
149
|
mute,
|
|
145
150
|
resolution,
|
|
146
151
|
resolutionList,
|
|
@@ -196,7 +201,9 @@ export const createUseCtx = _ref => {
|
|
|
196
201
|
const store = getDefaultStore();
|
|
197
202
|
const _recording = store.get(recording);
|
|
198
203
|
if (target && target === _recording) {
|
|
199
|
-
|
|
204
|
+
toast({
|
|
205
|
+
title: Strings.getLang('ipc_player_recording_now_tip')
|
|
206
|
+
});
|
|
200
207
|
return false;
|
|
201
208
|
}
|
|
202
209
|
return new Promise((resolve, reject) => {
|
|
@@ -214,15 +221,15 @@ export const createUseCtx = _ref => {
|
|
|
214
221
|
} else {
|
|
215
222
|
IPCPlayerInstance.current.stopRecord({
|
|
216
223
|
saveToAlbum,
|
|
217
|
-
success:
|
|
224
|
+
success: res => {
|
|
218
225
|
updateAtom(recording, false);
|
|
219
|
-
resolve(
|
|
226
|
+
resolve(res);
|
|
220
227
|
},
|
|
221
228
|
fail: err => {
|
|
222
|
-
updateAtom(recording,
|
|
229
|
+
updateAtom(recording, false);
|
|
223
230
|
reject(err);
|
|
224
231
|
const errObj = err.innerError || err || {};
|
|
225
|
-
const errMsg = errObj.errorMsg ||
|
|
232
|
+
const errMsg = errObj.errorMsg || Strings.getLang('ipc_player_stop_recording_err');
|
|
226
233
|
toast({
|
|
227
234
|
title: errMsg
|
|
228
235
|
});
|
|
@@ -231,6 +238,7 @@ export const createUseCtx = _ref => {
|
|
|
231
238
|
}
|
|
232
239
|
});
|
|
233
240
|
},
|
|
241
|
+
setRecordingDisabled,
|
|
234
242
|
setPtzActive,
|
|
235
243
|
setFullResolutionActive,
|
|
236
244
|
setScreenType,
|
package/lib/i18n/index.d.ts
CHANGED
|
@@ -5,30 +5,46 @@ declare const Strings: kit.I18N<{
|
|
|
5
5
|
ipc_player_resolution_SD: string;
|
|
6
6
|
ipc_player_current_resolution_is_equal: string;
|
|
7
7
|
ipc_player_screenshot_success_tip: string;
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
ipc_player_error_screenshot_error_tip: string;
|
|
9
|
+
ipc_player_record_success_tip: string;
|
|
10
|
+
ipc_player_shot_success_check: string;
|
|
11
|
+
ipc_player_record_success_check: string;
|
|
12
|
+
ipc_player_recording_now_tip: string;
|
|
13
|
+
ipc_player_stop_recording_err: string;
|
|
10
14
|
};
|
|
11
15
|
zh: {
|
|
12
16
|
ipc_player_resolution_HD: string;
|
|
13
17
|
ipc_player_resolution_SD: string;
|
|
14
18
|
ipc_player_current_resolution_is_equal: string;
|
|
15
19
|
ipc_player_screenshot_success_tip: string;
|
|
16
|
-
|
|
17
|
-
|
|
20
|
+
ipc_player_error_screenshot_error_tip: string;
|
|
21
|
+
ipc_player_record_success_tip: string;
|
|
22
|
+
ipc_player_shot_success_check: string;
|
|
23
|
+
ipc_player_record_success_check: string;
|
|
24
|
+
ipc_player_recording_now_tip: string;
|
|
25
|
+
ipc_player_stop_recording_err: string;
|
|
18
26
|
};
|
|
19
27
|
}, {
|
|
20
28
|
ipc_player_resolution_HD: string;
|
|
21
29
|
ipc_player_resolution_SD: string;
|
|
22
30
|
ipc_player_current_resolution_is_equal: string;
|
|
23
31
|
ipc_player_screenshot_success_tip: string;
|
|
24
|
-
|
|
25
|
-
|
|
32
|
+
ipc_player_error_screenshot_error_tip: string;
|
|
33
|
+
ipc_player_record_success_tip: string;
|
|
34
|
+
ipc_player_shot_success_check: string;
|
|
35
|
+
ipc_player_record_success_check: string;
|
|
36
|
+
ipc_player_recording_now_tip: string;
|
|
37
|
+
ipc_player_stop_recording_err: string;
|
|
26
38
|
} | {
|
|
27
39
|
ipc_player_resolution_HD: string;
|
|
28
40
|
ipc_player_resolution_SD: string;
|
|
29
41
|
ipc_player_current_resolution_is_equal: string;
|
|
30
42
|
ipc_player_screenshot_success_tip: string;
|
|
31
|
-
|
|
32
|
-
|
|
43
|
+
ipc_player_error_screenshot_error_tip: string;
|
|
44
|
+
ipc_player_record_success_tip: string;
|
|
45
|
+
ipc_player_shot_success_check: string;
|
|
46
|
+
ipc_player_record_success_check: string;
|
|
47
|
+
ipc_player_recording_now_tip: string;
|
|
48
|
+
ipc_player_stop_recording_err: string;
|
|
33
49
|
}>;
|
|
34
50
|
export default Strings;
|
package/lib/i18n/strings.d.ts
CHANGED
|
@@ -4,16 +4,24 @@ declare const _default: {
|
|
|
4
4
|
ipc_player_resolution_SD: string;
|
|
5
5
|
ipc_player_current_resolution_is_equal: string;
|
|
6
6
|
ipc_player_screenshot_success_tip: string;
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
ipc_player_error_screenshot_error_tip: string;
|
|
8
|
+
ipc_player_record_success_tip: string;
|
|
9
|
+
ipc_player_shot_success_check: string;
|
|
10
|
+
ipc_player_record_success_check: string;
|
|
11
|
+
ipc_player_recording_now_tip: string;
|
|
12
|
+
ipc_player_stop_recording_err: string;
|
|
9
13
|
};
|
|
10
14
|
zh: {
|
|
11
15
|
ipc_player_resolution_HD: string;
|
|
12
16
|
ipc_player_resolution_SD: string;
|
|
13
17
|
ipc_player_current_resolution_is_equal: string;
|
|
14
18
|
ipc_player_screenshot_success_tip: string;
|
|
15
|
-
|
|
16
|
-
|
|
19
|
+
ipc_player_error_screenshot_error_tip: string;
|
|
20
|
+
ipc_player_record_success_tip: string;
|
|
21
|
+
ipc_player_shot_success_check: string;
|
|
22
|
+
ipc_player_record_success_check: string;
|
|
23
|
+
ipc_player_recording_now_tip: string;
|
|
24
|
+
ipc_player_stop_recording_err: string;
|
|
17
25
|
};
|
|
18
26
|
};
|
|
19
27
|
export default _default;
|
package/lib/i18n/strings.js
CHANGED
|
@@ -4,15 +4,23 @@ export default {
|
|
|
4
4
|
ipc_player_resolution_SD: 'SD',
|
|
5
5
|
ipc_player_current_resolution_is_equal: 'Already at current clarity',
|
|
6
6
|
ipc_player_screenshot_success_tip: 'Screenshot saved to album',
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
ipc_player_error_screenshot_error_tip: 'Screenshot failed. Please try again later.',
|
|
8
|
+
ipc_player_record_success_tip: 'Recording saved to album',
|
|
9
|
+
ipc_player_shot_success_check: 'View',
|
|
10
|
+
ipc_player_record_success_check: 'View',
|
|
11
|
+
ipc_player_recording_now_tip: 'Recording in progress...',
|
|
12
|
+
ipc_player_stop_recording_err: 'Failed to stop recording. Please exit and try again.'
|
|
9
13
|
},
|
|
10
14
|
zh: {
|
|
11
15
|
ipc_player_resolution_HD: '高清',
|
|
12
16
|
ipc_player_resolution_SD: '标清',
|
|
13
17
|
ipc_player_current_resolution_is_equal: '已是当前清晰度',
|
|
14
18
|
ipc_player_screenshot_success_tip: '截图已保存在APP相册',
|
|
15
|
-
|
|
16
|
-
|
|
19
|
+
ipc_player_error_screenshot_error_tip: '截图失败了,请稍后再试',
|
|
20
|
+
ipc_player_record_success_tip: '录像已保存在APP相册',
|
|
21
|
+
ipc_player_shot_success_check: '查看',
|
|
22
|
+
ipc_player_record_success_check: '查看',
|
|
23
|
+
ipc_player_recording_now_tip: '正在录像中...',
|
|
24
|
+
ipc_player_stop_recording_err: '结束录像失败,请退出重试'
|
|
17
25
|
}
|
|
18
26
|
};
|
package/lib/interface.d.ts
CHANGED
|
@@ -72,8 +72,9 @@ export type ComponentConfig<T = ReturnType<UseCtx> & Record<string, any>> = {
|
|
|
72
72
|
id: string;
|
|
73
73
|
content: (props: T) => React.ReactElement;
|
|
74
74
|
initProps?: T;
|
|
75
|
-
absolutePosition?:
|
|
75
|
+
absolutePosition?: React.CSSProperties;
|
|
76
76
|
absoluteContentClassName?: string;
|
|
77
|
+
absoluteContentStyle?: React.CSSProperties;
|
|
77
78
|
};
|
|
78
79
|
export type ComponentConfigProps = {
|
|
79
80
|
IPCPlayerContext: IpcContext;
|
|
@@ -82,3 +83,8 @@ export type PlayStatusData = {
|
|
|
82
83
|
playState: PlayState;
|
|
83
84
|
playCode: number;
|
|
84
85
|
};
|
|
86
|
+
export type RecordInfoData = boolean | {
|
|
87
|
+
tempImagePath: string;
|
|
88
|
+
filePath: string;
|
|
89
|
+
thumbPath: string;
|
|
90
|
+
};
|
|
@@ -58,9 +58,7 @@ export function FullScreen(props) {
|
|
|
58
58
|
addContent('absolute', {
|
|
59
59
|
id: voiceIntercomId,
|
|
60
60
|
content: props => {
|
|
61
|
-
return /*#__PURE__*/React.createElement(
|
|
62
|
-
className: clsx('ipc-player-plugin-full-screen-voice')
|
|
63
|
-
}, /*#__PURE__*/React.createElement(VoiceIntercom, props));
|
|
61
|
+
return /*#__PURE__*/React.createElement(VoiceIntercom, props);
|
|
64
62
|
},
|
|
65
63
|
absoluteContentClassName: 'ipc-player-plugin-full-screen-voice-wrap',
|
|
66
64
|
initProps: _objectSpread({}, props)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import React, { useContext } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { View } from '@ray-js/ray';
|
|
4
4
|
import clsx from 'clsx';
|
|
5
5
|
import { VoiceIntercom as Component } from '../voiceIntercom';
|
|
6
6
|
import { useComponentHideState } from '../../ui/hooks';
|
|
@@ -21,7 +21,7 @@ export function VoiceIntercom(props) {
|
|
|
21
21
|
const {
|
|
22
22
|
event
|
|
23
23
|
} = useContext(UIEventContext);
|
|
24
|
-
return /*#__PURE__*/React.createElement(
|
|
24
|
+
return /*#__PURE__*/React.createElement(View, {
|
|
25
25
|
className: clsx('ipc-player-plugin-full-screen-voice', {
|
|
26
26
|
'ipc-player-plugin-full-screen-voice-hide': shouldHide || isPtzActive || fullResolutionActive
|
|
27
27
|
})
|
package/lib/plugins/ptz/ptz.js
CHANGED
|
@@ -17,10 +17,12 @@ export const Ptz = props => {
|
|
|
17
17
|
} = props;
|
|
18
18
|
const {
|
|
19
19
|
screenType,
|
|
20
|
-
isPtzActive
|
|
20
|
+
isPtzActive,
|
|
21
|
+
brandColor
|
|
21
22
|
} = useStore({
|
|
22
23
|
screenType: screenTypeAtom,
|
|
23
|
-
isPtzActive: ptzActive
|
|
24
|
+
isPtzActive: ptzActive,
|
|
25
|
+
brandColor: props.brandColor
|
|
24
26
|
});
|
|
25
27
|
if (screenType === 'vertical') {
|
|
26
28
|
return null;
|
|
@@ -33,9 +35,7 @@ export const Ptz = props => {
|
|
|
33
35
|
addContent('absolute', {
|
|
34
36
|
id: ptzControlId,
|
|
35
37
|
content: props => {
|
|
36
|
-
return /*#__PURE__*/React.createElement(
|
|
37
|
-
className: "ipc-player-plugin-full-screen-ptz-control"
|
|
38
|
-
}, /*#__PURE__*/React.createElement(PtzControl, props));
|
|
38
|
+
return /*#__PURE__*/React.createElement(PtzControl, props);
|
|
39
39
|
},
|
|
40
40
|
absoluteContentClassName: 'ipc-player-plugin-full-screen-ptz-control-warp',
|
|
41
41
|
initProps: _objectSpread({}, props)
|
|
@@ -46,6 +46,9 @@ export const Ptz = props => {
|
|
|
46
46
|
updateAtom(ptzActive, !isPtzActive);
|
|
47
47
|
}
|
|
48
48
|
}, /*#__PURE__*/React.createElement(Text, {
|
|
49
|
-
className: clsx('icon-panel', 'icon-panel-ptz', 'ipc-player-plugin-ptz-text-icon',
|
|
49
|
+
className: clsx('icon-panel', 'icon-panel-ptz', 'ipc-player-plugin-ptz-text-icon'),
|
|
50
|
+
style: _objectSpread({}, isPtzActive && {
|
|
51
|
+
color: brandColor
|
|
52
|
+
})
|
|
50
53
|
}));
|
|
51
54
|
};
|
package/lib/plugins/ptz/ptz.less
CHANGED
|
@@ -2,11 +2,6 @@
|
|
|
2
2
|
color: var(--iconColor);
|
|
3
3
|
font-size: calc(var(--iconPlayerSize) * var(--ipc-player-size-scale, 1)) !important;
|
|
4
4
|
}
|
|
5
|
-
|
|
6
|
-
.ipc-ptz-active {
|
|
7
|
-
color: var(--iconActiveColor);
|
|
8
|
-
}
|
|
9
|
-
|
|
10
5
|
// .ipc-player-plugin-full-screen-ptz {
|
|
11
6
|
// position: absolute;
|
|
12
7
|
// top: 60%;
|
|
@@ -35,7 +30,7 @@
|
|
|
35
30
|
}
|
|
36
31
|
|
|
37
32
|
.arrow-icon-wrapper {
|
|
38
|
-
font-size:
|
|
33
|
+
font-size: 25px;
|
|
39
34
|
color: #707070;
|
|
40
35
|
}
|
|
41
36
|
|
|
@@ -1,13 +1,43 @@
|
|
|
1
|
-
import React, { useContext } from 'react';
|
|
1
|
+
import React, { useContext, useEffect, useRef } from 'react';
|
|
2
2
|
import { CoverView } from '@ray-js/ray';
|
|
3
3
|
import clsx from 'clsx';
|
|
4
|
+
import _find from 'lodash/find';
|
|
5
|
+
import _get from 'lodash/get';
|
|
4
6
|
import IpcPtzZoom from '@ray-js/ipc-ptz-zoom';
|
|
7
|
+
import IpcUtils from '@ray-js/ray-ipc-utils';
|
|
5
8
|
import { useComponentHideState } from '../../ui/hooks';
|
|
6
9
|
import { UIEventContext } from '../../ui/context';
|
|
7
10
|
import { useStore } from '../../ctx/store';
|
|
11
|
+
import { getEnumRangeIsValid } from '../../utils/device';
|
|
8
12
|
import { startTimeToHideAllComponent, pauseTimeToHideAllComponent } from '../../ui/constant';
|
|
9
|
-
import './ptz.less';
|
|
13
|
+
import Styles from './ptz.less';
|
|
14
|
+
const getPtzData = devId => {
|
|
15
|
+
return [{
|
|
16
|
+
type: 'top',
|
|
17
|
+
show: getEnumRangeIsValid(devId, 'ptz_control', '0'),
|
|
18
|
+
dpValue: '0',
|
|
19
|
+
icon: 'ptz-arrow'
|
|
20
|
+
}, {
|
|
21
|
+
type: 'right',
|
|
22
|
+
show: getEnumRangeIsValid(devId, 'ptz_control', '2'),
|
|
23
|
+
dpValue: '2',
|
|
24
|
+
icon: 'ptz-arrow'
|
|
25
|
+
}, {
|
|
26
|
+
type: 'left',
|
|
27
|
+
show: getEnumRangeIsValid(devId, 'ptz_control', '6'),
|
|
28
|
+
dpValue: '6',
|
|
29
|
+
icon: 'ptz-arrow'
|
|
30
|
+
}, {
|
|
31
|
+
type: 'bottom',
|
|
32
|
+
show: getEnumRangeIsValid(devId, 'ptz_control', '4'),
|
|
33
|
+
dpValue: '4',
|
|
34
|
+
icon: 'ptz-arrow'
|
|
35
|
+
}];
|
|
36
|
+
};
|
|
10
37
|
export const PtzControl = props => {
|
|
38
|
+
const {
|
|
39
|
+
devId
|
|
40
|
+
} = props;
|
|
11
41
|
const {
|
|
12
42
|
screenType,
|
|
13
43
|
brandColor
|
|
@@ -19,6 +49,16 @@ export const PtzControl = props => {
|
|
|
19
49
|
const {
|
|
20
50
|
event
|
|
21
51
|
} = useContext(UIEventContext);
|
|
52
|
+
const ptzTimeId = useRef(null);
|
|
53
|
+
const ptzData = useRef(getPtzData(devId));
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
return () => {
|
|
56
|
+
if (ptzTimeId.current) {
|
|
57
|
+
clearInterval(ptzTimeId.current);
|
|
58
|
+
ptzTimeId.current = null;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
}, []);
|
|
22
62
|
return /*#__PURE__*/React.createElement(CoverView, {
|
|
23
63
|
className: clsx('ipc-player-plugin-full-screen-ptz-control', {
|
|
24
64
|
'ipc-player-plugin-full-screen-ptz-control-hide': shouldHide
|
|
@@ -26,38 +66,44 @@ export const PtzControl = props => {
|
|
|
26
66
|
}, /*#__PURE__*/React.createElement(IpcPtzZoom, {
|
|
27
67
|
ptzSize: "172px",
|
|
28
68
|
zoomData: [],
|
|
29
|
-
ptzData:
|
|
30
|
-
|
|
31
|
-
// show: getEnumRangeIsValid('ptz_control', '0'),
|
|
32
|
-
show: true,
|
|
33
|
-
dpValue: '0',
|
|
34
|
-
icon: 'ptz-arrow'
|
|
35
|
-
}, {
|
|
36
|
-
type: 'right',
|
|
37
|
-
// show: getEnumRangeIsValid('ptz_control', '2'),
|
|
38
|
-
show: true,
|
|
39
|
-
dpValue: '2',
|
|
40
|
-
icon: 'ptz-arrow'
|
|
41
|
-
}, {
|
|
42
|
-
type: 'left',
|
|
43
|
-
// show: getEnumRangeIsValid('ptz_control', '6'),
|
|
44
|
-
show: true,
|
|
45
|
-
dpValue: '6',
|
|
46
|
-
icon: 'ptz-arrow'
|
|
47
|
-
}, {
|
|
48
|
-
type: 'bottom',
|
|
49
|
-
// show: getEnumRangeIsValid('ptz_control', '4'),
|
|
50
|
-
show: true,
|
|
51
|
-
dpValue: '4',
|
|
52
|
-
icon: 'ptz-arrow'
|
|
53
|
-
}],
|
|
54
|
-
onTouchPtzStart: () => {
|
|
69
|
+
ptzData: ptzData.current,
|
|
70
|
+
onTouchPtzStart: async data => {
|
|
55
71
|
event.emit(pauseTimeToHideAllComponent);
|
|
72
|
+
const {
|
|
73
|
+
type
|
|
74
|
+
} = data;
|
|
75
|
+
const dpData = await IpcUtils.getDpIdByCode(devId, 'ptz_control');
|
|
76
|
+
if (dpData.code === 0) {
|
|
77
|
+
const ptzControlId = dpData.data;
|
|
78
|
+
const sndDpValue = _get(_find(ptzData.current, {
|
|
79
|
+
type
|
|
80
|
+
}), 'dpValue', null);
|
|
81
|
+
IpcUtils.publishDps(devId, {
|
|
82
|
+
[ptzControlId]: sndDpValue
|
|
83
|
+
});
|
|
84
|
+
ptzTimeId.current = setInterval(() => {
|
|
85
|
+
IpcUtils.publishDps(devId, {
|
|
86
|
+
[ptzControlId]: sndDpValue
|
|
87
|
+
});
|
|
88
|
+
}, 1000);
|
|
89
|
+
}
|
|
56
90
|
},
|
|
57
|
-
onTouchPtzEnd: () => {
|
|
91
|
+
onTouchPtzEnd: async () => {
|
|
92
|
+
const ptzStopData = await IpcUtils.getDpIdByCode(devId, 'ptz_stop');
|
|
93
|
+
if (ptzStopData.code === 0) {
|
|
94
|
+
const ptzStopId = ptzStopData.data;
|
|
95
|
+
IpcUtils.publishDps(devId, {
|
|
96
|
+
[ptzStopId]: true
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
if (ptzTimeId.current) {
|
|
100
|
+
clearInterval(ptzTimeId.current);
|
|
101
|
+
ptzTimeId.current = null;
|
|
102
|
+
}
|
|
58
103
|
event.emit(startTimeToHideAllComponent);
|
|
59
104
|
},
|
|
60
105
|
brandColor: brandColor,
|
|
61
|
-
iconClassName:
|
|
106
|
+
iconClassName: Styles['arrow-icon-wrapper'],
|
|
107
|
+
darkMode: true
|
|
62
108
|
}));
|
|
63
109
|
};
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import React, { useState, useEffect, useRef, useContext } from 'react';
|
|
2
|
-
import { View, Text } from '@ray-js/ray';
|
|
2
|
+
import { View, Text, Image } from '@ray-js/ray';
|
|
3
|
+
import { useSetState, useUpdateEffect } from 'ahooks';
|
|
3
4
|
import clsx from 'clsx';
|
|
5
|
+
import IpcUtils from '@ray-js/ray-ipc-utils';
|
|
6
|
+
import Strings from '../../i18n';
|
|
4
7
|
import { UIEventContext } from '../../ui/context';
|
|
5
|
-
import { startTimeToHideAllComponent, pauseTimeToHideAllComponent } from '../../ui/constant';
|
|
6
8
|
import { useStore, getDefaultStore } from '../../ctx/store';
|
|
7
9
|
import './recordVideo.less';
|
|
8
|
-
const
|
|
10
|
+
const CLOSE_TIME = 5000;
|
|
11
|
+
const RESET_TIMER = 3000;
|
|
12
|
+
const RECORD_VIDEO_SUCCESS_TOAST_ID = 'record_video_SUCCESS_toast_id';
|
|
13
|
+
const RECORD_VIDEO_TIMER_ID = 'record_video_timer_id';
|
|
9
14
|
function formatTimeDiff(diff) {
|
|
10
15
|
const padWithZero = true;
|
|
11
16
|
const diffMs = Math.abs(diff);
|
|
@@ -49,11 +54,18 @@ function useTime() {
|
|
|
49
54
|
};
|
|
50
55
|
}
|
|
51
56
|
function TimeRecord() {
|
|
57
|
+
// const { showTimer } = props;
|
|
52
58
|
const {
|
|
53
59
|
min,
|
|
54
60
|
sec,
|
|
55
61
|
cancel
|
|
56
62
|
} = useTime();
|
|
63
|
+
// useEffect(() => {
|
|
64
|
+
// console.log('____________', showTimer);
|
|
65
|
+
// if (!showTimer) {
|
|
66
|
+
// cancel();
|
|
67
|
+
// }
|
|
68
|
+
// }, [showTimer]);
|
|
57
69
|
return /*#__PURE__*/React.createElement(View, {
|
|
58
70
|
className: "ipc-player-plugin-record-video-toast-time"
|
|
59
71
|
}, /*#__PURE__*/React.createElement(View, {
|
|
@@ -73,44 +85,159 @@ export function RecordVideo(props) {
|
|
|
73
85
|
deleteContent,
|
|
74
86
|
recording: recordingAtom,
|
|
75
87
|
setRecording,
|
|
88
|
+
setRecordingDisabled,
|
|
89
|
+
devId,
|
|
76
90
|
className
|
|
77
91
|
} = props;
|
|
78
92
|
const {
|
|
79
|
-
recording
|
|
93
|
+
recording,
|
|
94
|
+
brandColor,
|
|
95
|
+
screenType,
|
|
96
|
+
recordingDisabled
|
|
80
97
|
} = useStore({
|
|
81
|
-
recording: recordingAtom
|
|
98
|
+
recording: recordingAtom,
|
|
99
|
+
brandColor: props.brandColor,
|
|
100
|
+
screenType: props.screenType,
|
|
101
|
+
recordingDisabled: props.recordingDisabled
|
|
102
|
+
});
|
|
103
|
+
const [state, setState] = useSetState({
|
|
104
|
+
showTimer: false,
|
|
105
|
+
showShot: false,
|
|
106
|
+
shotUrl: ''
|
|
82
107
|
});
|
|
108
|
+
|
|
109
|
+
/** 设置5秒后关闭录制成功弹窗 */
|
|
110
|
+
const timer = useRef();
|
|
111
|
+
const timeToCloseRecordToast = () => {
|
|
112
|
+
clearTimeout(timer.current);
|
|
113
|
+
// @ts-ignore
|
|
114
|
+
timer.current = setTimeout(() => {
|
|
115
|
+
setState({
|
|
116
|
+
showShot: false,
|
|
117
|
+
shotUrl: ''
|
|
118
|
+
});
|
|
119
|
+
deleteContent('absolute', RECORD_VIDEO_SUCCESS_TOAST_ID);
|
|
120
|
+
}, CLOSE_TIME);
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
/** 设置3秒后还原禁止结束录像状态 */
|
|
124
|
+
const recordDisabledTimer = useRef();
|
|
125
|
+
const timeToResetRecordDisabled = () => {
|
|
126
|
+
clearTimeout(recordDisabledTimer.current);
|
|
127
|
+
// @ts-ignore
|
|
128
|
+
recordDisabledTimer.current = setTimeout(() => {
|
|
129
|
+
setRecordingDisabled(false);
|
|
130
|
+
}, RESET_TIMER);
|
|
131
|
+
};
|
|
132
|
+
useUpdateEffect(() => {
|
|
133
|
+
if (state.showShot && screenType) {
|
|
134
|
+
showRecordToast();
|
|
135
|
+
}
|
|
136
|
+
}, [state.showShot, screenType]);
|
|
137
|
+
|
|
138
|
+
/** 根据showTimer的显示定时器 */
|
|
139
|
+
useUpdateEffect(() => {
|
|
140
|
+
if (state.showTimer) {
|
|
141
|
+
showRecordTimer();
|
|
142
|
+
} else {
|
|
143
|
+
deleteContent('absolute', RECORD_VIDEO_TIMER_ID);
|
|
144
|
+
// 清除定时器,元素移除
|
|
145
|
+
}
|
|
146
|
+
}, [state.showTimer]);
|
|
147
|
+
|
|
148
|
+
/** 跳转相册 */
|
|
149
|
+
const handCheck = () => {
|
|
150
|
+
IpcUtils.goToIpcPageNativeRoute('ipc_album_panel', devId);
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
/** 添加录制成功弹窗 */
|
|
154
|
+
const showRecordToast = () => {
|
|
155
|
+
deleteContent('absolute', RECORD_VIDEO_SUCCESS_TOAST_ID);
|
|
156
|
+
addContent('absolute', {
|
|
157
|
+
id: RECORD_VIDEO_SUCCESS_TOAST_ID,
|
|
158
|
+
absoluteContentClassName: 'ipc-player-plugin-record-success-toast-wrap',
|
|
159
|
+
absolutePosition: {
|
|
160
|
+
top: screenType === 'vertical' ? '12px' : '60px',
|
|
161
|
+
left: screenType === 'vertical' ? '16px' : '50%',
|
|
162
|
+
right: screenType === 'vertical' ? '16px' : 'unset',
|
|
163
|
+
display: 'flex',
|
|
164
|
+
width: screenType === 'vertical' ? 'auto' : '400px',
|
|
165
|
+
marginLeft: screenType === 'vertical' ? '0' : '-200px'
|
|
166
|
+
},
|
|
167
|
+
content: () => {
|
|
168
|
+
return /*#__PURE__*/React.createElement(View, {
|
|
169
|
+
className: "ipc-player-plugin-record-success-toast"
|
|
170
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
171
|
+
className: "ipc-player-plugin-record-success-toast-image-box"
|
|
172
|
+
}, /*#__PURE__*/React.createElement(Image, {
|
|
173
|
+
className: "ipc-player-plugin-record-success-toast-image",
|
|
174
|
+
src: state.shotUrl
|
|
175
|
+
})), /*#__PURE__*/React.createElement(View, {
|
|
176
|
+
className: "ipc-player-plugin-record-success-toast-title"
|
|
177
|
+
}, Strings.getLang('ipc_player_record_success_tip')), /*#__PURE__*/React.createElement(View, {
|
|
178
|
+
onClick: handCheck,
|
|
179
|
+
className: "ipc-player-plugin-record-success-toast-bottom",
|
|
180
|
+
style: {
|
|
181
|
+
color: brandColor,
|
|
182
|
+
borderColor: brandColor
|
|
183
|
+
}
|
|
184
|
+
}, Strings.getLang('ipc_player_record_success_check')));
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
timeToCloseRecordToast();
|
|
188
|
+
};
|
|
189
|
+
const showRecordTimer = () => {
|
|
190
|
+
deleteContent('absolute', RECORD_VIDEO_TIMER_ID);
|
|
191
|
+
addContent('absolute', {
|
|
192
|
+
id: RECORD_VIDEO_TIMER_ID,
|
|
193
|
+
absoluteContentClassName: 'ipc-player-plugin-record-video-toast-wrap',
|
|
194
|
+
content: () => /*#__PURE__*/React.createElement(View, {
|
|
195
|
+
className: clsx('ipc-player-plugin-record-video-toast', {
|
|
196
|
+
'ipc-player-plugin-record-video-toast-show': state.showTimer,
|
|
197
|
+
'ipc-player-plugin-record-video-toast-hide': !state.showTimer
|
|
198
|
+
})
|
|
199
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
200
|
+
className: "ipc-player-plugin-record-video-toast-point",
|
|
201
|
+
style: {
|
|
202
|
+
backgroundColor: brandColor
|
|
203
|
+
}
|
|
204
|
+
}), /*#__PURE__*/React.createElement(TimeRecord, null))
|
|
205
|
+
});
|
|
206
|
+
};
|
|
83
207
|
const handRecordVideo = async () => {
|
|
84
208
|
const store = getDefaultStore();
|
|
85
209
|
const _recording = store.get(recordingAtom);
|
|
86
210
|
const target = !_recording;
|
|
87
|
-
if (
|
|
88
|
-
|
|
89
|
-
} else {
|
|
90
|
-
event.emit(startTimeToHideAllComponent);
|
|
211
|
+
if (recordingDisabled) {
|
|
212
|
+
return false;
|
|
91
213
|
}
|
|
92
|
-
await setRecording(target);
|
|
214
|
+
const recordInfo = await setRecording(target);
|
|
93
215
|
if (target) {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
content: () => /*#__PURE__*/React.createElement(View, {
|
|
98
|
-
className: "ipc-player-plugin-record-video-toast"
|
|
99
|
-
}, /*#__PURE__*/React.createElement(View, {
|
|
100
|
-
className: "ipc-player-plugin-record-video-toast-point"
|
|
101
|
-
}), /*#__PURE__*/React.createElement(TimeRecord, null))
|
|
216
|
+
setRecordingDisabled(true);
|
|
217
|
+
setState({
|
|
218
|
+
showTimer: true
|
|
102
219
|
});
|
|
220
|
+
/** 录制开始后3秒后才可结束 */
|
|
221
|
+
timeToResetRecordDisabled();
|
|
103
222
|
} else {
|
|
104
|
-
|
|
223
|
+
setState({
|
|
224
|
+
showTimer: false,
|
|
225
|
+
showShot: true,
|
|
226
|
+
shotUrl: recordInfo.tempImagePath
|
|
227
|
+
});
|
|
105
228
|
}
|
|
229
|
+
return true;
|
|
106
230
|
};
|
|
107
231
|
return /*#__PURE__*/React.createElement(View, {
|
|
108
232
|
onClick: () => handRecordVideo(),
|
|
109
|
-
className: clsx(className, '')
|
|
233
|
+
className: clsx(className, ''),
|
|
234
|
+
style: {
|
|
235
|
+
opacity: recordingDisabled ? 0.5 : 1
|
|
236
|
+
}
|
|
110
237
|
}, /*#__PURE__*/React.createElement(Text, {
|
|
111
238
|
className: clsx('icon-panel', 'ipc-player-plugin-record-video-icon', recording ? 'icon-panel-record-stop' : 'icon-panel-record'),
|
|
112
239
|
style: {
|
|
113
|
-
color: recording ?
|
|
240
|
+
color: recording ? brandColor : undefined
|
|
114
241
|
}
|
|
115
242
|
}));
|
|
116
243
|
}
|