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

use-video-player-hook

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

use-video-player-hook

custom react hook helps to create custom video player

  • 1.0.7
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4
increased by300%
Maintainers
1
Weekly downloads
 
Created
Source

use-video-player

custom react hook helps you to build custome video player

Install

yarn add use-video-player-hook or npm i use-video-player-hook

Usage

 const videoElement = useRef(null);
const {
    playerState,
    togglePlay,
    handleOnTimeUpdate,
    handleVideoProgress,
    handleVideoSpeed,
    toggleMute,
} = useVideoPlayer(videoElement);


return (
    <div>
        <div>
            <video
                src={src}
                ref={videoElement}
                onTimeUpdate={handleOnTimeUpdate}
            />
            <div>
                <button onClick={togglePlay}>
                    {!playerState.isPlaying ? (
                        <span>Play</span>
                    ) : (
                        <span>Pause</span>
                    )}
                </button>
                <input
                    type="range"
                    min="0"
                    max="100"
                    value={playerState.progress}
                    onChange={(e) => handleVideoProgress(e)}
                />
                <select
                    value={playerState.speed}
                    onChange={(e) => handleVideoSpeed(e)}
                >
                    <option value="0.50">0.50x</option>
                    <option value="1">1x</option>
                    <option value="1.25">1.25x</option>
                    <option value="2">2x</option>
                </select>
                <button onClick={toggleMute}>
                    {!playerState.isMuted ? (
                        <span>Mute</span>
                    ) : (
                        <span>Unmute</span>
                    )}
                </button>
            </div>
        </div>
    </div>
);

All you need is to pass videoElement ref as a parameter

     const videoElement = useRef(null);
     const {
      playerState,
      togglePlay,
      handleOnTimeUpdate,
      handleVideoProgress,
      handleVideoSpeed,
      toggleMute,
    } = useVideoPlayer(videoElement);

Metadata

package on npm https://npmjs.com/package/use-video-player-hook

Show your support

Give a ⭐️ if this project helped you!

Keywords

FAQs

Package last updated on 12 Aug 2022

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