Skip to main content

Video Player

The Reactjs Media library provides a customizable, ready-to-use Video Player component, making it easy to integrate video playback into your React application.

Key Features

  • Fully customizable controls and UI
  • Built as a lightweight wrapper around the HTML5 video element
  • Easy to integrate and configure

Installation & Setup

The Video Player is designed following React principles to ensure modularity and flexibility. You can quickly add it to your project by importing it from the reactjs-media package and passing the necessary properties.

Quick Start Example

import { Video } from "reactjs-media";

const App = () => {
return (
<div>
<Video
src="/video.mkv" // Your video source
controls={true} // Show video controls
height={500} // Video player height
width={800} // Video player width
poster="https://example.com/poster-image.jpg" // Image displayed before video plays
/>
</div>
);
};

Props Overview

The Video Player accepts a wide range of properties (props) to give you full control over video playback and interaction. These can be divided into two categories: Attributes and Event Handlers.


Attributes

These props define the behavior and appearance of the video player.

PropTypeDescription
srcstringThe source URL of the video file (required).
controlsbooleanDisplays video controls (e.g., play, pause, volume) if true.
heightnumberSets the height of the video player.
widthnumberSets the width of the video player.
posterstringA poster image to show before the video starts.
autoPlaybooleanIf true, the video will play automatically once loaded.
loopbooleanIf true, the video will loop continuously once it finishes.

Event Handlers

These functions let you handle key events that occur during video playback.

EventDescription
onPlayCalled when the video starts playing.
onPauseCalled when the video is paused.
onEndedTriggered when the video finishes playing.
onTimeUpdateReceives the current playback time as the video progresses.
onVolumeChangeReceives the current volume level whenever it's adjusted.
onSeekingTriggered when the user seeks to a new time in the video.
onSeekedCalled once the seeking operation is complete.
onErrorTriggered when there is an error loading the video.

Conclusion

With the Reactjs Media Video Player, you can quickly add rich video functionality to your application while maintaining full control over both the UI and the playback experience. Customize the player as needed, and take advantage of the built-in event handlers to create seamless user experiences.