From 25ce6f6536874dcc00a849cfa97106f575bc2b7a Mon Sep 17 00:00:00 2001 From: Shreyansh shrey <53744971+shreyshreyansh@users.noreply.github.com> Date: Mon, 21 Jun 2021 13:47:45 +0530 Subject: [PATCH] fix: remove the previous elements from the later joined screen --- public/script.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/public/script.js b/public/script.js index e9c41c5..29afcf6 100644 --- a/public/script.js +++ b/public/script.js @@ -19,6 +19,10 @@ navigator.mediaDevices.getUserMedia({ call.on('stream', userVideoStream => { addVideoStream(video, userVideoStream) }) + call.on("close", () => { + video.remove(); + }) + peers[call.peer] = call; }) socket.on('user-connected', userId => { @@ -53,4 +57,4 @@ function addVideoStream(video, stream) { video.play() }) videoGrid.append(video) -} \ No newline at end of file +}