1.0.0 • Published 6 years ago

react-simple-video-player v1.0.0

Weekly downloads
148
License
MIT
Repository
github
Last release
6 years ago

react-simple-video-player

A simple, material design video player component for React.

Video player screenshot

Install

yarn add react-simple-video-player or npm install --save react-simple-video-player

Usage

Basic example

import VideoPlayer from 'react-simple-video-player';

const App = () => (
  <VideoPlayer url="/video.mp4" />
);

Advanced example

import VideoPlayer from 'react-simple-video-player';

const App = () => (
  <VideoPlayer
    url="/video.mp4"
    poster="/myPoster.png"
    width={400}
    height={300}
    autoplay
  />
);

Props

* = Required

PropDescriptiondefault
url*Url of the video file to play
posterUrl of the image to use as poster for the video
widthWidth of the video player640
heightHeight of the video player360
autosizeIf set to true, the video player will become 100% of the parent width and 100% of the parent height (if the parent does not have a height, the video player will automatically become the right height). autosize overrides the given width and heightfalse
autoplayIf set to true, the video will automatically playfalse
loopIf set to true, the video will loopfalse
aspectRatioThe aspect ratio of the video (see explanation below).16:9

Usage of the aspectRatio prop

The aspectRatio prop can be used to automatically give the video player the correct height for the given width (or the correct width for the given height).

For example, in the following scenario:

<VideoPlayer url="/video.mp4" width={400} aspectRatio="4:3" />

the video player would automatically become 300px high.

In the following scenario:

<VideoPlayer url="/video.mp4" height={300} aspectRatio="4:3" />

the video player would automatically become 400px wide.

In the following scenario:

<VideoPlayer url="/video.mp4" aspectRatio="4:3" />

the video player would automatically become 480px high (since the width defaults to 640px).

Notice that when an invalid aspectRatio is given, it'll be ignored.

Notes

react-simple-video-player is built on top of react-player.

This project does not aim to provide a customisable video player.

Please use react-player when you need customisability.