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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@dafilabs/react-video-compare

v0.0.5

Published

sync video player with comparison slider could be useful to compare before and after of videos

Readme

Synchronized Video Component Documentation

newgif-ezgif com-video-to-gif-converter

Overview

The SynchronizedVideo component is a React component that allows side-by-side video comparison with synchronized playback, custom controls, and advanced caching mechanisms.

Features

  • Side-by-side video comparison using ReactCompareSlider
  • Synchronized video playback
  • Custom video controls
  • Video caching mechanism
  • Extensive customization options
  • Responsive design
  • Error handling

Installation Requirements

  • React
  • Next.js
  • react-compare-slider
  • lucide-react

Props Interface

interface SynchronizedVideoProps {
  src1: string;                     // First video source URL
  src2: string;                     // Second video source URL
  type: string;                     // Video type
  width?: string;                   // Video width
  height?: string;                  // Video height
  className1?: string;              // CSS class for first video
  className2?: string;              // CSS class for second video
  isPause?: boolean;                // Initial pause state
  isMute?: boolean;                 // Initial mute state
  fallbackSrc?: string;             // Fallback video source
  label1Text?: string;              // Label for first video
  label2Text?: string;              // Label for second video
  
  // Styling Props
  textStyleLabel1?: string;
  textStyleLabel2?: string;
  progressBarBackgroundColor?: string;
  progressBarFilledColor?: string;
  controlBarBackgroundColor?: string;
  controlButtonColor?: string;
  controlButtonHoverColor?: string;
  timeTextColor?: string;
  volumeSliderThumbColor?: string;
  controlbarwidth?: string;
}

Key Features Breakdown

1. Video Caching

  • Implements a sophisticated video caching mechanism
  • Uses Map to store video URLs and reference counts
  • Prevents unnecessary network requests
  • Automatically releases cached resources when no longer needed

2. Video Synchronization

  • Ensures both videos remain in sync
  • Handles play/pause states across both videos
  • Manages video playback during tab visibility changes

3. Custom Controls

  • Play/Pause button
  • Progress bar with seek functionality
  • Volume control
  • Mute/Unmute toggle
  • Time display

4. Error Handling

  • Graceful error display if video loading fails
  • Fallback video support

Usage Example

<SynchronizedVideo 
  src1="/path/to/video1.mp4"
  src2="/path/to/video2.mp4"
  type="video/mp4"
  width="500px"
  height="300px"
  isPause={false}
  label1Text="Before"
  label2Text="After"
  controlBarBackgroundColor="bg-gray-800"
  progressBarFilledColor="bg-blue-500"
/>

Performance Considerations

  • Uses useRef for efficient DOM manipulation
  • Implements cleanup mechanisms in useEffect
  • Caches video URLs to reduce network requests
  • Handles tab visibility to optimize resource usage

Customization

The component offers extensive customization through props:

  • Video dimensions
  • Playback state
  • Control styling
  • Label styling
  • Color schemes

Browser Compatibility

  • Requires modern browsers supporting URL.createObjectURL()
  • Works best with Next.js React applications

Potential Improvements

  • Add keyboard navigation support
  • Implement fullscreen mode
  • Add playback speed controls
  • Enhance error handling

Dependencies

  • React
  • Next.js Image component
  • react-compare-slider
  • lucide-react icons

Accessibility Considerations

  • Provides alternative fallback video
  • Uses semantic HTML5 video elements
  • Supports muting and volume control

TypeScript Support

Full TypeScript support with comprehensive prop typing.