Hi folks, hope you are doing well. In this post we are going to learn how to add a video link to your React app and play in your React app.
How to Install
This player component can be used by installing react-player
NPM package.
Enter your directory, open your terminal (Ctrl+ J).
Type npm i react-player
in your app directory and press enter.
How To Use
1. Import -
Now, import the package in the React component file where you want to add the video player.
import ReactPlayer from "react-player";
2. Add the component -
<ReactPlayer url="url-link" controls={true} />
Hurray, you added a video-player to your React app!!
At this point, you can stop and enjoy :)
Additional Settings-
If you want to add some extra settings, here are a few-
-
controls = {true/false}
- provides video controls to user -
loop = {true/false}
- repeat the video if it ends -
volume = {0 to 1}
- set volume
To check out more, click here
Check out the my Netflix clone, click on any movie to view it's trailer - here
If you know of other methods to implement, let me know in the comments. Thanks for reading :)
Top comments (0)