0.1.0 • Published 8 months ago

react-sproutvideo v0.1.0

Weekly downloads
-
License
ISC
Repository
github
Last release
8 months ago

SproutVideo React Implementation

This is a typescript-safe React version of SproutVideo API. It allows you to embed SV videos as a React component and use in your project (via iframes).

Installation

npm install react-sproutvideo

Usage

Import the video object

// import at the top of the file
import {
  SproutVideoPlayer,
  type SproutVideoPlayerRef,
} from "react-sproutvideo";

export function MyVideoPlayer() {
  // create a ref to have custom controls over the video
  const videoRef = useRef<SproutVideoPlayerRef>(null);

  // render in your component
  return (
    <>
      <SproutVideoPlayer
        id="123123"
        url="https://videos.sproutvideo.com/embed/123123/456456456"
        ref={videoRef}
      />

      <button onClick={() => videoRef.current?.play()}>Play</button>
    </>
  );
}

Props

<SproutVideoPlayer
  id="123123123" // video ID
  url="https://videos.sproutvideo.com/embed/123123123/321321312" // embed Link, can contain other settings from Sprout
  className="w-[700px] h-[400px]" // className for video container, by default invisible unless you give it dimentions
  styles={{}} // same as above, I'm using Tailwind in the example
  ref={videoRef} // videoRef object
  onVideoReady={() => {
    // on video ready callback, in this case used to autoplay the video
    console.log("video ready");
    videoRef.current?.play();
  }}
/>

Contibuting

All the contributions are welcome, please let me know if you want any additional features through issues.

0.1.0

8 months ago

0.0.6

9 months ago

0.0.5

9 months ago

0.0.4

9 months ago

0.0.3

9 months ago

0.0.2

9 months ago

0.0.1

9 months ago