1.0.0 • Published 3 months ago

react-video-poup v1.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
3 months ago

React Advanced Video Player

A customizable React video player supporting both regular videos and YouTube embeds.

Features

  • Support for regular video files and YouTube videos
  • Customizable play button
  • Fullscreen support
  • Keyboard shortcuts
  • Automatic controls hiding
  • Progress bar with seeking
  • Time display
  • Mute/unmute functionality

Installation

npm install react-advanced-video-player
# or
yarn add react-advanced-video-player

Usage

import React, { useState } from 'react';
import { VideoPlayer } from 'react-advanced-video-player';

const MyComponent = () => {
  const [isOpen, setIsOpen] = useState(false);

  return (
    <div>
      <button onClick={() => setIsOpen(true)}>
        Open Video
      </button>

      <VideoPlayer
        videoSrc="https://example.com/video.mp4"
        isOpen={isOpen}
        onClose={() => setIsOpen(false)}
        title="My Awesome Video"
      />
    </div>
  );
};

YouTube Support

<VideoPlayer
  videoSrc="https://www.youtube.com/watch?v=dQw4w9WgXcQ"
  isYouTube={true}
  isOpen={isOpen}
  onClose={() => setIsOpen(false)}
  title="YouTube Video"
/>

Custom Play Button

<VideoPlayer
  videoSrc="https://example.com/video.mp4"
  isOpen={isOpen}
  onClose={() => setIsOpen(false)}
  customPlayButton={
    <div className="my-custom-button">
      <span>PLAY</span>
    </div>
  }
/>

Props

PropTypeDescription
videoSrcstringURL of the video or YouTube link
isOpenbooleanWhether the video modal is open
onClosefunctionFunction to call when the modal is closed
isYouTubebooleanWhether the video is a YouTube video
youtubeOptionsobjectOptions for the YouTube player
customPlayButtonReactNodeCustom play button component
titlestringTitle displayed in the header

Keyboard Shortcuts

  • Space / K: Play/Pause
  • M: Mute/Unmute
  • F: Toggle Fullscreen
  • ESC: Close video (when not in fullscreen)

License

MIT