Skip to content

Commit d131b71

Browse files
Feat: video toggle event
1 parent a02fd07 commit d131b71

File tree

4 files changed

+47
-17
lines changed

4 files changed

+47
-17
lines changed

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

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ import AgoraRTC, {
5252

5353
import { JSONValue } from "@lowcoder-ee/index.sdk";
5454
import { getData } from "../listViewComp/listViewUtils";
55-
import { meetingStreamChildren } from "./videoMeetingStreamComp";
5655

5756
const EventOptions = [closeEvent] as const;
5857

@@ -151,22 +150,15 @@ const shareScreen = async (sharing: boolean) => {
151150
};
152151
const leaveChannel = async () => {
153152
if (videoTrack) {
154-
await turnOnCamera(false);
155153
await client.unpublish(videoTrack);
156-
videoTrack.stop();
154+
await turnOnCamera(false);
157155
}
158156

159157
if (audioTrack) {
160158
await turnOnMicrophone(false);
161-
await client.unpublish(audioTrack);
162-
audioTrack.stop();
163159
}
164-
165160
await client.leave();
166-
window.location.reload(); //FixMe: this reloads the page when user leaves
167-
isJoined = false;
168161
};
169-
let isJoined = false;
170162

171163
const hostChanged = (users: any) => {};
172164

@@ -236,6 +228,17 @@ let MTComp = (function () {
236228
);
237229
}, [userIds]);
238230

231+
useEffect(() => {
232+
if (props.endCall.value) {
233+
let newUsers = userIds.filter((item: any) => item.user !== userId);
234+
console.log("newUsers", newUsers, userId);
235+
236+
dispatch(
237+
changeChildAction("participants", getData(newUsers).data, false)
238+
);
239+
}
240+
}, [props.endCall.value]);
241+
239242
useEffect(() => {
240243
client.on("user-joined", (user: IAgoraRTCRemoteUser) => {
241244
let userData = { user: user.uid, host: false };
@@ -401,8 +404,6 @@ MTComp = withMethodExposing(MTComp, [
401404
},
402405
execute: async (comp, values) => {
403406
let value = !comp.children.audioControl.getView().value;
404-
console.log("turnOnMicrophone", value);
405-
// await audioTrack.setEnabled(value);
406407
await turnOnMicrophone(value);
407408
comp.children.audioControl.change(value);
408409
},
@@ -413,9 +414,14 @@ MTComp = withMethodExposing(MTComp, [
413414
description: trans("meeting.actionBtnDesc"),
414415
params: [],
415416
},
416-
execute: (comp, values) => {
417+
execute: async (comp, values) => {
417418
let value = !comp.children.videoControl.getView().value;
418-
turnOnCamera(value);
419+
if (videoTrack) {
420+
videoTrack.setEnabled(value);
421+
} else {
422+
await turnOnCamera(value);
423+
}
424+
419425
comp.children.videoControl.change(value);
420426
},
421427
},
@@ -445,9 +451,8 @@ MTComp = withMethodExposing(MTComp, [
445451
},
446452
execute: async (comp, values) => {
447453
let value = !comp.children.endCall.getView().value;
448-
449-
await leaveChannel();
450454
comp.children.endCall.change(value);
455+
await leaveChannel();
451456
},
452457
},
453458
{

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

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ import { RefControl } from "comps/controls/refControl";
2828
import { useEffect, useRef } from "react";
2929

3030
import { AutoHeightControl } from "comps/controls/autoHeightControl";
31-
import { client } from "./videoMeetingControllerComp";
31+
import {
32+
client,
33+
meetingControllerChildren,
34+
} from "./videoMeetingControllerComp";
3235

3336
import { IAgoraRTCRemoteUser } from "agora-rtc-sdk-ng";
3437

@@ -193,6 +196,13 @@ let VideoCompBuilder = (function (props) {
193196
if (mediaType === "video") {
194197
const remoteTrack = await client.subscribe(user, mediaType);
195198
let userId = user.uid + "";
199+
if (
200+
user.hasVideo &&
201+
user.uid + "" != props.userId.value &&
202+
props.userId.value != ""
203+
) {
204+
props.onEvent("videoActiveInactive");
205+
}
196206
const element = document.getElementById(userId);
197207
if (element) {
198208
remoteTrack.play(userId);
@@ -223,6 +233,15 @@ let VideoCompBuilder = (function (props) {
223233
props.onEvent("audioMuteUnmute");
224234
}
225235
}
236+
if (mediaType === "video") {
237+
if (
238+
!user.hasVideo &&
239+
user.uid + "" != props.userId.value &&
240+
props.userId.value != ""
241+
) {
242+
props.onEvent("videoActiveInactive");
243+
}
244+
}
226245
}
227246
);
228247
}, [props.userId.value]);

client/packages/lowcoder/src/comps/controls/eventHandlerControl.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,11 @@ export const audioMuteUnmute: EventConfigType = {
363363
value: "audioMuteUnmute",
364364
description: trans("meeting.audioMuteUnmute"),
365365
};
366-
366+
export const videoActiveInactive: EventConfigType = {
367+
label: trans("meeting.videoActiveInactive"),
368+
value: "videoActiveInactive",
369+
description: trans("meeting.videoActiveInactive"),
370+
};
367371
export const InputEventHandlerControl = eventHandlerControl([
368372
changeEvent,
369373
focusEvent,
@@ -395,4 +399,5 @@ export const MeetingEventHandlerControl = eventHandlerControl([
395399
screenShared,
396400
cameraView,
397401
audioMuteUnmute,
402+
videoActiveInactive,
398403
] as const);

client/packages/lowcoder/src/i18n/locales/en.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1440,6 +1440,7 @@ export const en = {
14401440
screenShared: "Screen Shared",
14411441
screenSharedDesc: "Screen Shared",
14421442
audioMuteUnmute: "Audio Mute",
1443+
videoActiveInactive: "Video Active Inactive",
14431444
size: "Size",
14441445
top: "Top",
14451446
host: "Host",

0 commit comments

Comments
 (0)