This application is built using the Agora RTC SDK to enable real-time video and audio communication. It supports features like screen sharing, remote user video rendering, muting/unmuting audio and video, and clean session handling.
-
Real-time Video and Audio Communication:
- Users can join a channel and communicate with others via audio and video.
-
Screen Sharing:
- Users can share their screens with others in the channel.
- Switch back to camera streaming after stopping screen sharing.
-
Remote User Video Rendering:
- Renders videos of remote users dynamically as they join or leave the channel.
-
Audio and Video Controls:
- Mute/unmute audio and video for the local user.
-
Session Management:
- Proper handling of user sessions, ensuring clean join/leave processes.
- An Agora account to obtain the App ID.
- Node.js installed on your system.
- Basic knowledge of React and TypeScript.
-
Clone the repository:
git clone <https://github.com/adityav477/agora-based-videochat>
-
Install dependencies:
cd agora-based-videochat npm install -
Create a
.envfile and add your Agora App ID:NEXT_PUBLIC_AGORA_API_KEY=your-agora-app-id
-
Start the development server:
npm start
URL -> https://agora-based-videochat.vercel.app/
- In the root folder
docker compose up --build-
Call the
joinfunction with the channel name and token:join(channelName);
-
Call the
leavefunction to exit the channel and clean up resources:leave();
-
Start screen sharing by calling:
startScreenShare();
-
Stop screen sharing and switch back to the camera using:
stopScreenShare();
-
Mute/unmute audio:
muteAudio();
-
Mute/unmute video:
muteVideo();
-
Remote users are dynamically rendered using:
{Array.from(remoteUsersSet || []).map((user) => ( <div key={user.uid} className="relative"> <div id={`player-${user.uid}`} className="h-60 bg-gray-800 rounded-lg overflow-hidden"> {user.hasVideo && ( <video ref={(v) => { if (v && user.videoTrack) { user.videoTrack.play(v); remoteUsersRef.current.set(user.uid, v); } }} autoPlay playsInline ></video> )} </div> <p className="absolute bottom-2 left-2 text-white">Remote User {user.uid}</p> </div> ))}
- Custom React hook that manages Agora client initialization, state management, and functionalities like joining, leaving, screen sharing, and user events.
- Dynamically renders video streams of remote users.
- Ensure browser permissions for camera and microphone are granted.
- Screen sharing may not work on unsupported browsers.
This project is licensed under the MIT License.