Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

How to create Video Player in ReactJS ?

  • Last Updated : 09 Nov, 2021

In this article, we are going to learn how we can create Video Player in ReactJS. A video player is a kind of media player for playing back digital video data.

React is a free and open-source front-end JavaScript library for building user interfaces or UI components. It is maintained by Facebook and a community of individual developers and companies.

Approach: To create our video player we are going to use the react-loading package because it is powerful, lightweight, and fully customizable. After that, we will add our video player to our homepage using the installed package.

Create ReactJs Application: You can create a new ReactJs project using the below command:

npx create-react-app gfg

Install the required package: Now we will install the react-video-js-player package using the below command:

npm i react-video-js-player

Project Structure: It will look like this.

Adding Video Player: In this example, we are going to add the react-loading on the homepage of our app using the package that we installed. We are using the below image and video in the example.

Now add the below code in the App.js file to create the video player.


import React, { Component } from 'react';
import VideoPlayer from 'react-video-js-player';
class VideoApp extends Component {
    player = {}
    state = {
        video: {
            src: "/video.mp4",
            poster: "/1.png"
        this.player = player;
    render() {
        return (
export default VideoApp;

Explanation: In the above example first, we are importing the VideoPlayer component from the react-video-js-player package. After that, we are creating our onPlayerReady and state function. Then we are adding our Video Player using the VideoPlayer component of the installed package.

Steps to run the application: Run the below command in the terminal to run the app.

npm start


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!