All Projects → mderrick → React Html5video

mderrick / React Html5video

Licence: mit
A customizeable HTML5 Video React component with i18n and a11y.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to React Html5video

vast-vmap
JavaScript library for IAB VAST + VMAP
Stars: ✭ 55 (-87.72%)
Mutual labels:  html5-video
synchroplayer
Synchronized video player for watching videos together remotely.
Stars: ✭ 25 (-94.42%)
Mutual labels:  html5-video
Plyr
A simple HTML5, YouTube and Vimeo player
Stars: ✭ 20,859 (+4556.03%)
Mutual labels:  html5-video
voronoi-video
Fragmented HTML5 using the Voronoi diagram
Stars: ✭ 13 (-97.1%)
Mutual labels:  html5-video
rtsp2html5
A small and simple PHP-script to convert RTSP-stream from IP-cameras to HTML5-video (with switch to MJPEG on failure)
Stars: ✭ 15 (-96.65%)
Mutual labels:  html5-video
Openplayerjs
Lightweight HTML5 video/audio player with smooth controls and ability to play VAST/VPAID/VMAP ads
Stars: ✭ 255 (-43.08%)
Mutual labels:  html5-video
cacophony
Cacophony HTML5 Interactive Video Player
Stars: ✭ 41 (-90.85%)
Mutual labels:  html5-video
Seethru
HTML5 video with alpha channel transparencies
Stars: ✭ 416 (-7.14%)
Mutual labels:  html5-video
advanced-responsive-video-embedder
Probably the the best WP plugin for embedding videos.
Stars: ✭ 32 (-92.86%)
Mutual labels:  html5-video
Fluid Player
Fluid Player - an open source VAST compliant HTML5 video player
Stars: ✭ 359 (-19.87%)
Mutual labels:  html5-video
balena-wpe
Fullscreen WebKit browser with hardware accelerated CSS, WebGL, and HTML5 video for the RaspberryPi 3.
Stars: ✭ 372 (-16.96%)
Mutual labels:  html5-video
clappr-core
Core components of the Clappr player architecture
Stars: ✭ 41 (-90.85%)
Mutual labels:  html5-video
Mediaelement Plugins
Plugins for the main mediaelement project
Stars: ✭ 328 (-26.79%)
Mutual labels:  html5-video
webFaceID
Use HTML5, Go and Facebox to implement face verification on a website
Stars: ✭ 60 (-86.61%)
Mutual labels:  html5-video
Gifshot
JavaScript library that can create animated GIFs from media streams, videos, or images.
Stars: ✭ 3,821 (+752.9%)
Mutual labels:  html5-video
vlitejs
🦋 vLitejs is a fast and lightweight Javascript library for customizing video and audio player in Javascript with a minimalist theme (HTML5, Youtube, Vimeo, Dailymotion)
Stars: ✭ 162 (-63.84%)
Mutual labels:  html5-video
youtube-to-html5-loader
Load YouTube videos with the HTLML5 <video> element without needing iframes or the YouTube JS API.
Stars: ✭ 77 (-82.81%)
Mutual labels:  html5-video
Lightgallery
A customizable, modular, responsive, lightbox gallery plugin.
Stars: ✭ 4,829 (+977.9%)
Mutual labels:  html5-video
Xgplayer
A HTML5 video player with a parser that saves traffic
Stars: ✭ 4,792 (+969.64%)
Mutual labels:  html5-video
Balena Wpe
Fullscreen WebKit browser with hardware accelerated CSS, WebGL, and HTML5 video for the RaspberryPi 3.
Stars: ✭ 353 (-21.21%)
Mutual labels:  html5-video

react-html5video

A customizeable HoC (Higher Order Component) for HTML5 Video that allows custom and configurable controls with i18n and a11y.

V2 API has changed and is not backwards compatible. You can find the old documentation here.

Build Status npm version npm downloads

View the demo.

Install

npm install react-html5video --save

Peer Dependencies

