Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • NextJS
  • Material UI
  • React Bootstrap
  • React Suite
  • Ant Design
  • Reactstrap
  • BlueprintJS
  • React Desktop
  • React Native
  • React Rebass
  • React Spring
  • React Evergreen
  • ReactJS
  • ReactJS
  • JS Formatter
  • Web Technology
Open In App
Next Article:
Create a Video Player App using React-Native
Next article icon

Create a Video Streaming App using React-Native

Last Updated : 23 Jul, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

React-Native is an open-source JavaScript framework used to broaden cross-platform packages i.e., you may write code in React-Native and publish it as an Android or IOS app. In this article, we will build a Video Streaming app using React-Native. The app will run on both Android and IOS.

Preview of final output: Let us have a look at how the final application will look like.

VideoStreaming
Video Streaming App

Prerequisites

  • Basics of JavaScript
  • React Basics
  • React Native Basics
  • Node.js and npm
  • Expo CLI

Approach to create Video Streaming App:

In the app, we use two screens. Home Screen and Video Player Screen. The home screen takes the video URL and plays it in the video player screen. To play the video we use the expo-av package. You can input any mp4 video URL that is live in the internet. The app will fetch the URL and play the video. This is how our basic video streaming app works.

Steps to Create Video Streaming App:

Step 1: Create a React Native app by using this command:

npx create-expo-app VideoStreamingApp

Step 2: Navigate to our project through this command:

cd VideoStreamingApp

Step 3: Install the required dependencies using the following command

npm install @react-navigation/native @react-navigation/stack expo-av

Project Structure:

Video-Streaming-Structure
Project Structure


The updated dependencies in package.json will look like this

"dependencies": {
"expo-av": "~13.2.1",
"expo-camera": "~13.2.1",
"expo-status-bar": "~1.4.4",
"expo-permissions": "~14.1.1",
"@expo/vector-icons": "^13.0.0",
"expo-media-library": "~15.2.3",
"react-native-paper": "4.9.2",
"expo-document-picker": "~11.2.2",
"react-native-screens": "~3.20.0",
"@react-navigation/stack": "^6.3.20",
"@react-navigation/native": "6.0.0",
"react-native-gesture-handler": "~2.9.0",
"@react-navigation/bottom-tabs": "^6.5.11",
"react-native-safe-area-context": "4.5.0"
}

Example: Write the code in respective files

JavaScript
// App.js  import React from 'react'; import { NavigationContainer } from '@react-navigation/native'; import { createStackNavigator } from '@react-navigation/stack'; import HomeScreen from './HomeScreen'; import VideoPlayer from './VideoPlayer';  const Stack = createStackNavigator();  const App = () => { 	return ( 		<NavigationContainer> 			<Stack.Navigator 				initialRouteName="Home" 				screenOptions={{ headerShown: false }} 			> 				<Stack.Screen name="Home" component={HomeScreen} /> 				<Stack.Screen name="VideoPlayer" component={VideoPlayer} /> 			</Stack.Navigator> 		</NavigationContainer> 	); };  export default App; 
JavaScript
// HomeScreen.js  import React, { useState } from 'react'; import { View, Text, TextInput, Pressable } from 'react-native'; import { styles } from './styles';  const HomeScreen = ({ navigation }) => { 	const [videoUrl, setVideoUrl] = useState('');  	const handlePlayVideo = () => { 		navigation.navigate('VideoPlayer', { videoUrl }); 	};  	return ( 		<View style={styles.container}> 			<Text style={styles.heading}>GeeksForGeeks</Text> 			<Text style={styles.heading}>Video Streaming App</Text> 			<TextInput 				style={styles.input} 				placeholder="Enter Video URL" 				onChangeText={(url) => setVideoUrl(url)} 				value={videoUrl} 			/> 			<Pressable 				onPress={handlePlayVideo} 				style={({ pressed }) => [ 					styles.button, 					{ 						backgroundColor: pressed ? '#1e8449' : '#2ecc71', 					}, 				]} 			> 				<Text style={styles.buttonText}>Play Video</Text> 			</Pressable> 		</View> 	); };  export default HomeScreen; 
JavaScript
// VideoPlayer.js  import React from 'react'; import { View, Text } from 'react-native'; import { Video } from 'expo-av'; import { styles } from './styles';  const VideoPlayer = ({ route }) => { 	const { videoUrl } = route.params;  	return ( 		<View style={styles.container}> 			<Text style={styles.heading}>Video Player</Text> 			<Video 				source={{ uri: videoUrl }} 				style={styles.video} 				useNativeControls 			/> 		</View> 	); };  export default VideoPlayer; 
JavaScript
// styles.js  import { StyleSheet } from "react-native";  export const styles = StyleSheet.create({ 	container: { 		flex: 1, 		justifyContent: 'center', 		alignItems: 'center', 		padding: 16, 	}, 	heading: { 		fontSize: 24, 		fontWeight: 'bold', 		marginBottom: 20, 		color: '#228B22', 	}, 	input: { 		height: 40, 		width: '100%', 		borderColor: '#228B22', 		borderWidth: 1, 		marginBottom: 20, 		paddingLeft: 10, 	}, 	button: { 		flexDirection: 'row', 		alignItems: 'center', 		backgroundColor: '#228B22', 		padding: 10, 		borderRadius: 5, 	}, 	buttonText: { 		color: 'white', 		marginLeft: 10, 	}, 	video: { 		width: 300, 		height: 300, 	}, }); 

