Skip to content

videosdk-live/videosdk-rtc-react-native-sdk-example

Repository files navigation

🚀 Video SDK for React Native

Documentation Firebase TestFlight Discord Register

At Video SDK, we’re building tools to help companies create world-class collaborative products with capabilities for live audio/video, cloud recordings, RTMP/HLS streaming, and interaction APIs.

🥳 Get 10,000 minutes free every month! Try it now!

⚡️From Clone to Launch - Get Started with the Example in 5 mins!

ReactNative

📚 Table of Contents

🖥️ Demo App

📱 Download the Sample iOS app here: https://testflight.apple.com/join/LYj3QJPx

📱 Download the Sample Android app here: https://appdistribution.firebase.dev/i/a4c63049415c4356

⚡ Quick Setup

  1. Sign up on VideoSDK to grab your API Key and Secret.
  2. Familiarize yourself with Token

🛠 Prerequisites

  • React Native 0.59.10 or later
  • Node 10 or later
  • Valid Video SDK Account
  • For Android
    • Java Development Kit (JDK) 8 or later
    • Android Studio (latest version recommended)
    • A physical or virtual mobile device running Android 5.0 or later
  • For iOS
    • Xcode 10 or later
    • CocoaPods
    • A physical or virtual mobile device running iOS 12.0 or later

📦 Running the Sample App

Follow these steps to get the sample app up and running:

1. Clone the sample project

Clone the repository to your local environment.

git clone https://github.com/videosdk-live/videosdk-rtc-react-native-sdk-example.git

2. Copy the .env.example file to .env file.

Open your favorite code editor and copy .env.example to .env file.

cp .env.example .env

3. Modify .env file

Generate a temporary token from Video SDK Account.

REACT_APP_VIDEOSDK_TOKEN = "TEMPORARY-TOKEN";

4. Install the dependencies

Install all the dependencies to run the project.

npm install

5. Set Up for iOS (if applicable)

For iOS, navigate to the ios folder and install the pods.

cd ios
pod install

6. Run the sample app

Bingo, it's time to push the launch button.

npm run start
npm android
npm ios

🔥 Meeting Features

Unlock a suite of powerful features to enhance your meetings:

Feature Documentation Description
📋 Precall Setup Setup Precall Configure audio, video devices, and other settings before joining the meeting.
🤝 Join Meeting Join Meeting Allows participants to join a meeting.
🚪 Leave Meeting Leave Meeting Allows participants to leave a meeting.
🎤 Toggle Mic Mic Control Toggle the microphone on or off during a meeting.
📷 Toggle Camera Camera Control Turn the video camera on or off during a meeting.
🖥️ Screen Share Screen Share Share your screen with other participants during the call.
📸 Image Capture Image Capturer Capture images of other participant from their video stream, particularly useful for Video KYC and identity verification scenarios.
🔊 Change Audio Output Switch Audio Output Select an output device for audio during a meeting.
🔌 Change Video Output Switch Video Output Select an output device for audio during a meeting.
⚙️ Optimize Audio Track Audio Track Optimization Enhance the quality and performance of media tracks.
⚙️ Optimize Video Track Video Track Optimization Enhance the quality and performance of media tracks.
🖼️ Virtual Background Virtual Background Add a virtual background or blur effect to your video during the call.
💬 Chat In-Meeting Chat Exchange messages with participants through a Publish-Subscribe mechanism.
📝 Whiteboard Whiteboard Collaborate visually by drawing and annotating on a shared whiteboard.
📁 File Sharing File Sharing Share files with participants during the meeting.
📺 Picture-in-Picture Picture-in-Picture Allows the video call to continue in a floating, minimized window.
📼 Recording Recording Record the meeting for future reference.
📡 RTMP Livestream RTMP Livestream Stream the meeting live to platforms like YouTube or Facebook.
📝 Real-time Transcription Real-time Transcription Generate real-time transcriptions of the meeting.
🔇 Toggle Remote Media Remote Media Control Control the microphone or camera of remote participants.
🚫 Mute All Participants Mute All Mute all participants simultaneously during the call.
🗑️ Remove Participant Remove Participant Eject a participant from the meeting.

🧠 Key Concepts

Understand the core components of our SDK:

  • Meeting - A Meeting represents Real-time audio and video communication.

    Note: Don't confuse the terms Room and Meeting; both mean the same thing 😃

  • Sessions - A particular duration you spend in a given meeting is referred as a session, you can have multiple sessions of a specific meetingId.

  • Participant - A participant refers to anyone attending the meeting session. The local participant represents yourself (You), while all other attendees are considered remote participants.

  • Stream - A stream refers to video or audio media content that is published by either the local participant or remote participants.

🔐 Token Generation

