New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@mixwave/player

Package Overview
Dependencies
Maintainers
0
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mixwave/player

Video player controls (React, Tailwind) and an HLS.js facade

latest
Source
npmnpm
Version
1.2.2
Version published
Maintainers
0
Created
Source

@mixwave/player

Player is a collection of React components and a facade for HLS.js, providing a unified API. It streamlines working with HLS.js by handling state management with a strong emphasis on reactivity and it provides a set of methods that make more sense for those building their own player UI.

npm i hls.js@1.6.0-beta.1
npm i @mixwave/player

[!NOTE] Full docs available at https://matvp91.github.io/mixwave/frontend/player.html

We strongly recommend you to go to the documentation link instead of relying on this README.

The components are styled with Tailwind, make sure you have it setup properly. Open your tailwind.config.js file and include the player build.

/** @type {import('tailwindcss').Config} */
module.exports = {
  content: [
    "./src/**/*.{ts,tsx}",
    "./node_modules/@mixwave/player/dist/**/*.{js,ts,jsx,tsx}",
  ],
  // The rest of the config...
};

Pass your HLS.js instance to the facade.

import Hls from "hls.js";
import { HlsFacade } from "@mixwave/player";

const hls = new Hls();
hls.attachMedia(videoElement);

const facade = new HlsFacade(hls);

Render the Controls component in your React setup, as if you would with any other component. Make sure you add the right classes and the data attribute data-mix-container to the container.

import Hls from "hls.js";
import {
  ControllerProvider,
  Controls,
  useController,
} from "@mixwave/player/react";

export function PlayerControls() {
  const [hls] = useState(() => new Hls());
  const controller = useController(hls);

  useEffect(() => {
    if (url) {
      hls.loadSource(url);
    }
  }, [url]);

  return (
    <ControllerProvider controller={controller}>
      <div
        className="relative aspect-video bg-black overflow-hidden rounded-md"
        data-mix-container
      >
        <video
          ref={controller.mediaRef}
          className="absolute inset-O w-full h-full"
        />
        <Controls />
      </div>
    </ControllerProvider>
  );
}

You can now interact with the Hls instance.

hls.loadSource("https://mixwave.stream/playlist/master.m3u8");

The facade greatly simplifies working with HLS.js, you can definitely use it to build your own UI instead.

FAQs

Package last updated on 20 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts