From c5d56f9ff62ee2edb25d39fbd0cb813cd8cfe977 Mon Sep 17 00:00:00 2001
From: chunweii <47494777+chunweii@users.noreply.github.com>
Date: Tue, 17 Oct 2023 21:21:08 +0800
Subject: [PATCH] Fix mute issue. Also move the video room outside
---
frontend/src/components/room/description.tsx | 2 --
frontend/src/components/room/video-room.tsx | 15 ++++++++-------
frontend/src/pages/room/[id].tsx | 2 +-
3 files changed, 9 insertions(+), 10 deletions(-)
diff --git a/frontend/src/components/room/description.tsx b/frontend/src/components/room/description.tsx
index 340b8cad..f859b4e6 100644
--- a/frontend/src/components/room/description.tsx
+++ b/frontend/src/components/room/description.tsx
@@ -18,7 +18,6 @@ type DescriptionProps = {
export default function Description({
question,
className,
- room
}: DescriptionProps) {
return (
@@ -45,7 +44,6 @@ export default function Description({
-
);
}
diff --git a/frontend/src/components/room/video-room.tsx b/frontend/src/components/room/video-room.tsx
index 24c517cb..ca42997a 100644
--- a/frontend/src/components/room/video-room.tsx
+++ b/frontend/src/components/room/video-room.tsx
@@ -5,6 +5,7 @@ import { Mic, MicOff, Video, VideoOff } from 'lucide-react';
interface VideoRoomProps {
room: Room | null;
+ className?: string;
}
function SingleVideoTrack({ track, userId, isLocal, isMute, toggleMute, isCameraOn, toggleCamera }:
@@ -27,7 +28,7 @@ function SingleVideoTrack({ track, userId, isLocal, isMute, toggleMute, isCamera
className="flex items-center justify-start gap-4"
key={userId}
>
-
+
{userId}
@@ -59,7 +60,7 @@ function SingleAudioTrack({track}: {track: RemoteAudioTrack}) {
>
);
}
-export default function VideoRoom({ room }: VideoRoomProps) {
+const VideoRoom: React.FC
= ({ room, className }) => {
const [isCameraOn, setIsCameraOn] = useState(true);
const [isMute, setIsMute] = useState(false);
const [participants, setParticipants] = useState([]);
@@ -103,7 +104,7 @@ export default function VideoRoom({ room }: VideoRoomProps) {
const toggleMute = () => {
room?.localParticipant.audioTracks.forEach(publication => {
if (publication.track) {
- publication.track.enable(!isMute);
+ publication.track.enable(isMute);
setIsMute(!isMute);
}
});
@@ -128,6 +129,7 @@ export default function VideoRoom({ room }: VideoRoomProps) {
}, [room]);
return (
+
{localParticipant ? Array.from(localParticipant.videoTracks.values()).map(publication => {
if (publication.track.kind === 'video') {
@@ -137,8 +139,6 @@ export default function VideoRoom({ room }: VideoRoomProps) {
{participants.flatMap(participant => {
return Array.from(participant.videoTracks.values()).map(publication => {
if (publication.track?.kind === 'video') {
- console.log("remote track")
- // return
;
return
;
} else {
return null;
@@ -154,7 +154,8 @@ export default function VideoRoom({ room }: VideoRoomProps) {
}
});
})}
-
+
);
-}
+};
+export default VideoRoom;
diff --git a/frontend/src/pages/room/[id].tsx b/frontend/src/pages/room/[id].tsx
index 2019fcde..0e2e3217 100644
--- a/frontend/src/pages/room/[id].tsx
+++ b/frontend/src/pages/room/[id].tsx
@@ -48,7 +48,6 @@ export default function Room() {
question={question}
participants={["Charisma", "Chun Wei"]}
room={room}
- className="h-[60vh]"
/>
{question.solution}
@@ -62,6 +61,7 @@ export default function Room() {
/>
+
);
}