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

reactjs-video-playlist-player

v1.1.1

Published

A React component that allows you to play a list of videos

Downloads

11

Readme

reactjs-video-playlist-player

A React component that allows you to play and control a playlist of videos

NPM JavaScript Style Guide License: MIT

Install

npm install --save reactjs-video-playlist-player

Demo

This demo site was built using Github Pages Demo site

alt text

The demo videos are coming from here https://gist.github.com/jsturgis/3b19447b304616f18657

Usage

import React, { Component } from "react";

import {
  Playlist,
  goToNextVideo,
  goToPreviousVideo
} from "reactjs-video-playlist-player";

function App() {
  const [videoList, setVideoList] = useState([
    {
      thumbnail: "https://via.placeholder.com/500/FFA500/FFFFFF",
      url:
        "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4",
      imgAlt: "Image 1 not found"
    },
    {
      thumbnail: "https://via.placeholder.com/500/FF0000/FFFFFF",
      url:
        "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/Sintel.mp4",
      imgAlt: "Image 2 not found"
    },
    {
      thumbnail: " ",
      url:
        "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ForBiggerEscapes.mp4",
      imgAlt: "Image 3 not found"
    },
    {
      thumbnail: "https://via.placeholder.com/500/FFFF00/000000",
      url:
        "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ForBiggerBlazes.mp4",
      imgAlt: "Image 4 not found"
    },
    {
      thumbnail: "",
      url:
        "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ForBiggerJoyrides.mp4",
      imgAlt: "Image 5 not found"
    }
  ]);

  const [currentVideo, setCurrentVideo] = useState(0);
  const vidRef = createRef(null);

  const params = {
    videos: list,
    autoPlay: true,
    showQueue: true,
    playForward: true,
    defaultQueueItemPlaceholderThumbnail: videoPlaceHolder,
    currentVideo: currentVideo,
    setCurrentVideo: setCurrentVideo,
    vidRef: vidRef
  };

  return (
    <div className="App">
      <h3 id="title">
        <span>React.js</span> video playlist player 🎥
      </h3>
      <div>
        <Playlist playlistParams={params} />
      </div>
    </div>
  );
}

export default App;

Params object

  const params = {
    videos: list,
    autoPlay: true,
    showQueue: true,
    playForward: true,
    defaultQueueItemPlaceholderThumbnail: videoPlaceHolder,
    currentVideo: currentVideo,
    setCurrentVideo: setCurrentVideo,
    vidRef: vidRef
  }

| parameter | description | | ------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------- | | videos | list of videos [{thumbnail : "", url : ""}] | | autoplay | videos in the playlist play one after the other without user interaction (true) or (false) | | showQueue | show videos queue (true) or (false) | | playForward | play videos by incrementing (true) or (false) | | defaultQueueItemPlaceholderThumbnail | image to display if thumbnail is not provided in video object ("/path/to/video") | | currentVideo | state variable that contains the currently selected video in the playlist (const [currentVideo , setCurrentVideo] = useState(0)) | | setCurrentVideo | function that updates the state variable that contains the currently selected video playlist (const [ currentVideo,setCurrentVideo] = useState(0)) | | vidRef | video ref (constvidRef= createRef(null)) |

Video object

{
  thumbnail: "",
  url: "",
  imgAlt: ""
},

| parameter | description | | --------- | ---------------------------------------------------------------- | | thumbnail | link ok thumbnail image of video in videos queue | | url | link of video | | imgAlt | Text to display if thumbnail link is not working (alt attribute) |

Methods

goToPreviousVideo Direction depends on the playForward parameter

goToPreviousVideo(params)

goToNextVideo Direction depends on the playForward parameter

goToNextVideo(params)

Styling

Create a css file add the classes below and import it

  • video-container-styles
  • video-styles
  • playlist-queue-styles
  • playlist-queue-item-styles
  • current-playing-video-styles (Only the currently selected item in the list of videos has this class)
  • thumbnail-styles

The image below describes the markup of the component and the relationship between the CSS classes

alt text

CSS Example

.video-container-styles {
  width: 60%;
  margin: 0 auto;
}

.playlist-queue-styles {
  box-shadow: 0px 0px 1px white;
  display: flex;
  align-items: center;
  overflow-x: auto;
  background-color: #212836;
}

.playlist-queue-item-styles {
  margin: 5px;
  cursor: pointer;
  min-width: 60px;
  max-width: 60px;
  min-height: 60px;
  max-height: 60px;
  display: flex;
  justify-content: center;
  align-items: center;
  border: 4px solid transparent;
}

.current-playing-video-styles {
  box-shadow: 0px 0px 2px white;
  transition: 0.2s;
}

.thumbnail-styles {
  width: 100%;
  height: 100%;
}

.video-styles {
  width: 100%;
  height: 500px;
  object-fit: cover;
}

@media screen and (max-width: 549px) {
  .video-container-styles {
    width: 100%;
  }
}

License

The code in this project is licensed under the MIT license

Author

AmineAboutaieb