interactive-react-player
TypeScript icon, indicating that this package has built-in type declarations

0.2.2 • Public • Published

Setup instructions

  1. Install the npm package
npm install interactive-react-player
  1. Use the below boilerplate react code as a reference to setup the interactive component
import React from "react";
import { InteractivePlayer } from "interactive-react-player";
import axios from "axios";

const App = () => {
  const [videoData, setVideoData] = React.useState({});
  const [canvasWidth, setCanvasWidth] = React.useState(window.innerWidth);
  const [canvasHeight, setCanvasHeight] = React.useState(window.innerHeight);
  const params = {
    url: process.env.VIDEO_URL,
    key: process.env.API_KEY,
  };
  const apiUrl: any = process.env.API_URL;
  React.useEffect(() => {
    axios
      .get(apiUrl, {
        params: params,
      })
      .then((res) => {
        const data = res.data;
        setVideoData(data);
        if (!data.showControls) {
          setCanvasHeight(canvasHeight * 0.97);
        } else {
          setCanvasHeight(canvasHeight * 0.93);
        }
      })
      .catch((err) => {
        console.log(err);
      });
  }, []);
  return (
    <>
      <InteractivePlayer
        canvasHeight={canvasHeight}
        canvasWidth={canvasWidth}
        videoData={videoData}
      />
    </>
  );
};
  1. The following environment variables can be found in interactive video applications
  process.env.VIDEO_URL,
  process.env.API_KEY,
  process.env.API_URL;

Package Sidebar

Install

npm i interactive-react-player

Weekly Downloads

1

Version

0.2.2

License

ISC

Unpacked Size

358 kB

Total Files

21

Last publish

Collaborators

  • ritwik1233