@ray-js/ipc-player-integration 0.0.1-beta-13 → 0.0.1-beta-15
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.composition.js +15 -9
- package/lib/ctx/ctx.js +56 -41
- package/lib/ctx/ports.output.d.ts +3 -1
- package/lib/ctx/store.d.ts +3 -2
- package/lib/ctx/store.js +1 -1
- package/lib/i18n/index.d.ts +22 -0
- package/lib/i18n/index.js +7 -0
- package/lib/i18n/strings.d.ts +13 -0
- package/lib/i18n/strings.js +12 -0
- package/lib/interface.d.ts +9 -2
- package/lib/interface.js +1 -0
- package/lib/plugins/battery/battery.composition.d.ts +7 -0
- package/lib/plugins/recordVideo/recordVideo.less +3 -1
- package/lib/plugins/resolution/fullResolutionControl.js +36 -7
- package/lib/plugins/resolution/resolution.js +13 -23
- package/lib/plugins/resolution/resolution.less +2 -0
- package/lib/plugins/voiceIntercom/voiceIntercom.d.ts +1 -1
- package/lib/plugins/voiceIntercom/voiceIntercom.js +32 -12
- package/lib/ports.output.d.ts +1 -0
- package/lib/ports.output.js +7 -1
- package/lib/ui/ui.d.ts +2 -0
- package/lib/ui/ui.js +5 -4
- package/package.json +1 -1
|
@@ -2,7 +2,7 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
3
|
const _excluded = ["title", "duration"];
|
|
4
4
|
import IPCUtils from '@ray-js/ray-ipc-utils';
|
|
5
|
-
import { MuteMode } from '@ray-js/ray-ipc-utils/lib/interface';
|
|
5
|
+
import { IntercomMode, MuteMode, ClarityType } from '@ray-js/ray-ipc-utils/lib/interface';
|
|
6
6
|
import { createUseCtx } from './ctx';
|
|
7
7
|
import { Battery, Screenshot, TempHumidity, RecordVideo, FullScreen, VideoBitKbps, Muted, Resolution, Ptz } from '../plugins';
|
|
8
8
|
import { authorizeStatus } from '../utils/authorize';
|
|
@@ -52,21 +52,27 @@ const toast = _ref => {
|
|
|
52
52
|
}, config));
|
|
53
53
|
};
|
|
54
54
|
const getMemoryState = devId => {
|
|
55
|
+
const defaultValue = {
|
|
56
|
+
mute: true,
|
|
57
|
+
intercomMode: IntercomMode.TwoWay,
|
|
58
|
+
resolution: ClarityType.HD,
|
|
59
|
+
resolutionList: [ClarityType.HD, ClarityType.SD]
|
|
60
|
+
};
|
|
55
61
|
return new Promise(resolve => {
|
|
56
62
|
IPCUtils.getCameraConfigInfo(devId).then(res => {
|
|
57
63
|
if (res.code === -1) {
|
|
58
|
-
return resolve(
|
|
59
|
-
mute: true
|
|
60
|
-
});
|
|
64
|
+
return resolve(defaultValue);
|
|
61
65
|
}
|
|
62
|
-
|
|
66
|
+
console.log(res, '========');
|
|
67
|
+
const muteValue = res.data.microphoneSettings.cachedMuteMode === MuteMode.OFF;
|
|
63
68
|
return resolve({
|
|
64
|
-
mute:
|
|
69
|
+
mute: muteValue,
|
|
70
|
+
intercomMode: res.data.intercomInfo.cachedIntercomMode,
|
|
71
|
+
resolution: res.data.videoResolution.cachedResolution,
|
|
72
|
+
resolutionList: res.data.videoResolution.availableResolutions
|
|
65
73
|
});
|
|
66
74
|
}).catch(() => {
|
|
67
|
-
resolve(
|
|
68
|
-
mute: true
|
|
69
|
-
});
|
|
75
|
+
resolve(defaultValue);
|
|
70
76
|
});
|
|
71
77
|
});
|
|
72
78
|
};
|
package/lib/ctx/ctx.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useRef, useCallback, useEffect } from 'react';
|
|
2
2
|
import { useAtom, updateAtom, getDefaultStore, useStore } from './store';
|
|
3
|
-
import { PlayState } from '../interface';
|
|
3
|
+
import { PlayState, IntercomMode } from '../interface';
|
|
4
|
+
import { ClarityType } from '@ray-js/ray-ipc-utils/lib/interface';
|
|
4
5
|
const SAVE_TO_ALBUM = 1;
|
|
5
6
|
export const createUseCtx = _ref => {
|
|
6
7
|
let {
|
|
@@ -23,29 +24,40 @@ export const createUseCtx = _ref => {
|
|
|
23
24
|
} = _ref2;
|
|
24
25
|
const streamStatus = useRef();
|
|
25
26
|
// 全屏、竖屏
|
|
26
|
-
const screenType = useAtom('vertical');
|
|
27
|
+
const [screenType, setScreenType] = useAtom('vertical');
|
|
28
|
+
|
|
27
29
|
// 录像中
|
|
28
|
-
const recording = useAtom(false);
|
|
30
|
+
const [recording] = useAtom(false);
|
|
29
31
|
|
|
30
32
|
// 静音 true 代表静音 false 代表不静音
|
|
31
|
-
const mute = useAtom(false);
|
|
33
|
+
const [mute] = useAtom(false);
|
|
32
34
|
|
|
33
|
-
//
|
|
34
|
-
const
|
|
35
|
+
// 品牌色 默认
|
|
36
|
+
const [brandColor, setBrandColor] = useAtom('#FF592A');
|
|
35
37
|
|
|
36
38
|
// ptz 是否点击
|
|
37
|
-
const ptzActive = useAtom(false);
|
|
39
|
+
const [ptzActive, setPtzActive] = useAtom(false);
|
|
40
|
+
|
|
41
|
+
// resolution 当前清晰度
|
|
42
|
+
const [resolution] = useAtom('HD');
|
|
43
|
+
// resolution 清晰度列表
|
|
44
|
+
const [resolutionList, setResolutionList] = useAtom([]);
|
|
45
|
+
|
|
46
|
+
// 单向对讲还是双向对讲
|
|
47
|
+
const [intercomMode, setIntercomMode] = useAtom(IntercomMode.TwoWay);
|
|
48
|
+
|
|
38
49
|
// 全屏清晰度UI切换是否展示
|
|
39
|
-
const fullResolutionActive = useAtom(false);
|
|
50
|
+
const [fullResolutionActive, setFullResolutionActive] = useAtom(false);
|
|
51
|
+
|
|
40
52
|
// 对讲中
|
|
41
|
-
const intercom = useAtom(false);
|
|
42
|
-
const playState = useAtom(PlayState.CONNECTING);
|
|
53
|
+
const [intercom] = useAtom(false);
|
|
54
|
+
const [playState] = useAtom(PlayState.CONNECTING);
|
|
43
55
|
const setPlayState = useCallback(value => {
|
|
44
56
|
updateAtom(playState, value);
|
|
45
57
|
}, [playState]);
|
|
46
|
-
const topContent = useAtom(initTopContent || defaultTopContent || []);
|
|
47
|
-
const bottomContent = useAtom(initBottomContent || defaultBottomContent || []);
|
|
48
|
-
const absoluteContent = useAtom(initAbsoluteContent || defaultAbsoluteContent || []);
|
|
58
|
+
const [topContent] = useAtom(initTopContent || defaultTopContent || []);
|
|
59
|
+
const [bottomContent] = useAtom(initBottomContent || defaultBottomContent || []);
|
|
60
|
+
const [absoluteContent] = useAtom(initAbsoluteContent || defaultAbsoluteContent || []);
|
|
49
61
|
const {
|
|
50
62
|
_playState
|
|
51
63
|
} = useStore({
|
|
@@ -55,7 +67,11 @@ export const createUseCtx = _ref => {
|
|
|
55
67
|
if (devId && _playState === PlayState.PLAYING) {
|
|
56
68
|
// 获取缓存的值且同步
|
|
57
69
|
getMemoryState(devId).then(res => {
|
|
70
|
+
console.log('==== getMemoryState ====', res);
|
|
58
71
|
_setMute(res.mute);
|
|
72
|
+
setIntercomMode(res.intercomMode);
|
|
73
|
+
_setResolution(res.resolution, 'res.resolution');
|
|
74
|
+
setResolutionList(res.resolutionList);
|
|
59
75
|
});
|
|
60
76
|
}
|
|
61
77
|
}, [devId, _playState]);
|
|
@@ -95,19 +111,40 @@ export const createUseCtx = _ref => {
|
|
|
95
111
|
* 设置清晰度
|
|
96
112
|
*
|
|
97
113
|
*/
|
|
98
|
-
|
|
114
|
+
const _setResolution = async target => {
|
|
115
|
+
// target 为需要切换的清晰度
|
|
116
|
+
return new Promise((resolve, reject) => {
|
|
117
|
+
IPCPlayerInstance.current.setClarity({
|
|
118
|
+
clarity: target === ClarityType.HD ? 'hd' : 'normal',
|
|
119
|
+
success: () => {
|
|
120
|
+
console.log('setClarity success', target);
|
|
121
|
+
updateAtom(resolution, target);
|
|
122
|
+
resolve(true);
|
|
123
|
+
},
|
|
124
|
+
fail: err => {
|
|
125
|
+
console.log(err, 'setClarity err');
|
|
126
|
+
// updateAtom(mute, !target);
|
|
127
|
+
reject(err);
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
};
|
|
99
132
|
return {
|
|
100
133
|
devId,
|
|
134
|
+
brandColor,
|
|
101
135
|
saveToAlbum,
|
|
102
136
|
screenType,
|
|
103
137
|
recording,
|
|
104
138
|
mute,
|
|
105
139
|
resolution,
|
|
140
|
+
resolutionList,
|
|
106
141
|
ptzActive,
|
|
107
142
|
fullResolutionActive,
|
|
108
143
|
intercom,
|
|
144
|
+
intercomMode,
|
|
109
145
|
playState,
|
|
110
146
|
setPlayState,
|
|
147
|
+
setBrandColor,
|
|
111
148
|
setIntercom: async target => {
|
|
112
149
|
const store = getDefaultStore();
|
|
113
150
|
const _intercom = store.get(intercom);
|
|
@@ -147,24 +184,8 @@ export const createUseCtx = _ref => {
|
|
|
147
184
|
});
|
|
148
185
|
},
|
|
149
186
|
setMute: _setMute,
|
|
150
|
-
setResolution:
|
|
151
|
-
|
|
152
|
-
return new Promise((resolve, reject) => {
|
|
153
|
-
IPCPlayerInstance.current.setClarity({
|
|
154
|
-
clarity: target,
|
|
155
|
-
success: () => {
|
|
156
|
-
console.log('setClarity success');
|
|
157
|
-
updateAtom(resolution, target === 'hd' ? 'HD' : 'SD');
|
|
158
|
-
resolve(true);
|
|
159
|
-
},
|
|
160
|
-
fail: err => {
|
|
161
|
-
console.log('setClarity err');
|
|
162
|
-
// updateAtom(mute, !target);
|
|
163
|
-
reject(err);
|
|
164
|
-
}
|
|
165
|
-
});
|
|
166
|
-
});
|
|
167
|
-
},
|
|
187
|
+
setResolution: _setResolution,
|
|
188
|
+
setResolutionList,
|
|
168
189
|
setRecording: async target => {
|
|
169
190
|
const store = getDefaultStore();
|
|
170
191
|
const _recording = store.get(recording);
|
|
@@ -204,15 +225,9 @@ export const createUseCtx = _ref => {
|
|
|
204
225
|
}
|
|
205
226
|
});
|
|
206
227
|
},
|
|
207
|
-
setPtzActive
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
setFullResolutionActive: value => {
|
|
211
|
-
updateAtom(fullResolutionActive, value);
|
|
212
|
-
},
|
|
213
|
-
setScreenType: value => {
|
|
214
|
-
updateAtom(screenType, value);
|
|
215
|
-
},
|
|
228
|
+
setPtzActive,
|
|
229
|
+
setFullResolutionActive,
|
|
230
|
+
setScreenType,
|
|
216
231
|
topContent,
|
|
217
232
|
bottomContent,
|
|
218
233
|
absoluteContent,
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import { IntercomMode } from '../ports.output';
|
|
2
|
+
export type { Toast, IntercomMode } from '../ports.output';
|
|
2
3
|
export type createPlayContext = (devId: string) => IpcContext;
|
|
3
4
|
export type AuthorizeStatus = (type: string) => Promise<boolean>;
|
|
4
5
|
export type GetMemoryState = (devId: string) => Promise<{
|
|
5
6
|
mute: boolean;
|
|
7
|
+
intercomMode: IntercomMode;
|
|
6
8
|
}>;
|
|
7
9
|
export type SetMuteMemoryState = (devId: string, value: boolean) => void;
|
package/lib/ctx/store.d.ts
CHANGED
|
@@ -3,9 +3,10 @@ export { getDefaultStore } from 'jotai';
|
|
|
3
3
|
export declare const topContent: import("jotai").PrimitiveAtom<never[]> & {
|
|
4
4
|
init: never[];
|
|
5
5
|
};
|
|
6
|
-
|
|
6
|
+
type Action<T> = T | ((prevValue: T) => T);
|
|
7
|
+
export declare const useAtom: <T extends unknown>(defaultValue: T) => [RetAtom<T>, (value: Action<T>) => void];
|
|
7
8
|
type ExtractReturnType<T> = {
|
|
8
9
|
[K in keyof T]: T[K] extends RetAtom<infer R> ? R : never;
|
|
9
10
|
};
|
|
10
11
|
export declare const useStore: <V, T extends Record<string, RetAtom<V>>>(options: T) => ExtractReturnType<T>;
|
|
11
|
-
export declare const updateAtom: <T>(atom: RetAtom<T>, value: T
|
|
12
|
+
export declare const updateAtom: <T>(atom: RetAtom<T>, value: Action<T>) => void;
|
package/lib/ctx/store.js
CHANGED
|
@@ -8,7 +8,7 @@ export const useAtom = defaultValue => {
|
|
|
8
8
|
// @ts-ignore
|
|
9
9
|
ref.current = atom(defaultValue);
|
|
10
10
|
}
|
|
11
|
-
return ref.current;
|
|
11
|
+
return [ref.current, value => updateAtom(ref.current, value)];
|
|
12
12
|
};
|
|
13
13
|
export const useStore = options => {
|
|
14
14
|
const combinedAtomRef = useRef();
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { kit } from '@ray-js/panel-sdk';
|
|
2
|
+
declare const Strings: kit.I18N<{
|
|
3
|
+
en: {
|
|
4
|
+
ipc_player_resolution_HD: string;
|
|
5
|
+
ipc_player_resolution_SD: string;
|
|
6
|
+
ipc_player_current_resolution_is_equal: string;
|
|
7
|
+
};
|
|
8
|
+
zh: {
|
|
9
|
+
ipc_player_resolution_HD: string;
|
|
10
|
+
ipc_player_resolution_SD: string;
|
|
11
|
+
ipc_player_current_resolution_is_equal: string;
|
|
12
|
+
};
|
|
13
|
+
}, {
|
|
14
|
+
ipc_player_resolution_HD: string;
|
|
15
|
+
ipc_player_resolution_SD: string;
|
|
16
|
+
ipc_player_current_resolution_is_equal: string;
|
|
17
|
+
} | {
|
|
18
|
+
ipc_player_resolution_HD: string;
|
|
19
|
+
ipc_player_resolution_SD: string;
|
|
20
|
+
ipc_player_current_resolution_is_equal: string;
|
|
21
|
+
}>;
|
|
22
|
+
export default Strings;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
en: {
|
|
3
|
+
ipc_player_resolution_HD: string;
|
|
4
|
+
ipc_player_resolution_SD: string;
|
|
5
|
+
ipc_player_current_resolution_is_equal: string;
|
|
6
|
+
};
|
|
7
|
+
zh: {
|
|
8
|
+
ipc_player_resolution_HD: string;
|
|
9
|
+
ipc_player_resolution_SD: string;
|
|
10
|
+
ipc_player_current_resolution_is_equal: string;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export default _default;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
en: {
|
|
3
|
+
ipc_player_resolution_HD: 'HD',
|
|
4
|
+
ipc_player_resolution_SD: 'SD',
|
|
5
|
+
ipc_player_current_resolution_is_equal: 'Already at current clarity'
|
|
6
|
+
},
|
|
7
|
+
zh: {
|
|
8
|
+
ipc_player_resolution_HD: '高清',
|
|
9
|
+
ipc_player_resolution_SD: '标清',
|
|
10
|
+
ipc_player_current_resolution_is_equal: '已是当前清晰度'
|
|
11
|
+
}
|
|
12
|
+
};
|
package/lib/interface.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { PrimitiveAtom } from 'jotai';
|
|
3
|
-
import type { Toast } from './ports.output';
|
|
3
|
+
import type { Toast, IntercomMode } from './ports.output';
|
|
4
|
+
export { IntercomMode } from './ports.output';
|
|
4
5
|
type WithInitialValue<Value> = {
|
|
5
6
|
init: Value;
|
|
6
7
|
};
|
|
@@ -31,20 +32,27 @@ export type UseCtx = (options: {
|
|
|
31
32
|
saveToAlbum?: 0 | 1;
|
|
32
33
|
}) => {
|
|
33
34
|
devId: string;
|
|
35
|
+
brandColor: string;
|
|
34
36
|
saveToAlbum: 0 | 1;
|
|
35
37
|
screenType: RetAtom<ScreenType>;
|
|
36
38
|
recording: RetAtom<boolean>;
|
|
37
39
|
mute: RetAtom<boolean>;
|
|
38
40
|
intercom: RetAtom<boolean>;
|
|
41
|
+
intercomMode: RetAtom<IntercomMode>;
|
|
39
42
|
ptzActive: RetAtom<boolean>;
|
|
43
|
+
resolution: RetAtom<string>;
|
|
44
|
+
resolutionList: RetAtom<string[]>;
|
|
40
45
|
fullResolutionActive: RetAtom<boolean>;
|
|
41
46
|
playState: RetAtom<PlayState>;
|
|
42
47
|
IPCPlayerInstance: IpcContext;
|
|
43
48
|
topContent: RetAtom<ComponentConfig[]>;
|
|
44
49
|
bottomContent: RetAtom<ComponentConfig[]>;
|
|
45
50
|
absoluteContent: RetAtom<ComponentConfig[]>;
|
|
51
|
+
setBrandColor: (color: string) => void;
|
|
46
52
|
setScreenType: (type: ScreenType) => void;
|
|
47
53
|
setPtzActive: (type: boolean) => void;
|
|
54
|
+
setResolution: (type: string) => void;
|
|
55
|
+
setResolutionList: (type: string[]) => void;
|
|
48
56
|
setFullResolutionActive: (type: boolean) => void;
|
|
49
57
|
setRecording: (value: boolean) => Promise<boolean>;
|
|
50
58
|
setIntercom: (value: boolean) => Promise<boolean>;
|
|
@@ -70,4 +78,3 @@ export type PlayStatusData = {
|
|
|
70
78
|
playState: PlayState;
|
|
71
79
|
playCode: number;
|
|
72
80
|
};
|
|
73
|
-
export {};
|
package/lib/interface.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { IntercomMode } from './ports.output';
|
|
1
2
|
export let PlayerStreamStatus = /*#__PURE__*/function (PlayerStreamStatus) {
|
|
2
3
|
PlayerStreamStatus[PlayerStreamStatus["UnknownException"] = -1000] = "UnknownException";
|
|
3
4
|
PlayerStreamStatus[PlayerStreamStatus["ConnectSuccess"] = 1001] = "ConnectSuccess";
|
|
@@ -3,20 +3,27 @@ export declare const Battery: import("react").FunctionComponent<{
|
|
|
3
3
|
IPCPlayerContext: IpcContext;
|
|
4
4
|
} & {
|
|
5
5
|
devId: string;
|
|
6
|
+
brandColor: string;
|
|
6
7
|
saveToAlbum: 0 | 1;
|
|
7
8
|
screenType: import("../..").RetAtom<import("../..").ScreenType>;
|
|
8
9
|
recording: import("../..").RetAtom<boolean>;
|
|
9
10
|
mute: import("../..").RetAtom<boolean>;
|
|
10
11
|
intercom: import("../..").RetAtom<boolean>;
|
|
12
|
+
intercomMode: import("../..").RetAtom<import("@ray-js/ray-ipc-utils/lib/interface").IntercomMode>;
|
|
11
13
|
ptzActive: import("../..").RetAtom<boolean>;
|
|
14
|
+
resolution: import("../..").RetAtom<string>;
|
|
15
|
+
resolutionList: import("../..").RetAtom<string[]>;
|
|
12
16
|
fullResolutionActive: import("../..").RetAtom<boolean>;
|
|
13
17
|
playState: import("../..").RetAtom<import("../..").PlayState>;
|
|
14
18
|
IPCPlayerInstance: IpcContext;
|
|
15
19
|
topContent: import("../..").RetAtom<import("../..").ComponentConfig<any & Record<string, any>>[]>;
|
|
16
20
|
bottomContent: import("../..").RetAtom<import("../..").ComponentConfig<any & Record<string, any>>[]>;
|
|
17
21
|
absoluteContent: import("../..").RetAtom<import("../..").ComponentConfig<any & Record<string, any>>[]>;
|
|
22
|
+
setBrandColor: (color: string) => void;
|
|
18
23
|
setScreenType: (type: import("../..").ScreenType) => void;
|
|
19
24
|
setPtzActive: (type: boolean) => void;
|
|
25
|
+
setResolution: (type: string) => void;
|
|
26
|
+
setResolutionList: (type: string[]) => void;
|
|
20
27
|
setFullResolutionActive: (type: boolean) => void;
|
|
21
28
|
setRecording: (value: boolean) => Promise<boolean>;
|
|
22
29
|
setIntercom: (value: boolean) => Promise<boolean>;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
color: var(--iconColor);
|
|
4
4
|
}
|
|
5
5
|
.ipc-player-plugin-record-video-toast-wrap {
|
|
6
|
-
z-index:
|
|
6
|
+
z-index: 110;
|
|
7
7
|
position: absolute;
|
|
8
8
|
top: calc(7px * var(--ipc-player-size-scale, 1));
|
|
9
9
|
left: 50%;
|
|
@@ -15,6 +15,8 @@
|
|
|
15
15
|
align-items: center;
|
|
16
16
|
background-color: var(--bg-color);
|
|
17
17
|
border-radius: calc(8px * var(--ipc-player-size-scale, 1));
|
|
18
|
+
// background-color: #fff;
|
|
19
|
+
background: linear-gradient(0deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.15)), #000000;
|
|
18
20
|
.ipc-player-plugin-record-video-toast-point {
|
|
19
21
|
width: calc(6px * var(--ipc-player-size-scale, 1));
|
|
20
22
|
height: calc(6px * var(--ipc-player-size-scale, 1));
|
|
@@ -2,30 +2,59 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
2
2
|
import React, { useContext } from 'react';
|
|
3
3
|
import { Text, View } from '@ray-js/ray';
|
|
4
4
|
import clsx from 'clsx';
|
|
5
|
+
import Strings from '../../i18n';
|
|
5
6
|
import { useComponentHideState } from '../../ui/hooks';
|
|
6
7
|
import { UIEventContext } from '../../ui/context';
|
|
7
8
|
import { useStore } from '../../ctx/store';
|
|
8
9
|
import { startTimeToHideAllComponent, pauseTimeToHideAllComponent } from '../../ui/constant';
|
|
9
10
|
import './resolution.less';
|
|
10
11
|
export const FullResolutionControl = props => {
|
|
12
|
+
const {
|
|
13
|
+
setResolution,
|
|
14
|
+
setFullResolutionActive
|
|
15
|
+
} = props;
|
|
11
16
|
const {
|
|
12
17
|
screenType,
|
|
13
|
-
fullResolutionActive
|
|
18
|
+
fullResolutionActive,
|
|
19
|
+
resolution,
|
|
20
|
+
resolutionList,
|
|
21
|
+
brandColor
|
|
14
22
|
} = useStore({
|
|
15
23
|
screenType: props.screenType,
|
|
16
|
-
fullResolutionActive: props.fullResolutionActive
|
|
24
|
+
fullResolutionActive: props.fullResolutionActive,
|
|
25
|
+
resolutionList: props.resolutionList,
|
|
26
|
+
brandColor: props.brandColor,
|
|
27
|
+
resolution: props.resolution
|
|
17
28
|
});
|
|
29
|
+
console.log(resolutionList, 'resolutionList');
|
|
18
30
|
const [shouldHide] = useComponentHideState(screenType);
|
|
19
31
|
const {
|
|
20
32
|
event
|
|
21
33
|
} = useContext(UIEventContext);
|
|
34
|
+
const changeResolution = value => {
|
|
35
|
+
if (value === resolution) {
|
|
36
|
+
ty.showToast({
|
|
37
|
+
icon: 'none',
|
|
38
|
+
title: Strings.getLang('ipc_player_current_resolution_is_equal')
|
|
39
|
+
});
|
|
40
|
+
} else {
|
|
41
|
+
setResolution(value);
|
|
42
|
+
setFullResolutionActive(false);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
console.log(brandColor, 'brandColor');
|
|
46
|
+
console.log(resolution, 'resolution');
|
|
47
|
+
console.log(resolutionList, 'resolutionList');
|
|
22
48
|
return /*#__PURE__*/React.createElement(View, _extends({
|
|
23
49
|
className: clsx('ipc-player-plugin-full-resolution-control', {
|
|
24
50
|
'ipc-player-plugin-full-resolution-control-hide': shouldHide || !fullResolutionActive
|
|
25
51
|
})
|
|
26
|
-
}, props), /*#__PURE__*/React.createElement(Text, {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
className: clsx('ipc-player-plugin-full-resolution-control-text')
|
|
30
|
-
|
|
52
|
+
}, props), resolutionList.map(item => /*#__PURE__*/React.createElement(Text, {
|
|
53
|
+
onClick: () => changeResolution(item),
|
|
54
|
+
key: item,
|
|
55
|
+
className: clsx('ipc-player-plugin-full-resolution-control-text'),
|
|
56
|
+
style: item === resolution && {
|
|
57
|
+
color: brandColor
|
|
58
|
+
}
|
|
59
|
+
}, Strings.getLang(`ipc_player_resolution_${item}`))));
|
|
31
60
|
};
|
|
@@ -1,41 +1,31 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
2
|
import { View, Text } from '@ray-js/ray';
|
|
3
3
|
import clsx from 'clsx';
|
|
4
|
-
import React, { useContext
|
|
4
|
+
import React, { useContext } from 'react';
|
|
5
|
+
import Strings from '../../i18n';
|
|
5
6
|
import { FullResolutionControl } from './fullResolutionControl';
|
|
6
7
|
import { fullResolutionId, pauseTimeToHideAllComponent } from '../../ui/constant';
|
|
7
8
|
import { UIEventContext } from '../../ui/context';
|
|
8
|
-
import { useStore
|
|
9
|
+
import { useStore } from '../../ctx/store';
|
|
9
10
|
import './resolution.less';
|
|
10
11
|
export const Resolution = props => {
|
|
11
12
|
const {
|
|
12
13
|
IPCPlayerContext,
|
|
13
|
-
resolution,
|
|
14
14
|
setResolution,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
addContent
|
|
15
|
+
addContent,
|
|
16
|
+
setFullResolutionActive
|
|
18
17
|
} = props;
|
|
19
18
|
const {
|
|
20
|
-
|
|
21
|
-
screenType
|
|
22
|
-
isFullResolutionActive
|
|
19
|
+
resolution,
|
|
20
|
+
screenType
|
|
23
21
|
} = useStore({
|
|
24
|
-
|
|
25
|
-
screenType:
|
|
26
|
-
|
|
22
|
+
resolution: props.resolution,
|
|
23
|
+
screenType: props.screenType,
|
|
24
|
+
fullResolutionActive: props.fullResolutionActive
|
|
27
25
|
});
|
|
28
26
|
const {
|
|
29
27
|
event
|
|
30
28
|
} = useContext(UIEventContext);
|
|
31
|
-
console.log(screenType, 'screenType');
|
|
32
|
-
// const setIsMuted = (value: typeof currentResolution) => {
|
|
33
|
-
// // updateAtom(mute, value);
|
|
34
|
-
// };
|
|
35
|
-
|
|
36
|
-
useEffect(() => {
|
|
37
|
-
// init();
|
|
38
|
-
}, []);
|
|
39
29
|
return /*#__PURE__*/React.createElement(View, {
|
|
40
30
|
onClick: () => {
|
|
41
31
|
if (screenType === 'full') {
|
|
@@ -48,15 +38,15 @@ export const Resolution = props => {
|
|
|
48
38
|
absoluteContentClassName: 'ipc-player-plugin-full-resolution-control-wrap',
|
|
49
39
|
initProps: _objectSpread({}, props)
|
|
50
40
|
});
|
|
51
|
-
|
|
41
|
+
setFullResolutionActive(true);
|
|
52
42
|
event.emit(pauseTimeToHideAllComponent);
|
|
53
43
|
return false;
|
|
54
44
|
}
|
|
55
|
-
setResolution(
|
|
45
|
+
setResolution(resolution === 'HD' ? 'SD' : 'HD');
|
|
56
46
|
return true;
|
|
57
47
|
},
|
|
58
48
|
className: clsx('ipc-player-plugin-resolution', screenType === 'vertical' ? 'ipc-player-plugin-resolution-vertical' : 'ipc-player-plugin-resolution-full')
|
|
59
49
|
}, /*#__PURE__*/React.createElement(Text, {
|
|
60
50
|
className: "resolutionText"
|
|
61
|
-
},
|
|
51
|
+
}, Strings.getLang(`ipc_player_resolution_${resolution}`)));
|
|
62
52
|
};
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
display: flex;
|
|
39
39
|
justify-content: center;
|
|
40
40
|
align-items: center;
|
|
41
|
+
background-color: transparent;
|
|
41
42
|
// transform: translate(200%, 0);
|
|
42
43
|
z-index: 3;
|
|
43
44
|
}
|
|
@@ -48,4 +49,5 @@
|
|
|
48
49
|
text-align: center;
|
|
49
50
|
color: #ffffff;
|
|
50
51
|
min-height: 40px;
|
|
52
|
+
width: 100%;
|
|
51
53
|
}
|
|
@@ -9,5 +9,5 @@ type Props = ComponentConfigProps & {
|
|
|
9
9
|
onTouchStart?: TouchEventHandler['onTouchStart'];
|
|
10
10
|
onTouchEnd?: TouchEventHandler['onTouchEnd'];
|
|
11
11
|
};
|
|
12
|
-
export declare function VoiceIntercom({ style, className, iconClassName, recording: recordingAtom, intercom: intercomAtom, setIntercom, mute: muteAtom, setMute, getStreamStatus, onTouchStart, onTouchEnd, }: Props): React.JSX.Element;
|
|
12
|
+
export declare function VoiceIntercom({ style, className, iconClassName, recording: recordingAtom, intercom: intercomAtom, intercomMode: intercomModeAtom, setIntercom, mute: muteAtom, setMute, getStreamStatus, onTouchStart, onTouchEnd, }: Props): React.JSX.Element;
|
|
13
13
|
export {};
|
|
@@ -5,7 +5,7 @@ import clsx from 'clsx';
|
|
|
5
5
|
import Res from './voice.gif';
|
|
6
6
|
import { useStore, getDefaultStore } from '../../ctx/store';
|
|
7
7
|
import './voiceIntercom.less';
|
|
8
|
-
import { PlayerStreamStatus } from '../../interface';
|
|
8
|
+
import { PlayerStreamStatus, IntercomMode } from '../../interface';
|
|
9
9
|
import { UIEventContext } from '../../ui/context';
|
|
10
10
|
import { startTimeToHideAllComponent, pauseTimeToHideAllComponent } from '../../ui/constant';
|
|
11
11
|
const NILL = () => null;
|
|
@@ -16,6 +16,7 @@ export function VoiceIntercom(_ref) {
|
|
|
16
16
|
iconClassName,
|
|
17
17
|
recording: recordingAtom,
|
|
18
18
|
intercom: intercomAtom,
|
|
19
|
+
intercomMode: intercomModeAtom,
|
|
19
20
|
setIntercom,
|
|
20
21
|
mute: muteAtom,
|
|
21
22
|
setMute,
|
|
@@ -28,10 +29,12 @@ export function VoiceIntercom(_ref) {
|
|
|
28
29
|
} = useContext(UIEventContext);
|
|
29
30
|
const {
|
|
30
31
|
mute,
|
|
31
|
-
intercom
|
|
32
|
+
intercom,
|
|
33
|
+
intercomMode
|
|
32
34
|
} = useStore({
|
|
33
35
|
mute: muteAtom,
|
|
34
|
-
intercom: intercomAtom
|
|
36
|
+
intercom: intercomAtom,
|
|
37
|
+
intercomMode: intercomModeAtom
|
|
35
38
|
});
|
|
36
39
|
// 对讲开始之前的静音状态
|
|
37
40
|
const originMuteStatusBeforeVoice = useRef(mute);
|
|
@@ -41,16 +44,28 @@ export function VoiceIntercom(_ref) {
|
|
|
41
44
|
console.log('PlayerStreamStatus not 1002');
|
|
42
45
|
return;
|
|
43
46
|
}
|
|
47
|
+
console.log('==== 开始对讲 =====');
|
|
44
48
|
originMuteStatusBeforeVoice.current = _mute;
|
|
45
|
-
//
|
|
46
|
-
|
|
47
|
-
|
|
49
|
+
// 单路对讲,开始对讲前需要静音
|
|
50
|
+
// 双路对讲,开始对讲前需要打开拾音器
|
|
51
|
+
const muteTarget = intercomMode === IntercomMode.OneWay;
|
|
52
|
+
if (_mute !== muteTarget) {
|
|
53
|
+
console.log(`=== 切换静音状态: ${_mute}`, `${intercomMode}`);
|
|
54
|
+
await setMute(muteTarget);
|
|
48
55
|
}
|
|
49
56
|
await setIntercom(true);
|
|
50
57
|
event.emit(pauseTimeToHideAllComponent);
|
|
51
58
|
};
|
|
52
59
|
const endVoice = async () => {
|
|
53
|
-
|
|
60
|
+
console.log('=== 结束对讲 ====');
|
|
61
|
+
// 单向对讲,结束对讲之后,强制关闭静态状态
|
|
62
|
+
if (intercomMode === IntercomMode.OneWay) {
|
|
63
|
+
console.log('=== 单向对讲,强制关闭静音状态 ===');
|
|
64
|
+
await setMute(false);
|
|
65
|
+
} else {
|
|
66
|
+
console.log(`=== 双向对讲,恢复对讲之前的静音状态 ${originMuteStatusBeforeVoice.current}===`);
|
|
67
|
+
await setMute(originMuteStatusBeforeVoice.current);
|
|
68
|
+
}
|
|
54
69
|
await setIntercom(false);
|
|
55
70
|
event.emit(startTimeToHideAllComponent);
|
|
56
71
|
};
|
|
@@ -70,12 +85,17 @@ export function VoiceIntercom(_ref) {
|
|
|
70
85
|
loading.current = false;
|
|
71
86
|
return;
|
|
72
87
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
88
|
+
try {
|
|
89
|
+
if (target) {
|
|
90
|
+
await startVoice(mute);
|
|
91
|
+
} else {
|
|
92
|
+
await endVoice();
|
|
93
|
+
}
|
|
94
|
+
} catch (err) {
|
|
95
|
+
loading.current = false;
|
|
96
|
+
} finally {
|
|
97
|
+
loading.current = false;
|
|
77
98
|
}
|
|
78
|
-
loading.current = false;
|
|
79
99
|
},
|
|
80
100
|
onTouchEnd: onTouchEnd
|
|
81
101
|
}, intercom ? /*#__PURE__*/React.createElement(Image, {
|
package/lib/ports.output.d.ts
CHANGED
package/lib/ports.output.js
CHANGED
package/lib/ui/ui.d.ts
CHANGED
|
@@ -16,6 +16,8 @@ type Props = {
|
|
|
16
16
|
className?: string;
|
|
17
17
|
onPlayStatus?: (data: PlayStatusData) => void;
|
|
18
18
|
style?: React.CSSProperties;
|
|
19
|
+
privateState?: boolean;
|
|
20
|
+
deviceOnline?: boolean;
|
|
19
21
|
CSSVariable?: Partial<CSSVariable>;
|
|
20
22
|
};
|
|
21
23
|
export declare const IPCPlayerIntegration: React.MemoExoticComponent<(props: Props) => React.JSX.Element>;
|
package/lib/ui/ui.js
CHANGED
|
@@ -38,10 +38,11 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
38
38
|
className,
|
|
39
39
|
devId,
|
|
40
40
|
style,
|
|
41
|
-
CSSVariable = defaultCSSVariable
|
|
41
|
+
CSSVariable = defaultCSSVariable,
|
|
42
|
+
privateState = false,
|
|
43
|
+
deviceOnline = true
|
|
42
44
|
} = props;
|
|
43
45
|
const instance = getCtxInstance(props.instance, devId);
|
|
44
|
-
console.log(instance, 'instance');
|
|
45
46
|
const {
|
|
46
47
|
setPlayState,
|
|
47
48
|
setScreenType,
|
|
@@ -184,7 +185,7 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
184
185
|
objectFit: "",
|
|
185
186
|
defaultMute: true,
|
|
186
187
|
devId: devId,
|
|
187
|
-
onlineStatus:
|
|
188
|
+
onlineStatus: deviceOnline,
|
|
188
189
|
ipcPlayerContext: instance.IPCPlayerInstance,
|
|
189
190
|
onChangeStreamStatus: code => {
|
|
190
191
|
var _props$onPlayStatus;
|
|
@@ -234,7 +235,7 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
234
235
|
}, 3000);
|
|
235
236
|
},
|
|
236
237
|
clarity: "hd",
|
|
237
|
-
privateState:
|
|
238
|
+
privateState: privateState,
|
|
238
239
|
onPlayerTap: handPlayerTap // 对应原来的onVideoTap
|
|
239
240
|
}), playerReady && /*#__PURE__*/React.createElement(TopContent, {
|
|
240
241
|
ctx: instance
|