npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-videojs-hook

v1.0.1

Published

A React hook for video.js

Downloads

1,304

Readme

react-videojs-hook

A React hook for video.js

NPM JavaScript Style Guide

Install using npm

npm install --save react-videojs-hook
npm install --save video.js

Install using yarn

yarn add react-videojs-hook
yarn add video.js

Usage

import React from 'react';
import { useVideojs } from 'react-videojs-hook';

import 'video.js/dist/video-js.css';

const App = () => {
  const onPlay = (currentTime?: number) => {
    console.log("Video played at: ", currentTime);
  };

  const onPause = (currentTime?: number) => {
    console.log("Video paused at: ", currentTime);
  };

  const onEnd = (currentTime?: number) => {
    console.log(`Video ended at ${currentTime}`);
  };

  const onTimeUpdate = (currentTime: number) => {
    console.log(`Video current time is ${currentTime}`)
  };

  const { vjsId, vjsRef, vjsClassName } = useVideojs({
    src: 'https://www.radiantmediaplayer.com/media/big-buck-bunny-360p.mp4',
    controls: true,
    autoplay: true,
    responsive: true,
    bigPlayButtonCentered: true,
    onPlay,
    onPause,
    onEnd,
    onTimeUpdate,
  });


  // wrap the player in a div with a `data-vjs-player` attribute
  // so videojs won't create additional wrapper in the DOM
  // see https://github.com/videojs/video.js/pull/3856
  return (
    <div data-vjs-player>
      <video ref={vjsRef} id={vjsId} className={vjsClassName}></video>
    </div>
  )
}

Hook Parameters

Param | Description | Required | Default ---- | ----------- | -------- | ------- src | The video source URL | true className | className to customize video player UI | false sources | The sources for a media asset. [{src: 'http://ex.com/video.mp4', type: 'video/mp4'}] | false | false aspectRatio | The value to set the Player's aspect ratio to | false controls | Set to true or false to display native player controls | false | false autoplay | Set the autoplay option, true or false | false | false textTrackSettings | Manipulate Text Tracks settings. | false defaultVolume | Video player initial volume | false | false responsive | Set responsive mode to add and remove classes based on its size breakpoints | false | false responsive | Set responsive mode to add and remove classes based on its size breakpoints | false | false width | Set player width | false | auto height | Set player height | false | auto height | Set player height | false | auto bigPlayButton | Set initial play button that shows before the video has played | false | true onReady | Triggered when player is loaded and ready to play | false onPlay | Triggered when player's play button is clicked | false onPause | Triggered when player's pause button is clicked | false onTimeUpdate | Triggered every time play time updates | false onSeeking | Triggered on player seeking to a different play time | false onSeeked | Triggered on player seeking completion to a different play time | false onEnd | Triggered when video finishes playing | false

How to contribute

To contribute, fork this repo to your private repository and create a pull request based on the feature you want to add.

License

MIT © Hector101