Usage

Simple Usage

The simplest way to use this component is to use the default player that is provided. It works the same way as a normal HTML5 video by taking all the supported HTML5 video attributes except for controls. This is now "controlled" and can be an array of supported component names in any order as below:

import { DefaultPlayer as Video } from 'react-html5video';
import 'react-html5video/dist/styles.css';
render() {
    return (
        <Video autoPlay loop muted
            controls={['PlayPause', 'Seek', 'Time', 'Volume', 'Fullscreen']}
            poster="http://sourceposter.jpg"
            onCanPlayThrough={() => {
                // Do stuff
            }}>
            <source src="http://sourcefile.webm" type="video/webm" />
            <track label="English" kind="subtitles" srcLang="en" src="http://source.vtt" default />
        </Video>
    );
}

a11y* and i18n

The custom controls provided are built using <button> and <input type="range"> which means basic keyboard controls are available when they are focused. For example, you can and hit the space bar on mute, play and fullscreen buttons as well as seek using the arrow keys when focused on the slider. aria-label attributes for screen readers have been used where user interaction is required. Try tabbing through the demo with Vox enabled.

You can change translate the aria-label values for all controls like so:

<Video copy={{ key: value }}>

The default english copy can be found in here.

*Disclaimer: Unfortuantely I don't much experience with a11y but I have tried to use some of the features from PayPal's accessible HTML5 player. If anyone has further input on this please raise an issue or a pull request.

Advanced Usage

If you want to get creative and create your own video player then you will need to use the higher order component. The HoC connects a React component to all the HTML5 video attributes and the HTMLMediaElement of the first video it finds in the component it is wrapping.

import videoConnect from 'react-html5video';

const MyVideoPlayer = ({ video, videoEl, children, ...restProps }) => (
    <div>
        <video {...restProps}>
            { children }
        </video>
        <p>
            Here are the video properties for the above HTML5 video:
            { JSON.stringify(video) }
        </p>
        <a href="#" onClick={(e) => {
            e.preventDefault();
            // You can do what you like with the HTMLMediaElement DOM element also.
            videoEl.pause();
        }}>
            Pause video
        </a>
    </div>
);

export default videoConnect(MyVideoPlayer)

The above will simply print out the properties of the HTML5 <video> within MyVideoPlayer. Now you have these properties and the HTMLMediaElement itself available in your component, it is up to you to create your new custom controls using them. See the default player as an example.

API

The API behaves much like the React Redux connect HoC but instead of using dispatch to change the state, we have access to the HTMLMediaElement.

videoConnect(ReactComponent, [mapStateToProps], [mapVideoElToProps], [mergeProps])

  • mapStateToProps(videoState, ownProps) - Use this to return the HTML5 video attributes required for your component. The plain object returned here will be merged with what is returned from mapVideoElToProps using the mergeProps function. By Default this returns all video attributes so they are accessible on this.props.video in your wrapped component.

  • mapVideoElToProps(videoEl, videoState, ownProps) - Use this to return a plain object that uses videoEl to update the videos state. videoEl is the raw HTMLMediaElement. The object returned here will be merged with what is returned from mapStateToProps using the mergeProps function. By default the videoEl will be accessible on this.props.videoEl in your wrapped component.

  • mergeProps(stateProps, videoElProps, ownProps) - If specified, it is passed the result of mapStateToProps mapVideoElToProps and the parent props. The plain object you return will be passed to your wrapped component. By default this will do Object.assign({}, stateProps, videoElProps, ownProps).

Components/Helpers

It is also possible to use the individual defaultPlayer components if you desire. The apiHelpers are also available. These are just methods that normalise the HTML5 video player API somewhat:

`import { Time, Seek, Volume, Captions, PlayPause, Fullscreen, Overlay, apiHelpers } from 'react-html5video';

Contributing

Dev Setup

To run a development server with HMR:

    $ npm i
    $ npm run i:demo
    $ npm start

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].