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-webgl-video-manager

v0.1.0

Published

Centralized video playback controls for applications built on top of React WebGL

Downloads

3

Readme

React WebGL Video Manager

react-webgl-video-manager is a centralized video manager that uses webgl-ui for easy control and playback of videos in WebGL contexts. It is designed to fit into the render loop of a React WebGL application, though it can also be used on its own.

The Video Manager allows you to load videos and control their playback via play, pause, seek, and other actions. It hooks directly into the TextureManager from webgl-ui using a custom protocol, allowing React WebGL image components to play videos using a video:// URL.

From your Video Manager, you can create individual Video Players that each handle the playback of a single video. A single player can be referenced multiple times within your app, much like how a single computer can be attached to multiple monitors.

Using the Video Manager

Your application should have a single VideoManager instance. This is where you will create and fetch individual players.

To construct a Video Manager, you need a reference to your webgl-ui texture manager. If you're using webgl-ui on its own, this is the instance you use to construct individual Image elements. If you're using react-webgl, you can get this from your CanvasRoot or RenderTargetRoot.

Actual playback is handled by implementations that decode video to a texture that can be rendered in WebGL. The package comes with a browser-based implementation that should cover most playback cases. If you have custom video decoding logic, like streaming video, you can create and register your own implementation.

import {VideoManager, BrowserVideoImplementation} from 'react-webgl-video-manager';

// ...

// Get the texture manager from your React WebGL root
const textureManager = root.getTextureManager();
const videos = new VideoManager(textureManager);

// From here, you can create individual players, and hook up React WebGL image
// components to those videos

Creating a video instance

To play a video, you must first create a player. Each player has a unique name, which is how it is referenced from your components.

const player = videos.createPlayer('birds-footage');
// player can now be controlled
player.setSource('https://example.net/birds.webm');
player.play();

// At any point in time, you can also retrieve the player by its name
const playerAgain = videos.getPlayer('birds-footage');
playerAgain.seekTo(14);
playerAgain.pause();

Referencing a video from react-webgl or webgl-ui

React WebGL Example

// point the <image /> to a video:// URI with your video's name
<image source={{uri: 'video://birds-footage'}} width={320} height={180} />

WebGL UI Example

const image = new Image(textureManager);
setStyle(image, {
  width: 320,
  height: 160,
});
// point the image to a video:// URI with your video's name
image.setSource({uri: 'video://birds-footage'});