1. Third-Party Packages
A Third-Party Package is a reusable code developed to perform a specific functionality
1.1 Advantages
- Easy integration
- Saves Time
- More productivity with fewer lines of code
- Better Error Handling
- More Customisation Options ... many more.
We have used many third-party packages like React Router, React Loader, React Icons, JWT, etc.
Node Package Manager contains Third-Party Packages for React JS, Node JS, Angular JS, and many more libraries and frameworks. To know more about npm you can refer to this.
1.2 Selecting a Third-Party Package
1.2.1 Things to Consider
- Users Satisfaction
- Popularity (number of stars)
- Maintenance
- Documentation
- Number of unresolved issues
Compare the packages in the above categories and pick one for the application.
2. Third-Party Package - react-player
NPM contains a react-player, a third-party package that provides a React component for playing a variety of URLs, including file paths, YouTube, Facebook, etc.
Installation Command:
2.1 React Player Props
We can provide different props to ReactPlayer. Below are some of the most commonly used props.
Prop | Description | Default Value |
---|---|---|
playing | Set to true or false to pause or play the media | false |
controls | Set to true to display native player controls. | false |
light | Set to true to show the video thumbnail, which loads the full player on click. Pass in an image URL to override the preview image | false |
width | Set the width of the player | 640px |
height | Set the height of the player | 360px |
className | Add the custom styles to ReactPlayer | - |
Example:
File: src/App.js
File: src/components/VideoPlayer/index.js
ReactPlayer Supports different types of URLs.
2.1.1 controls Prop
File: src/components/VideoPlayer/index.js
2.1.2 playing Prop
File: src/components/VideoPlayer/index.js