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

@theoplayer/react-ui

v1.9.0

Published

React component library for the THEOplayer Web SDK

Downloads

2,124

Readme

THEOplayer Open Video UI for React ⚛️

NPM version Build status API docs GitHub issues

A React component library for building a world-class video player experience powered by the THEOplayer Web SDK.

  • Use the default UI for a great out-of-the-box experience, or use the individual components to build your own custom UI.
  • Idiomatic React components make the UI feel right at home in your existing React web app.
  • Easy to customize: use JSX to lay out your controls, and CSS to style them.

Installation

  1. This project requires the THEOplayer Web SDK to be installed.
    npm install theoplayer
    You can also install a different variant of the THEOplayer npm package if you don't need all features, as long as it's aliased as theoplayer.
    npm install theoplayer@npm:@theoplayer/basic-hls
  2. Install the Open Video UI for React.
    npm install @theoplayer/react-ui
  3. Add @theoplayer/react-ui to your app:
    import { DefaultUI } from '@theoplayer/react-ui';
    Open Video UI will import THEOplayer from theoplayer/chromeless. If you're using a bundler such as Webpack or Rollup, this dependency should automatically get bundled with your web app.

Usage

Default UI

<DefaultUI> provides a fully-featured video player experience with minimal setup, and allows for small customizations such as changing colors or fonts.

import { DefaultUI } from '@theoplayer/react-ui';
import type { ChromelessPlayer } from 'theoplayer/chromeless';

const App = () => {
    // Configure THEOplayer
    const configuration = {
        libraryLocation: '/path/to/node_modules/theoplayer/',
        license: 'your_theoplayer_license_goes_here'
    };
    // Configure a source for the player to play
    const source = {
        sources: {
            src: 'https://example.com/stream.m3u8'
        }
    };
    // Optionally, access the underlying THEOplayer player instance
    const onReady = (player: ChromelessPlayer) => {
        player.addEventListener('playing', () => console.log('THEOplayer is now playing'));
    };

    return <DefaultUI configuration={configuration} source={source} onReady={onReady} />;
};

See default-ui/demo.html for a complete example.

Custom UI

If you want to fully customize your video player layout, you can use a <UIContainer> instead.

import { ControlBar, MuteButton, PlayButton, TimeRange, VolumeRange } from '@theoplayer/react-ui';

const App = () => {
    const configuration = {
        libraryLocation: '/path/to/node_modules/theoplayer/',
        license: 'your_theoplayer_license_goes_here'
    };
    const source = {
        sources: {
            src: 'https://example.com/stream.m3u8'
        }
    };

    return (
        <UIContainer
            configuration={configuration}
            source={source}
            bottomChrome={
                <>
                    {/* Choose your own layout using the provided components (or your own!) */}
                    <ControlBar>
                        <TimeRange />
                    </ControlBar>
                    <ControlBar>
                        <PlayButton />
                        <MuteButton />
                        <VolumeRange />
                    </ControlBar>
                </>
            }
        />
    );
};

See custom-ui/demo.html for a complete example.

Legacy browser support

By default, Open Video UI for React targets modern browsers that support modern JavaScript syntax (such as async/await) and native Custom Elements. This keeps the download size small, so your viewers can spend less time waiting for your page to load and start watching their video faster.

On older browsers (such as Internet Explorer 11 and older smart TVs), you need to load a different version of the Open Video UI that uses older JavaScript syntax. You also need to load additional polyfills for missing features such as Promises or Custom Elements. We recommend the Cloudflare mirror of Polyfill.io and Web Components Polyfills for these.

The simplest way to do this is to load the legacy build instead:

import '@webcomponents/webcomponentsjs/custom-elements-es5-adapter.js';
import '@webcomponents/webcomponentsjs/webcomponents-bundle.js';
import { DefaultUI } from '@theoplayer/react-ui/es5'; // note the "/es5" suffix

However, this will load unnecessary polyfills in modern browsers, which is suboptimal. Instead, we recommend configuring your bundler to produce a modern and legacy build of your entire web app, and to import the appropriate version of Open Video UI for each build flavor.