Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-video-js-player

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-video-js-player

React wrapper for VideoJS

  • 1.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

react-video-js-player

React wrapper for VideoJS. Live Demo

Install

npm install --save react-video-js-player

Usage

import React, { Component } from 'react';
import VideoPlayer from 'react-video-js-player';

class VideoApp extends Component {
    player = {}
    state = {
        video: {
            src: "http://www.example.com/path/to/video.mp4",
            poster: "http://www.example.com/path/to/video_poster.jpg"
        }
    }

    onPlayerReady(player){
        console.log("Player is ready: ", player);
        this.player = player;
    }

    onVideoPlay(duration){
        console.log("Video played at: ", duration);
    }

    onVideoPause(duration){
        console.log("Video paused at: ", duration);
    }

    onVideoTimeUpdate(duration){
        console.log("Time updated: ", duration);
    }

    onVideoSeeking(duration){
        console.log("Video seeking: ", duration);
    }

    onVideoSeeked(from, to){
        console.log(`Video seeked from ${from} to ${to}`);
    }

    onVideoEnd(){
        console.log("Video ended");
    }

    render() {
        return (
            <div>
                <VideoPlayer
                    controls={true}
                    src={this.state.video.src}
                    poster={this.state.video.poster}
                    width="720"
                    height="420"
                    onReady={this.onPlayerReady.bind(this)}
                    onPlay={this.onVideoPlay.bind(this)}
                    onPause={this.onVideoPause.bind(this)}
                    onTimeUpdate={this.onVideoTimeUpdate.bind(this)}
                    onSeeking={this.onVideoSeeking.bind(this)}
                    onSeeked={this.onVideoSeeked.bind(this)}
                    onEnd={this.onVideoEnd.bind(this)}
                />
            </div>
        );
    }
}
export default VideoApp;

VideoJS APIs support:

onReady will return videojs instance. Which means you can use all the APIs provided by VideoJS.
List of VideoJS APIs

VideoJS plugins support:

Since most of the VideoJS plugins needs videojs instance to get initialized, it is very easy to integrate any of the available plugins by making use of videojs instance returnd by onReady event.
List of VideoJS plugins

Available Props:

Prop NameProp TypeDefault ValueDescription
srcstring""Video file path
posterstring""Video poster file path
widthstring | numberautoVideo player width
heightstring | numberautoVideo player height
controlsbooleantrueVideo player control bar toggle
autoplaybooleanfalseVideo will start playing automatically if true
preloadstringautovideo tag preload attribute
playbackRatesarray[0.5, 1, 1.5, 2]Video speed control
hideControlsarray[]List of controls to hide. ['play','volume','seekbar','timer','playbackrates','fullscreen']
bigPlayButtonbooleantrueBig play button visibility toggle
bigPlayButtonCenteredbooleantrueBig play button center position toggle
classNamestring""Video player wrapper class. It can be used for custom player skin.

Video tracking props:

Method NameDescription
onReadyIt will fire when video player is ready to be used. It returns videojs instance.
onPlayIt will fire when video starts playing anytime. It returns current time of the video
onPauseIt will fire when video is paused. It returns current time of the video
onTimeUpdateIt keeps firing while video is in playing state. It returns current time of the video
onSeekingIt will fire when video is beeing seeked using seekbar. It returns current time of the video
onSeekedIt will fire after seeking is done. It returns seek start time and seek end time for the video.
onEndIt will fire when video is finished playing.

Keywords

FAQs

Package last updated on 05 Jan 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc