Skip to content

Commit e601b46

Browse files
fix: trasmitting audio and video stream
1 parent 25a3e35 commit e601b46

File tree

2 files changed

+44
-14
lines changed

2 files changed

+44
-14
lines changed

client/packages/lowcoder/src/comps/comps/meetingComp/videoMeetingControllerComp.tsx

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -308,15 +308,40 @@ let MTComp = (function () {
308308
[dispatch, isTopBom]
309309
);
310310
const [userIds, setUserIds] = useState<any>([]);
311+
const [updateVolume, setUpdateVolume] = useState<any>({
312+
update: false,
313+
userid: null,
314+
});
311315
const [rtmMessages, setRtmMessages] = useState<any>([]);
312316

313317
useEffect(() => {
314-
console.log(userIds);
315318
dispatch(
316319
changeChildAction("participants", getData(userIds).data, false)
317320
);
318321
}, [userIds]);
319322

323+
useEffect(() => {
324+
if (updateVolume.userid) {
325+
console.log("userIds ", props.participants);
326+
let prevUsers: [] = props.participants as [];
327+
328+
const updatedItems = prevUsers.map((userInfo: any) => {
329+
if (
330+
userInfo.user === updateVolume.userid &&
331+
userInfo.speaking != updateVolume.update
332+
) {
333+
return { ...userInfo, speaking: updateVolume.update };
334+
}
335+
return userInfo;
336+
});
337+
console.log("updatedItems", updatedItems);
338+
339+
dispatch(
340+
changeChildAction("participants", getData(updatedItems).data, false)
341+
);
342+
}
343+
}, [updateVolume]);
344+
320345
useEffect(() => {
321346
if (props.endCall.value) {
322347
let newUsers = userIds.filter((item: any) => item.user !== userId);
@@ -397,16 +422,16 @@ let MTComp = (function () {
397422
if (volumeInfos.length == 0) return;
398423
volumeInfos.map((volumeInfo: any) => {
399424
const speaking = volumeInfo.level >= 30;
400-
if (volumeInfo.uid == userId) {
425+
if (
426+
volumeInfo.uid == userId &&
427+
props.localUser.value.speaking != speaking
428+
) {
401429
props.localUser.onChange({
402430
...props.localUser.value,
403431
speaking,
404432
});
405433
} else {
406-
const userInfo = userIds.find(
407-
(info: any) => info.user === volumeInfo.uid
408-
);
409-
setUserIds([...userIds, { ...userInfo, speaking }]);
434+
setUpdateVolume({ update: speaking, userid: volumeInfo.uid });
410435
}
411436
});
412437
});
@@ -582,6 +607,12 @@ MTComp = withMethodExposing(MTComp, [
582607
} else {
583608
await turnOnCamera(value);
584609
}
610+
comp.children.localUser.change({
611+
user: userId + "",
612+
streamingVideo: value,
613+
audiostatus: false,
614+
speaking: false,
615+
});
585616
comp.children.videoControl.change(value);
586617
},
587618
},

client/packages/lowcoder/src/comps/comps/meetingComp/videoMeetingStreamComp.tsx

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -187,18 +187,17 @@ let VideoCompBuilder = (function (props) {
187187
useEffect(() => {
188188
if (props.userId.value !== "") {
189189
let userData = JSON.parse(props.userId?.value);
190-
if (
191-
userData.user == userId &&
192-
userData.streamingVideo == false &&
193-
videoRef.current &&
194-
videoRef.current?.id == userId + ""
195-
) {
196-
videoRef.current.srcObject = null;
190+
if (userData.user == userId && userData.streamingVideo == false && videoRef.current && videoRef.current?.id == userId + "") {
191+
if (videoRef.current && videoRef.current?.id == userId + "") {
192+
videoRef.current.srcObject = null;
193+
}
197194
}
198195
client.on(
199196
"user-published",
200197
async (user: IAgoraRTCRemoteUser, mediaType: "video" | "audio") => {
201198
if (mediaType === "video") {
199+
console.log("user-published",user.uid);
200+
202201
const remoteTrack = await client.subscribe(user, mediaType);
203202
let userId = user.uid + "";
204203
if (
@@ -242,7 +241,7 @@ let VideoCompBuilder = (function (props) {
242241
}
243242
}
244243
if (mediaType === "video") {
245-
console.log("user-unpublished video");
244+
console.log("user-unpublished video", user.uid);
246245
if (videoRef.current && videoRef.current?.id == user.uid + "") {
247246
videoRef.current.srcObject = null;
248247
}

0 commit comments

Comments
 (0)