Skip to content

Commit 0e5ee2e

Browse files
committed
Swap chat template to video panel and edit styling
1 parent 1fc36fa commit 0e5ee2e

File tree

4 files changed

+116
-22
lines changed

4 files changed

+116
-22
lines changed

apps/frontend/src/app/collaboration/[id]/page.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import {
2727
MessageOutlined,
2828
PlayCircleOutlined,
2929
SendOutlined,
30+
VideoCameraOutlined,
3031
} from "@ant-design/icons";
3132
import { ProgrammingLanguageOptions } from "@/utils/SelectOptions";
3233
import CollaborativeEditor, {
@@ -457,15 +458,14 @@ export default function CollaborationPage(props: CollaborationProps) {
457458
<Row className="chat-row">
458459
<div className="chat-container">
459460
<div className="chat-title">
460-
<MessageOutlined className="title-icons" />
461-
Chat
461+
<VideoCameraOutlined className="title-icons" />
462+
Video
462463
</div>
463464
<VideoPanel />
464-
<div className="chat-message-box">
465+
{/* <div className="chat-message-box">
465466
<div className="chat-header-message">
466467
Matched with {matchedUser}
467468
</div>
468-
{/* TODO: Map and input the history of messages sent here */}
469469
<div></div>
470470
</div>
471471
<div className="chat-typing-box">
@@ -474,7 +474,7 @@ export default function CollaborationPage(props: CollaborationProps) {
474474
placeholder="Send Message Here"
475475
rows={4}
476476
/>
477-
</div>
477+
</div> */}
478478
</div>
479479
</Row>
480480
</Col>

apps/frontend/src/app/collaboration/[id]/styles.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@
3737
}
3838

3939
.session-row {
40-
height: 20%;
40+
height: 18%;
4141
padding: 1rem 0.25rem 0.25rem;
4242
}
4343

4444
.chat-row {
45-
height: 80%;
45+
height: 82%;
4646
padding: 0.25rem;
4747
}
4848

apps/frontend/src/components/VideoPanel/VideoPanel.tsx

Lines changed: 97 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import "./styles.scss";
44
import { Button } from "antd";
55
import {
66
ApiOutlined,
7+
AudioMutedOutlined,
8+
AudioOutlined,
79
PhoneOutlined,
810
VideoCameraOutlined,
911
} from "@ant-design/icons";
@@ -23,6 +25,7 @@ const VideoPanel = () => {
2325
);
2426
const [userStream, setUserStream] = useState<MediaStream | null>(null);
2527
const [videoOn, setVideoOn] = useState<boolean>(true);
28+
const [muteOn, setMuteOn] = useState<boolean>(false);
2629

2730
const handleCall = () => {
2831
navigator.mediaDevices
@@ -52,6 +55,17 @@ const VideoPanel = () => {
5255
if (sender) {
5356
sender.replaceTrack(videoTrack); // Replace the video track in the call
5457
}
58+
59+
const audioTrack = userStream.getAudioTracks()[0];
60+
61+
const sender2 = call.peerConnection.getSenders().find((s) => {
62+
if (s.track) {
63+
return s.track.kind === "audio";
64+
}
65+
});
66+
if (sender2) {
67+
sender2.replaceTrack(audioTrack); // Replace the video track in the call
68+
}
5569
}
5670
}
5771
}
@@ -104,7 +118,6 @@ const VideoPanel = () => {
104118

105119
const toggleVideo = () => {
106120
if (userStream) {
107-
console.log(userStream.getVideoTracks());
108121
const videoTrack = userStream.getVideoTracks()[0];
109122

110123
if (videoTrack) {
@@ -134,33 +147,102 @@ const VideoPanel = () => {
134147
}
135148
};
136149

150+
const toggleMute = () => {
151+
if (userStream) {
152+
console.log(userStream.getAudioTracks());
153+
const audioTrack = userStream.getAudioTracks()[0];
154+
155+
if (audioTrack) {
156+
if (muteOn) {
157+
// Unmute the audio track
158+
audioTrack.enabled = true;
159+
setMuteOn(false);
160+
} else {
161+
// Mute the audio track
162+
audioTrack.enabled = false;
163+
setMuteOn(true);
164+
165+
if (callInstance) {
166+
const sender = callInstance.peerConnection
167+
.getSenders()
168+
.find((s) => {
169+
if (s.track) {
170+
return s.track.kind === "audio";
171+
}
172+
});
173+
if (sender) {
174+
sender.replaceTrack(audioTrack); // Replace the video track in the call
175+
}
176+
}
177+
}
178+
}
179+
}
180+
};
181+
137182
return (
138183
<div className="video-panel">
139-
<p className="header-tag">Video Feed for: {currentUsername}</p>
184+
{/* <p className="header-tag">Video Feed for: {currentUsername}</p> */}
140185
<video
141186
className="user-video"
142187
playsInline
143188
ref={currentUserVideoRef}
144189
autoPlay
145-
muted
146190
/>
147-
<Button
148-
onClick={toggleVideo}
149-
icon={<VideoCameraOutlined />}
150-
type={videoOn ? "default" : "primary"}
151-
>
152-
{videoOn ? "Off Webcam" : "On Webcam"}
153-
</Button>
154-
<Button onClick={handleCall} icon={<ApiOutlined />} type="primary">
155-
Initiate Call
156-
</Button>
157-
<p className="header-tag">Video Feed for: {matchedUsername}</p>
191+
<div className="buttons-container">
192+
<Button
193+
onClick={toggleVideo}
194+
icon={
195+
videoOn ? (
196+
<div className="icon-padding">
197+
<svg
198+
xmlns="http://www.w3.org/2000/svg"
199+
width="1.2em"
200+
height="1.2em"
201+
viewBox="0 0 32 32"
202+
>
203+
<path
204+
fill="currentColor"
205+
d="M21 26H4a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h17a2 2 0 0 1 2 2v4.06l5.42-3.87A1 1 0 0 1 30 9v14a1 1 0 0 1-1.58.81L23 19.94V24a2 2 0 0 1-2 2M4 8v16h17v-6a1 1 0 0 1 1.58-.81L28 21.06V10.94l-5.42 3.87A1 1 0 0 1 21 14V8Z"
206+
></path>
207+
</svg>
208+
</div>
209+
) : (
210+
<div className="icon-padding">
211+
<svg
212+
xmlns="http://www.w3.org/2000/svg"
213+
width="1.2em"
214+
height="1.2em"
215+
viewBox="0 0 32 32"
216+
>
217+
<path
218+
fill="currentColor"
219+
d="M29.46 8.11a1 1 0 0 0-1 .08L23 12.06v-1.62l7-7L28.56 2L2 28.56L3.44 30l4-4H21a2 2 0 0 0 2-2v-4.06l5.42 3.87A1 1 0 0 0 30 23V9a1 1 0 0 0-.54-.89M28 21.06l-5.42-3.87A1 1 0 0 0 21 18v6H9.44L21 12.44V14a1 1 0 0 0 1.58.81L28 10.94zM4 24V8h16V6H4a2 2 0 0 0-2 2v16z"
220+
></path>
221+
</svg>
222+
</div>
223+
)
224+
}
225+
type={videoOn ? "default" : "primary"}
226+
>
227+
{videoOn ? "Off Cam" : "On Cam"}
228+
</Button>
229+
<Button
230+
onClick={toggleMute}
231+
type={!muteOn ? "default" : "primary"}
232+
icon={muteOn ? <AudioMutedOutlined /> : <AudioOutlined />}
233+
>
234+
{muteOn ? "On Mic" : "Off Mic"}
235+
</Button>
236+
<Button onClick={handleCall} icon={<ApiOutlined />} type="primary">
237+
Call
238+
</Button>
239+
</div>
240+
{/* <p className="header-tag">Video Feed for: {matchedUsername}</p> */}
158241
<video
159242
className="matched-user-video"
160243
playsInline
161244
ref={remoteVideoRef}
162245
autoPlay
163-
muted
164246
/>
165247
</div>
166248
);

apps/frontend/src/components/VideoPanel/styles.scss

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,20 @@
66
.user-video,
77
.matched-user-video {
88
width: 100%;
9+
margin: 4px 0px 0px;
910
}
1011

1112
.header-tag {
1213
font-weight: bold;
1314
}
15+
16+
.buttons-container {
17+
margin-top: 1px;
18+
display: flex;
19+
flex-direction: row;
20+
justify-content: space-between;
21+
}
22+
23+
.icon-padding {
24+
padding-top: 2px;
25+
}

0 commit comments

Comments
 (0)