@ray-js/ipc-player-integration 0.0.24-beta-2 → 0.0.24-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.
|
@@ -1,18 +1,62 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { TouchEventHandler } from '@ray-js/components/lib/types';
|
|
3
3
|
import './voiceIntercom.less';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
import { PlayerStreamStatus, IntercomMode, PlayState } from '../../interface';
|
|
5
|
+
export declare const VoiceIntercom: React.ForwardRefExoticComponent<{
|
|
6
|
+
IPCPlayerContext: import("../../interface").IpcContext;
|
|
7
|
+
} & {
|
|
8
|
+
devId: string;
|
|
9
|
+
brandColor: import("../../interface").RetAtom<string>;
|
|
10
|
+
verticalMic: import("../../interface").RetAtom<boolean>;
|
|
11
|
+
saveToAlbum: 0 | 1;
|
|
12
|
+
showPtzControlTip: boolean;
|
|
13
|
+
screenType: import("../../interface").RetAtom<import("../../interface").ScreenType>;
|
|
14
|
+
recording: import("../../interface").RetAtom<boolean>;
|
|
15
|
+
recordingDisabled: import("../../interface").RetAtom<boolean>;
|
|
16
|
+
mute: import("../../interface").RetAtom<boolean>;
|
|
17
|
+
intercom: import("../../interface").RetAtom<boolean>;
|
|
18
|
+
intercomMode: import("../../interface").RetAtom<IntercomMode>;
|
|
19
|
+
intercomSupported: import("../../interface").RetAtom<boolean>;
|
|
20
|
+
resolution: import("../../interface").RetAtom<string>;
|
|
21
|
+
resolutionList: import("../../interface").RetAtom<string[]>;
|
|
22
|
+
playState: import("../../interface").RetAtom<PlayState>;
|
|
23
|
+
IPCPlayerInstance: import("../../interface").IpcContext;
|
|
24
|
+
topLeftContent: import("../../interface").RetAtom<import("../../interface").ComponentConfig<any & Record<string, any>>[]>;
|
|
25
|
+
topRightContent: import("../../interface").RetAtom<import("../../interface").ComponentConfig<any & Record<string, any>>[]>;
|
|
26
|
+
bottomLeftContent: import("../../interface").RetAtom<import("../../interface").ComponentConfig<any & Record<string, any>>[]>;
|
|
27
|
+
bottomRightContent: import("../../interface").RetAtom<import("../../interface").ComponentConfig<any & Record<string, any>>[]>;
|
|
28
|
+
absoluteContent: import("../../interface").RetAtom<import("../../interface").ComponentConfig<any & Record<string, any>>[]>;
|
|
29
|
+
setShowPtzControlTip: (value: boolean) => void;
|
|
30
|
+
setBrandColor: (color: string) => void;
|
|
31
|
+
setVerticalMic: (value: boolean) => void;
|
|
32
|
+
setScreenType: (type: import("../../interface").ScreenType) => void;
|
|
33
|
+
setRecordingDisabled: (type: boolean) => void;
|
|
34
|
+
setResolution: (type: string) => void;
|
|
35
|
+
setResolutionList: (type: string[]) => void;
|
|
36
|
+
setRecording: (value: boolean, onlyUpdateAtom?: boolean | undefined) => Promise<import("../../interface").RecordInfoData>;
|
|
37
|
+
setIntercom: (value: boolean, onlyUpdateAtom?: boolean | undefined) => Promise<boolean>;
|
|
38
|
+
setMute: (value: boolean) => Promise<boolean>;
|
|
39
|
+
changeStreamStatus: (value: PlayerStreamStatus) => void;
|
|
40
|
+
getStreamStatus: () => PlayerStreamStatus;
|
|
41
|
+
setPlayState: (value: PlayState) => void;
|
|
42
|
+
addContent: <T>(type: import("../../interface").ContentPlaceType, config: import("../../interface").ComponentConfig<T> | import("../../interface").ComponentConfig<T>[], position?: number | undefined) => void;
|
|
43
|
+
deleteContent: (type: import("../../interface").ContentPlaceType, id: string) => void;
|
|
44
|
+
getContent: () => import("../../interface").ComponentConfig<any & Record<string, any>>[];
|
|
45
|
+
updateContent: (type: import("../../interface").ContentPlaceType, data: import("../../interface").ComponentConfig<any & Record<string, any>>[]) => void;
|
|
46
|
+
hasContent: (type: import("../../interface").ContentPlaceType, id: string) => boolean;
|
|
47
|
+
hideContent: (type: import("../../interface").ContentPlaceType, id: string) => void;
|
|
48
|
+
showContent: (type: import("../../interface").ContentPlaceType, id: string) => void;
|
|
49
|
+
toast: import("../../ports.output").Toast;
|
|
50
|
+
event: import("../../interface").EventInstance;
|
|
51
|
+
} & {
|
|
52
|
+
style?: React.CSSProperties | undefined;
|
|
53
|
+
intercomClassName?: string | undefined;
|
|
54
|
+
iconClassName?: string | undefined;
|
|
55
|
+
widthScale?: number | undefined;
|
|
56
|
+
heightScale?: number | undefined;
|
|
11
57
|
onTouchStart?: TouchEventHandler['onTouchStart'];
|
|
12
58
|
onTouchEnd?: TouchEventHandler['onTouchEnd'];
|
|
13
|
-
talkingColor?: string;
|
|
14
|
-
mode?:
|
|
15
|
-
disabled?: boolean;
|
|
16
|
-
}
|
|
17
|
-
export declare const VoiceIntercom: (props: Props) => React.JSX.Element;
|
|
18
|
-
export {};
|
|
59
|
+
talkingColor?: string | undefined;
|
|
60
|
+
mode?: "circle" | "verticalSmall" | "fullSmall" | undefined;
|
|
61
|
+
disabled?: boolean | undefined;
|
|
62
|
+
} & React.RefAttributes<unknown>>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
-
import React, { useRef, useContext, useState, useEffect } from 'react';
|
|
2
|
+
import React, { useRef, useContext, useState, useEffect, forwardRef, useImperativeHandle } from 'react';
|
|
3
3
|
import { View, getSystemInfoSync } from '@ray-js/ray';
|
|
4
4
|
import clsx from 'clsx';
|
|
5
5
|
import Svg from '@ray-js/svg';
|
|
@@ -10,7 +10,7 @@ import { UIEventContext } from '../../ui/context';
|
|
|
10
10
|
import { radialGradient } from '../../utils';
|
|
11
11
|
import { startTimeToHideAllComponent, pauseTimeToHideAllComponent, changeIgnoreHideStopPreview } from '../../ui/constant';
|
|
12
12
|
const NILL = () => null;
|
|
13
|
-
export const VoiceIntercom = props => {
|
|
13
|
+
export const VoiceIntercom = /*#__PURE__*/forwardRef((props, ref) => {
|
|
14
14
|
const {
|
|
15
15
|
style,
|
|
16
16
|
intercomClassName,
|
|
@@ -102,6 +102,38 @@ export const VoiceIntercom = props => {
|
|
|
102
102
|
await setIntercom(false);
|
|
103
103
|
event.emit(startTimeToHideAllComponent);
|
|
104
104
|
};
|
|
105
|
+
const handTouchStart = async e => {
|
|
106
|
+
if (disabled) return;
|
|
107
|
+
onTouchStart(e);
|
|
108
|
+
getDefaultStore();
|
|
109
|
+
if (loading.current) return;
|
|
110
|
+
loading.current = true;
|
|
111
|
+
// const _intercom = store.get(intercomAtom);
|
|
112
|
+
// const _recording = store.get(recordingAtom);
|
|
113
|
+
const target = !intercom;
|
|
114
|
+
if (target && recording) {
|
|
115
|
+
console.log('录制中,无法对讲');
|
|
116
|
+
loading.current = false;
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
try {
|
|
120
|
+
if (target) {
|
|
121
|
+
await startVoice(mute);
|
|
122
|
+
} else {
|
|
123
|
+
await endVoice();
|
|
124
|
+
}
|
|
125
|
+
} catch (err) {
|
|
126
|
+
loading.current = false;
|
|
127
|
+
} finally {
|
|
128
|
+
loading.current = false;
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
// 暴露给父组件的接口
|
|
133
|
+
useImperativeHandle(ref, () => ({
|
|
134
|
+
triggerIntercom: e => handTouchStart(e)
|
|
135
|
+
}));
|
|
136
|
+
|
|
105
137
|
// 获取 requestAnimationFrame 和兼容性回退
|
|
106
138
|
const requestFrame = callback => {
|
|
107
139
|
if (typeof requestAnimationFrame !== 'undefined') {
|
|
@@ -154,32 +186,7 @@ export const VoiceIntercom = props => {
|
|
|
154
186
|
'ipc-player-plugin-voice-intercom': mode === 'circle',
|
|
155
187
|
'ipc-player-plugin-voice-small-intercom': mode !== 'circle'
|
|
156
188
|
}, intercomClassName),
|
|
157
|
-
onTouchStart:
|
|
158
|
-
if (disabled) return;
|
|
159
|
-
onTouchStart(e);
|
|
160
|
-
getDefaultStore();
|
|
161
|
-
if (loading.current) return;
|
|
162
|
-
loading.current = true;
|
|
163
|
-
// const _intercom = store.get(intercomAtom);
|
|
164
|
-
// const _recording = store.get(recordingAtom);
|
|
165
|
-
const target = !intercom;
|
|
166
|
-
if (target && recording) {
|
|
167
|
-
console.log('录制中,无法对讲');
|
|
168
|
-
loading.current = false;
|
|
169
|
-
return;
|
|
170
|
-
}
|
|
171
|
-
try {
|
|
172
|
-
if (target) {
|
|
173
|
-
await startVoice(mute);
|
|
174
|
-
} else {
|
|
175
|
-
await endVoice();
|
|
176
|
-
}
|
|
177
|
-
} catch (err) {
|
|
178
|
-
loading.current = false;
|
|
179
|
-
} finally {
|
|
180
|
-
loading.current = false;
|
|
181
|
-
}
|
|
182
|
-
},
|
|
189
|
+
onTouchStart: handTouchStart,
|
|
183
190
|
onTouchEnd: onTouchEnd
|
|
184
191
|
}, intercom ? /*#__PURE__*/React.createElement(View, {
|
|
185
192
|
className: clsx({
|
|
@@ -202,4 +209,4 @@ export const VoiceIntercom = props => {
|
|
|
202
209
|
})))) : /*#__PURE__*/React.createElement(View, {
|
|
203
210
|
className: clsx('icon-panel', 'icon-panel-one-way-intercom', mode === 'circle' && 'intercom-default-size', mode !== 'circle' && 'ipc-player-plugin-voice-small-intercom', iconClassName)
|
|
204
211
|
}));
|
|
205
|
-
};
|
|
212
|
+
});
|