The token is used to create and validate a meeting using API and also initialize a meeting.

🛠️ Development Environment:

  • You may use a temporary token for development. To create a temporary token, go to VideoSDK's dashboard .

🌐 Production Environment:

  • You must set up an authentication server to authorize users for production. To set up an authentication server, please take a look at our official example repositories. videosdk-rtc-api-server-examples

🧩 Project Overview

App Behaviour with Different Meeting Types

  • One-to-One meeting - The One-to-One meeting allows 2 participants to join a meeting in the app.

  • Group Meeting - The Group meeting allows any number of participants to join a meeting in the app with a maximum of 6 participants on screen.

🏗️ Project Structure

We have separated screens and components in the following folder structure:

src
└── scenes
    └── join
      └── index.js
    └── meeting

1. Join Screen

  • scenes/join/index.js: This file provides an interface for users to create or join meetings, allowing control over audio, video, and camera orientation.

2. Meeting Screen

scenes
└── meeting
    └── index.js
    └── MeetingContainer.js
    └── Components
    └── Conference
    └── OneToOne
  • meeting/index.js : This file essentially initializes the meeting based on the provided configuration, such as meeting ID, participant name, and mic/camera status.
  • meeting/MeetingContainer.js : MeetingContainer.js manages joining and leaving meetings, tracking participant status and limits using useMeeting. It dynamically renders either ConferenceMeetingViewer, OneToOneMeetingViewer, or a waiting view based on the meeting type and participant count.

This folder contains all the common components used in the Conference and OneToOne meeting types.

Components
    └── ChatViewer
    └── ParticipantListViewer
    └── LocalParticipantPresenter.js
    └── WaitingToJoinView.js

1. ChatViewer

  • ChatViewer provides a real-time chat interface, displaying messages in a scrollable list with sender names and timestamps.

2. ParticipantListViewer

  • ParticipantListViewer displays a list of meeting participants using their IDs, with each participant represented by a ParticipantListItem component.

3. LocalParticipantPresenter.js

4. WaitingToJoinView.js

  • WaitingToJoinView.js provides a waiting screen with animation and message while a meeting room is being created.

The whole user interface and business logic for the meeting type Conference are contained in this folder.

Conference
    └── ConferenceMeetingViewer.js
    └── ConferenceParticipantGrid.js
    └── ParticipantView.js
    └── PauseInvisibleParticipant.js
    └── RemoteParticipantPresenter.js

1. ConferenceMeetingViewer.js

  • ConferenceMeetingViewer.js manages the primary layout and interaction for conference-style meetings, showing participant views, recording status, and controls for toggling audio, video, and screen sharing.

2. ConferenceParticipantGrid.js

  • ConferenceParticipantGrid.js arranges participant video feeds in a responsive grid, adjusting the number of participants per row and video quality based on the total participant count and whether someone is presenting. It uses a memoized ParticipantView to improve rendering efficiency and includes a BottomSheet for viewing individual participant stats.

3. ParticipantView.js

  • ParticipantView.js maintains the stream of a particular participant as well as the status of controls (Mic and Cam).

4. PauseInvisibleParticipant.js

  • PauseInvisibleParticipant.js optimizes resource usage by pausing video streams of participants who are not visible on the screen. It maps through all participants and checks if each participant ID is within the list of visible participants, resuming streams for visible ones and pausing others.

5. RemoteParticipantPresenter.js

The whole user interface and business logic for the meeting type OneToOne are contained in this folder.

OneToOne
    └── index.js
    └── LargeView
    └── MiniView
    └── LocalViewContainer.js
    └── ParticipantLimitViewer.js

1. index.js

  • The OneToOneMeetingViewer component defines the layout for one-on-one meetings, managing primary views for LargeView and MiniView participants. It provides controls for toggling audio, video, and screen sharing, and includes a BottomSheet for viewing participant stats, chat, and the participant list. The interface adapts dynamically based on participant count, screen-sharing status, and device orientation.

2. LargeView

  • LargeView displays a participant's video or screen share in full view, prioritizing high video quality.

3. MiniView

  • MiniView is dedicated to displaying a minimized view of a local participant’s video stream.

4. LocalViewContainer.js

  • LocalViewContainer.js handles displaying the local participant’s video stream when no other participants are present in the meeting.

5. ParticipantLimitViewer.js

  • ParticipantLimitViewer.js notifies users when the maximum participant limit is reached in a meeting, displaying a message that only two participants are allowed.


📖 Examples

📝 Documentation

Explore more and start building with our Documentation

🤝 Join Our Community

  • Discord: Engage with the Video SDK community, ask questions, and share insights.
  • X: Stay updated with the latest news, updates, and tips from Video SDK.