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

@triyanox/react-video

v0.1.9

Published

A video component for react inspired by the ios video player

Downloads

24

Readme

@triyanox/react-video a unified customizable video playback experience across all browsers for react

Introduction

The @triyanox/react-video component is a highly customizable and easy-to-use React component for playing video content in your react applications inspired by apple tv video player. It offers extensive control over video playback and is fully compatible with TailwindCSS, allowing for seamless styling integration.

Installation

To install the component, use the following command:

pnpm add @triyanox/react-video

Usage

Basic Usage

You can use the video component simply by importing Video from the package

import { Video } from "@triyanox/react-video";

export default function Page() {
 return (
   <Video
   src="https://vjs.zencdn.net/v/oceans.mp4"
   />
)}

Options

  • src: VideoSource: The source of the video. This can be either a string URL or an array of objects containing src, type, and label fields.

    • Example:
      [
        { src: 'https://example.com/video.mp4', type: 'video/mp4', label: 'SD' },
        { src: 'https://example.com/video.mp4', type: 'video/mp4', label: 'HD' }
      ]
      // or
      'https://example.com/video.mp4'
  • poster?: string: URL of the video's poster image.

    • Example: 'https://example.com/poster.jpg'
  • title?: string: Title of the video.

    • Example: 'Video title'
  • subtitle?: string: Subtitle of the video.

    • Example: 'Video subtitle'
  • Event Handlers:

    • onProgress?: (currentTime: number) => void: Called when the video progress changes.
    • onDuration?: (duration: number) => void: Called when the video duration is available.
    • onEnded?: () => void: Called when the video ends.
    • onPlay?: () => void: Called when the video is played.
    • onPause?: () => void: Called when the video is paused.
    • onLoad?: () => void: Called when the video is loaded.
    • onVolumeChange?: (volume: number) => void: Called when the volume changes.
    • onPlaybackRateChange?: (playbackRate: number) => void: Called when the playback rate changes.
  • Styling and Layout:

    • className?: string: Root CSS class for custom styling.
    • classNames?: object: Object containing CSS classes for various elements (title, subtitle, wrappers, video, backdrop, sliders).
  • Playback Control:

    • autoPlay?: boolean: If true, the video will start playing as soon as it is ready.
    • loop?: boolean: If true, the video will loop continuously.
    • showControls?: boolean: If true, video controls will be displayed.
    • icons?: object: Custom icons for various video controls (play, pause, forward, etc.).
  • Additional Options:

    • hideSliderThumb?: boolean: If true, hides the slider thumb.

Example

import React from 'react';
import { Video } from '@triyanox/react-video';

// Import custom icons (assuming these are available in your project)
import {
  CustomPlayIcon,
  CustomPauseIcon,
  CustomForwardIcon,
  CustomBackwardIcon,
  CustomEnterPipIcon,
  CustomExitPipIcon,
  CustomVolumeIcon,
  CustomFullScreenIcon,
  CustomExitFullScreenIcon,
  CustomLoadingIcon,
} from './YourIconPath';

const MyVideoComponent = () => {
  const videoProps = {
    src: [
      {
        src: 'https://example.com/video-sd.mp4',
        type: 'video/mp4',
        label: 'SD',
      },
      {
        src: 'https://example.com/video-hd.mp4',
        type: 'video/mp4',
        label: 'HD',
      },
    ],
    poster: 'https://example.com/poster.jpg',
    title: 'My Amazing Video',
    subtitle: 'An insightful subtitle',
    onProgress: currentTime => console.log(`Current Time: ${currentTime}`),
    onDuration: duration => console.log(`Duration: ${duration}`),
    onEnded: () => console.log('Video Ended'),
    onPlay: () => console.log('Video Played'),
    onPause: () => console.log('Video Paused'),
    onLoad: () => console.log('Video Loaded'),
    onVolumeChange: volume => console.log(`Volume: ${volume}`),
    onPlaybackRateChange: rate => console.log(`Playback Rate: ${rate}`),
    className: 'custom-video-class',
    autoPlay: true,
    loop: true,
    showControls: true,
    icons: {
      play: CustomPlayIcon,
      pause: CustomPauseIcon,
      forwardBy10: CustomForwardIcon,
      backBy10: CustomBackwardIcon,
      enterPip: CustomEnterPipIcon,
      exitPip: CustomExitPipIcon,
      volume: CustomVolumeIcon,
      fullScreen: CustomFullScreenIcon,
      exitFullScreen: CustomExitFullScreenIcon,
      loading: CustomLoadingIcon,
    },
    classNames: {
      base: 'video-base-class',
      title: 'video-title-class',
      subtitle: 'video-subtitle-class',
      topWrapper: 'top-wrapper-class',
      centerWrapper: 'center-wrapper-class',
      bottomWrapper: 'bottom-wrapper-class',
      video: 'video-element-class',
      backdrop: 'video-backdrop-class',
      volumeSlider: {
        root: 'volume-slider-root-class',
        track: 'volume-slider-track-class',
        thumb: 'volume-slider-thumb-class',
        range: 'volume-slider-range-class',
      },
      playbackRateSlider: {
        root: 'playback-rate-slider-root-class',
        track: 'playback-rate-slider-track-class',
        thumb: 'playback-rate-slider-thumb-class',
        range: 'playback-rate-slider-range-class',
      },
    },
    hideSliderThumb: false,
  };

  return <Video {...videoProps} />;
};


export default MyVideoComponent;

Customization

The video component is fully customizable using TailwindCSS. You can use the className and classNames props to apply your TailwindCSS classes for styling the video player as per your design requirements.