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

react-shaka-plyr

v1.1.0

Published

shaka player wrapped react component

Downloads

6

Readme

react-shaka-plyr

This project is Shaka Player wrapped react component

Before starting, please read the documents related to Shaka Player first.

I'm inspired by react-use - useVideo Hooks and Headless UI Component, and try to keep the interface similar to those libraries.

Installation

/* recommended */
yarn add react-shaka-plyr
// or
npm install react-shaka-plyr

Usage

Free m3u8 streams

import React from "react";
import { useRef } from "react";
import {
  ShakaPlayer,
  ShakaPlayerProvider,
  ShakaControlsRef,
  useShakaState
} from "react-shaka-plyr";

const App = () => {
  return (
    <ShakaPlayerProvider>
      <Player />
    </ShakaPlayerProvider>
  );
};

const Player = () => {
  const state = useShakaState();
  const ref = useRef<ShakaControlsRef>(null);

  return (
    <>
      <ShakaPlayer
        ref={ref}
        src="http://sample.vodobox.net/skate_phantom_flex_4k/skate_phantom_flex_4k.m3u8"
      />
      {Object.entries(state).map(([key, value]) => {
        return (
          <div key={key} style={{ display: "flex", gap: 8 }}>
            <span>{key}</span>
            <span>{String(value)}</span>
          </div>
        );
      })}
      <button onClick={() => ref.current?.pause()}>Pause</button>
      <button onClick={() => ref.current?.play()}>Play</button>
      <br />
      <button onClick={() => ref.current?.mute()}>Mute</button>
      <button onClick={() => ref.current?.unmute()}>Un-mute</button>
      <br />
      <button onClick={() => ref.current?.volume(0.1)}>Volume: 10%</button>
      <button onClick={() => ref.current?.volume(0.5)}>Volume: 50%</button>
      <button onClick={() => ref.current?.volume(1)}>Volume: 100%</button>
      <br />
      <button onClick={() => ref.current?.seek(state.time - 5)}>-5 sec</button>
      <button onClick={() => ref.current?.seek(state.time + 5)}>+5 sec</button>
    </>
  );
};

To customize the controller, use the following options Reference: Shaka Player Customizing the UI

    <ShakaPlayer
      ref={ref}
      src="http://sample.vodobox.net/skate_phantom_flex_4k/skate_phantom_flex_4k.m3u8"
      uiConfig={{ controlPanelElements: [], addSeekBar: false }}
      style={{ position: "relative" }}
    >
        <button
          style={{ position: "absolute" }}
          onClick={() => ref.current?.play()}
        >
          Play
        </button>
        ...
    </ShakaPlayer>

Props

By default, ShakaPlayer component props inherit HTMLVideoElement attributes. ex: src, autoPlay, muted, loop, onLoad, onTimeupdate... | Props | Optional | Description | Type | | -------- | -------- | -------------------------------------------------------------------------------------------------------------- | --------------------------------- | | config | true | shaka player config object | | | uiConfig | true | shaka player ui config object | | | ref | true | A ref object for player control | React.RefObject |

Issue & Contribution

Please feel free to pull request. The issue issue is also the same.