From 6fac7c6321f9f0c673f662d89c7f32883b97b5b9 Mon Sep 17 00:00:00 2001 From: heyhiru Date: Tue, 14 Nov 2023 18:09:24 +0530 Subject: [PATCH] converted slug into reusable components Signed-off-by: heyhiru --- client/src/components/Lobby.jsx | 16 ++++-- client/src/components/VideoPlayer.jsx | 23 ++++++++ client/src/pages/index.js | 1 - client/src/pages/room/[slug].jsx | 76 +++++++++++---------------- client/src/styles/globals.css | 27 ++++++++++ 5 files changed, 94 insertions(+), 49 deletions(-) create mode 100644 client/src/components/VideoPlayer.jsx diff --git a/client/src/components/Lobby.jsx b/client/src/components/Lobby.jsx index 602ea86..8e85097 100644 --- a/client/src/components/Lobby.jsx +++ b/client/src/components/Lobby.jsx @@ -1,6 +1,7 @@ import { useSocket } from '@/context/SocketProvider'; import { useRouter } from 'next/router'; -import React, { useCallback, useEffect, useState } from 'react' +import React, { useCallback, useEffect, useState } from 'react'; +import VideoCallIcon from '@mui/icons-material/VideoCall'; const LobbyScreen = () => { const [email, setEmail] = useState(""); @@ -29,7 +30,12 @@ const LobbyScreen = () => { return (
-

Lobby

+

VideoPeers

+

+ Peer-to-Peer video calls, powered by WebRTC! +
+ Bring People Closer Together. +

{ setEmail(e.target.value)} @@ -45,14 +52,15 @@ const LobbyScreen = () => {
setRoom(e.target.value)} />
-
diff --git a/client/src/components/VideoPlayer.jsx b/client/src/components/VideoPlayer.jsx new file mode 100644 index 0000000..7433e6f --- /dev/null +++ b/client/src/components/VideoPlayer.jsx @@ -0,0 +1,23 @@ +import ReactPlayer from 'react-player'; + +const VideoPlayer = ({ stream, isAudioMute, name }) => ( +
+
+

+ {name === 'My Stream' ? 'My Stream' : 'Remote Stream'} +

+
+ +
+
+
+); + +export default VideoPlayer; \ No newline at end of file diff --git a/client/src/pages/index.js b/client/src/pages/index.js index d0594ab..a501f19 100644 --- a/client/src/pages/index.js +++ b/client/src/pages/index.js @@ -1,5 +1,4 @@ import LobbyScreen from '@/components/Lobby'; -import SocketProvider from '@/context/SocketProvider'; export default function Home() { return ( diff --git a/client/src/pages/room/[slug].jsx b/client/src/pages/room/[slug].jsx index 2b1e38f..8a015c9 100644 --- a/client/src/pages/room/[slug].jsx +++ b/client/src/pages/room/[slug].jsx @@ -2,6 +2,10 @@ import { useSocket } from '@/context/SocketProvider'; import React, { useCallback, useEffect, useState } from 'react' import ReactPlayer from 'react-player'; import peer from '@/service/peer'; +import CallIcon from '@mui/icons-material/Call'; +import VideoCallIcon from '@mui/icons-material/VideoCall'; +import VideoPlayer from '@/components/VideoPlayer'; +import CallHandleButtons from '@/components/CallHandleButtons'; const RoomPage = () => { const socket = useSocket(); @@ -194,66 +198,50 @@ const RoomPage = () => { }, [myStream, remoteSocketId, socket]); return ( -
-

RoomPage

-

{remoteSocketId ? "Connected" : "No One In Room"}

+
+

Video + + Peers +

+

+ {remoteSocketId ? "Connected With Remote User!" : "No One In Room"} +

{(remoteStream && remoteSocketId && isSendButtonVisible) && } {(remoteSocketId && callButton) && - + ( + + ) } -
+
+ { myStream && -
-

- My Stream -

- -
+ } { remoteStream && -
-

- Remote Stream -

- -
+ }
{myStream && ( -
-
- - - -
-
+ )}
) diff --git a/client/src/styles/globals.css b/client/src/styles/globals.css index 95d0b55..7e18f0c 100644 --- a/client/src/styles/globals.css +++ b/client/src/styles/globals.css @@ -1,3 +1,5 @@ +@import url('https://fonts.googleapis.com/css2?family=Poppins&display=swap'); +@import url('https://fonts.googleapis.com/css2?family=Josefin+Sans:wght@500&display=swap'); @tailwind base; @tailwind components; @tailwind utilities; @@ -37,4 +39,29 @@ button{ outline: 2px solid transparent; outline-offset: 2px; } +} + +.callButtons{ + border-width: 1px; + font-weight: 500; + border-radius: 9999px; + font-size: 0.875rem; + line-height: 1.25rem; + padding: 0.625rem; + text-align: center; + display: inline-flex; + align-items: center; + + &:hover{ + color: white; + } + + &:focus{ + outline: 2px solid transparent; + outline-offset: 2px; + } +} + +video{ + object-fit: cover; } \ No newline at end of file