You can use any of the below two methods to run the app

Method 1: Open the terminal and enter the following command to run the app

npx expo start

Now download the Expo Go app from the Apple App Store (For iOS) or Google Play Store (For Android) to run the app.

Method 2: You can use emulator or connect computer to your device using USB and run the below command

  • To run on Android:
npx react-native run-android
  • To run on Ios:
npx react-native run-ios

Output:


Next Article
Create a Video Player App using React-Native

S

sainaveen_bhukya
Improve
Article Tags :
  • Project
  • Web Technologies
  • ReactJS
  • Geeks Premier League
  • React-Native
  • Geeks Premier League 2023

Similar Reads

  • Create a Video Player App using React-Native
    React-Native is an open-source JavaScript framework used to broaden cross-platform packages i.e., you may write code in React-Native and publish it as an Android or IOS app. In this article, we will build a Video Player app with the usage of React-Native. The app will run on both Android and IOS. Pr
    4 min read
  • Create a Voting App using React-Native
    Voting involves assessing multiple entities based on specific criteria. This article guides the creation of a basic voting app, where users can compare and evaluate options. The application allows users to make choices, making it a valuable tool for decision-making and gathering opinions. We will cr
    3 min read
  • Create Timeline App using React-Native
    A Timeline App is a software application designed to display events in chronological order. The primary purpose of this timeline app is to present a visual representation of a sequence of events. In this article, we are going to implement a TimeLine App using React Native. It allows users to easily
    4 min read
  • Create a Voice Notes App using React-Native
    We are going to build a Voice Notes app that will allow us to save our voice as a recording in our application. It is similar to a notes app but we will have our voice as notes. We can play the voice recordings, record them, and delete them. It leverages React-Native's cross-platform capabilities to
    5 min read
  • Create a News Reader app using React-Native
    Creating the News Reader application using React-Native language is an exciting project. Using this project, the users can read the news in the application itself, by filtering them according to the categories as per their interest. In this article, we will develop the complete News Reader applicati
    5 min read
  • Create a Location Sharing App using React-Native
    In this article, we are going to build a step-by-step Location Sharing App using React-Native. A Location Sharing App developed with React-Native allows users to share their real-time location with others. It leverages React-Native's cross-platform capabilities to create a mobile application that fa
    4 min read
  • Create a Book Store using React-Native
    React-Native is a flexible frameworks for building mobile applications. We will develop a Book Store application, which allows users to search for a specific book, and store the book in the application. If the user wants to remove the book from the stored list, they can easily remove it by navigatin
    6 min read
  • Create a Food Reciepe App using React-Native
    In this React-Native article, we will be developing an interactive Food Recipe Application. In this application, the users can be able to search for any food recipe in the search box. Then, according to the search query, the results will be fetched through an API and will be displayed in the applica
    5 min read
  • Create a Text Editor App using React-Native
    In this article, we are going to implement a text editor app using React Native. It will contain multiple text formatting functionalities like bold, italic, underline, etc. We will implement Editor with a library called "react-native-pell-rich-editor." Preview of final output: Let us have a look at
    3 min read
  • Create a Bill Splitter App using React-Native
    We are going to implement the Bill Splitter App using React Native. Bill Splitter App is a mobile application that helps us divide expenses and bills among a group of people. For example, when we are dining at a restaurant with friends, going on a trip, or sharing household expenses with roommates.
    4 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences