@ray-js/ipc-player-integration 0.0.1-beta-8 → 0.0.1-beta-10
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 +4 -1
- package/lib/ctx/ctx.js +28 -0
- package/lib/plugins/index.d.ts +1 -0
- package/lib/plugins/index.js +2 -1
- package/lib/plugins/resolution/index.d.ts +1 -0
- package/lib/plugins/resolution/index.js +1 -0
- package/lib/plugins/resolution/resolution.d.ts +4 -0
- package/lib/plugins/resolution/resolution.js +42 -0
- package/lib/plugins/resolution/resolution.less +15 -0
- package/lib/plugins/voiceIntercom/voiceIntercom.js +5 -4
- package/lib/ui/ui.js +33 -10
- 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 { createUseCtx } from './ctx';
|
|
5
|
-
import { Battery, Screenshot, TempHumidity, RecordVideo, FullScreen, VideoBitKbps, Muted } from '../plugins';
|
|
5
|
+
import { Battery, Screenshot, TempHumidity, RecordVideo, FullScreen, VideoBitKbps, Muted, Resolution } from '../plugins';
|
|
6
6
|
import { authorizeStatus } from '../utils/authorize';
|
|
7
7
|
const createPlayContext = ty.createIpcPlayerContext;
|
|
8
8
|
// const createPlayContext = () => null;
|
|
@@ -27,6 +27,9 @@ const bottomContent = [{
|
|
|
27
27
|
}, {
|
|
28
28
|
id: 'Muted',
|
|
29
29
|
content: Muted
|
|
30
|
+
}, {
|
|
31
|
+
id: 'Resolution',
|
|
32
|
+
content: Resolution
|
|
30
33
|
}, {
|
|
31
34
|
id: 'FullScreen',
|
|
32
35
|
content: FullScreen
|
package/lib/ctx/ctx.js
CHANGED
|
@@ -28,6 +28,9 @@ export const createUseCtx = _ref => {
|
|
|
28
28
|
// 静音
|
|
29
29
|
const mute = useAtom(false);
|
|
30
30
|
|
|
31
|
+
// 清晰度
|
|
32
|
+
const resolution = useAtom('HD');
|
|
33
|
+
|
|
31
34
|
// 对讲中
|
|
32
35
|
const intercom = useAtom(false);
|
|
33
36
|
const playState = useAtom(PlayState.CONNECTING);
|
|
@@ -41,12 +44,19 @@ export const createUseCtx = _ref => {
|
|
|
41
44
|
if (!IPCPlayerInstance.current) {
|
|
42
45
|
IPCPlayerInstance.current = createPlayContext(devId);
|
|
43
46
|
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* 设置清晰度
|
|
50
|
+
*
|
|
51
|
+
*/
|
|
52
|
+
|
|
44
53
|
return {
|
|
45
54
|
devId,
|
|
46
55
|
saveToAlbum,
|
|
47
56
|
screenType,
|
|
48
57
|
recording,
|
|
49
58
|
mute,
|
|
59
|
+
resolution,
|
|
50
60
|
intercom,
|
|
51
61
|
playState,
|
|
52
62
|
setPlayState,
|
|
@@ -104,6 +114,24 @@ export const createUseCtx = _ref => {
|
|
|
104
114
|
});
|
|
105
115
|
});
|
|
106
116
|
},
|
|
117
|
+
setResolution: async target => {
|
|
118
|
+
console.log('执行清晰度方法');
|
|
119
|
+
return new Promise((resolve, reject) => {
|
|
120
|
+
IPCPlayerInstance.current.setClarity({
|
|
121
|
+
clarity: target,
|
|
122
|
+
success: () => {
|
|
123
|
+
console.log('setClarity success');
|
|
124
|
+
updateAtom(resolution, target === 'hd' ? 'HD' : 'SD');
|
|
125
|
+
resolve(true);
|
|
126
|
+
},
|
|
127
|
+
fail: err => {
|
|
128
|
+
console.log('setClarity err');
|
|
129
|
+
// updateAtom(mute, !target);
|
|
130
|
+
reject(err);
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
},
|
|
107
135
|
setRecording: async target => {
|
|
108
136
|
const store = getDefaultStore();
|
|
109
137
|
const _recording = store.get(recording);
|
package/lib/plugins/index.d.ts
CHANGED
package/lib/plugins/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './resolution';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './resolution';
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { View, Text } from '@ray-js/ray';
|
|
2
|
+
import React, { useEffect } from 'react';
|
|
3
|
+
import { useStore } from '../../ctx/store';
|
|
4
|
+
import './resolution.less';
|
|
5
|
+
export const Resolution = props => {
|
|
6
|
+
console.log(props, 'props');
|
|
7
|
+
const {
|
|
8
|
+
IPCPlayerContext,
|
|
9
|
+
resolution,
|
|
10
|
+
setResolution
|
|
11
|
+
} = props;
|
|
12
|
+
const {
|
|
13
|
+
currentResolution
|
|
14
|
+
} = useStore({
|
|
15
|
+
currentResolution: resolution
|
|
16
|
+
});
|
|
17
|
+
// const setIsMuted = (value: typeof currentResolution) => {
|
|
18
|
+
// // updateAtom(mute, value);
|
|
19
|
+
// };
|
|
20
|
+
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
// init();
|
|
23
|
+
}, []);
|
|
24
|
+
return /*#__PURE__*/React.createElement(View, {
|
|
25
|
+
onClick: () => {
|
|
26
|
+
console.log('_____');
|
|
27
|
+
setResolution(currentResolution === 'HD' ? 'normal' : 'hd');
|
|
28
|
+
// // IPCPlayerContext.setMuted({
|
|
29
|
+
// // mute: !isMuted,
|
|
30
|
+
// // success: res => {
|
|
31
|
+
// // setIsMuted(!isMuted);
|
|
32
|
+
// // },
|
|
33
|
+
// // fail: res => {
|
|
34
|
+
// // console.log('res===setMuted err', res);
|
|
35
|
+
// // },
|
|
36
|
+
// // });
|
|
37
|
+
},
|
|
38
|
+
className: "resolutionWrapper"
|
|
39
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
40
|
+
className: "resolutionText"
|
|
41
|
+
}, currentResolution));
|
|
42
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
.resolutionWrapper {
|
|
2
|
+
background-color: rgba(255,255,255,0.2);
|
|
3
|
+
padding: 2px 4px;
|
|
4
|
+
display: flex;
|
|
5
|
+
justify-content: center;
|
|
6
|
+
align-items: center;
|
|
7
|
+
border-radius: 8rpx;
|
|
8
|
+
backdrop-filter: blur(8rpx);
|
|
9
|
+
.resolutionText {
|
|
10
|
+
color: #ffffff;
|
|
11
|
+
font-weight: 600;
|
|
12
|
+
font-size: 24rpx;
|
|
13
|
+
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -47,10 +47,12 @@ export function VoiceIntercom(_ref) {
|
|
|
47
47
|
await setMute(false);
|
|
48
48
|
}
|
|
49
49
|
await setIntercom(true);
|
|
50
|
+
event.emit(pauseTimeToHideAllComponent);
|
|
50
51
|
};
|
|
51
52
|
const endVoice = async () => {
|
|
52
53
|
await setMute(originMuteStatusBeforeVoice.current);
|
|
53
54
|
await setIntercom(false);
|
|
55
|
+
event.emit(startTimeToHideAllComponent);
|
|
54
56
|
};
|
|
55
57
|
return /*#__PURE__*/React.createElement(View, {
|
|
56
58
|
style: _objectSpread({}, style),
|
|
@@ -62,16 +64,15 @@ export function VoiceIntercom(_ref) {
|
|
|
62
64
|
loading.current = true;
|
|
63
65
|
const _intercom = store.get(intercomAtom);
|
|
64
66
|
const _recording = store.get(recordingAtom);
|
|
65
|
-
|
|
67
|
+
const target = !_intercom;
|
|
68
|
+
if (target && _recording) {
|
|
66
69
|
console.log('录制中,无法对讲');
|
|
67
70
|
loading.current = false;
|
|
68
71
|
return;
|
|
69
72
|
}
|
|
70
|
-
if (
|
|
71
|
-
event.emit(pauseTimeToHideAllComponent);
|
|
73
|
+
if (target) {
|
|
72
74
|
await startVoice(mute);
|
|
73
75
|
} else {
|
|
74
|
-
event.emit(startTimeToHideAllComponent);
|
|
75
76
|
await endVoice();
|
|
76
77
|
}
|
|
77
78
|
loading.current = false;
|
package/lib/ui/ui.js
CHANGED
|
@@ -139,8 +139,7 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
139
139
|
eventRef.current.off(pauseTimeToHideAllComponent, listenPause);
|
|
140
140
|
};
|
|
141
141
|
});
|
|
142
|
-
|
|
143
|
-
const playerReady = true;
|
|
142
|
+
const playerReady = playState === PlayState.PLAYING;
|
|
144
143
|
return /*#__PURE__*/React.createElement(UIEventContext.Provider, {
|
|
145
144
|
value: {
|
|
146
145
|
event: eventRef.current
|
|
@@ -176,17 +175,41 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
176
175
|
// onCtx={getIpcPlayer}
|
|
177
176
|
// onPlayerTap={handlePlayerClick}
|
|
178
177
|
,
|
|
179
|
-
onZoomChange:
|
|
180
|
-
console.log(
|
|
178
|
+
onZoomChange: data => {
|
|
179
|
+
console.log(`zoomChange事件: ${JSON.stringify(data)}`);
|
|
180
|
+
ty.showToast({
|
|
181
|
+
title: `zoomChange事件: ${JSON.stringify(data)}`
|
|
182
|
+
});
|
|
183
|
+
setTimeout(() => {
|
|
184
|
+
ty.hideToast();
|
|
185
|
+
}, 3000);
|
|
181
186
|
},
|
|
182
|
-
onSessionDidDisconnected:
|
|
183
|
-
console.log(
|
|
187
|
+
onSessionDidDisconnected: data => {
|
|
188
|
+
console.log(`sessionDidDisconnected事件: ${JSON.stringify(data)}`);
|
|
189
|
+
ty.showToast({
|
|
190
|
+
title: `sessionDidDisconnected事件: ${JSON.stringify(data)}`
|
|
191
|
+
});
|
|
192
|
+
setTimeout(() => {
|
|
193
|
+
ty.hideToast();
|
|
194
|
+
}, 3000);
|
|
184
195
|
},
|
|
185
|
-
onCameraPreviewFailure:
|
|
186
|
-
console.log(
|
|
196
|
+
onCameraPreviewFailure: data => {
|
|
197
|
+
console.log(`onCameraPreviewFailure事件: ${JSON.stringify(data)}`);
|
|
198
|
+
ty.showToast({
|
|
199
|
+
title: `onCameraPreviewFailure事件: ${JSON.stringify(data)}`
|
|
200
|
+
});
|
|
201
|
+
setTimeout(() => {
|
|
202
|
+
ty.hideToast();
|
|
203
|
+
}, 3000);
|
|
187
204
|
},
|
|
188
|
-
onCameraNotifyWeakNetwork:
|
|
189
|
-
console.log(
|
|
205
|
+
onCameraNotifyWeakNetwork: data => {
|
|
206
|
+
console.log(`onCameraNotifyWeakNetwork: ${JSON.stringify(data)}`);
|
|
207
|
+
ty.showToast({
|
|
208
|
+
title: `onCameraNotifyWeakNetwork: ${JSON.stringify(data)}`
|
|
209
|
+
});
|
|
210
|
+
setTimeout(() => {
|
|
211
|
+
ty.hideToast();
|
|
212
|
+
}, 3000);
|
|
190
213
|
},
|
|
191
214
|
clarity: "hd",
|
|
192
215
|
privateState: false,
|