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

apnaytplayer

v1.0.0

Published

A lightweight, feature-rich React component for embedding YouTube videos with thumbnail overlay, interactive seek controls, and comprehensive video metadata support

Readme

ApnaYT - Custom YouTube Player

A lightweight, feature-rich React component for embedding YouTube videos with complete control. Includes built-in thumbnail overlay, interactive seek controls, and comprehensive video metadata support.

Installation

npm install apnaytplayer

or

yarn add apnaytplayer

Quick Start

import React, { useRef } from 'react';
import { ApnaYT, ApnaYTRef, ApnaYTConfig } from 'apnaytplayer';
import 'apnaytplayer/ApnaYT.css';

function MyPlayer() {
  const playerRef = useRef<ApnaYTRef>(null);

  const config: ApnaYTConfig = {
    videoId: 'dQw4w9WgXcQ',
    autoplay: false,
    muted: false,
    controls: 0,
    width: '100%',
    height: '500px',
  };

  return (
    <>
      <ApnaYT
        ref={playerRef}
        config={config}
        onReady={() => console.log('Ready!')}
        onPlay={() => console.log('Playing')}
        onPause={() => console.log('Paused')}
        onTimeUpdate={(current, duration) => {
          console.log(`Time: ${current}/${duration}`);
        }}
      />

      <button onClick={() => playerRef.current?.play()}>Play</button>
      <button onClick={() => playerRef.current?.pause()}>Pause</button>
    </>
  );
}

Features

Thumbnail Overlay - Shows video thumbnail when paused/stopped
🎮 Interactive Controls - Click to play/pause, double-click to seek ±10s
📊 Video Metadata - Get video info, channel details, views, and likes
🎨 Customizable - Full control over styling and behavior
🔧 Full API Access - All YouTube IFrame API methods via ref
📡 Complete Events - onPlay, onPause, onTimeUpdate, onVolumeChange, etc.

Config Options

interface ApnaYTConfig {
  videoId: string;
  autoplay?: boolean;
  muted?: boolean;
  loop?: boolean;
  controls?: 0 | 1;
  rel?: 0 | 1;
  modestbranding?: 0 | 1;
  iv_load_policy?: 1 | 3;
  fs?: 0 | 1;
  cc_load_policy?: 0 | 1;
  playsinline?: 0 | 1;
  disablekb?: 0 | 1;
  width?: string | number;
  height?: string | number;
}

Methods (via ref)

// Playback Control
playerRef.current?.play();
playerRef.current?.pause();
playerRef.current?.stop();
playerRef.current?.seekTo(30, true);

// Time Information
playerRef.current?.getCurrentTime();
playerRef.current?.getDuration();

// Volume Control
playerRef.current?.setVolume(75);
playerRef.current?.getVolume();
playerRef.current?.mute();
playerRef.current?.unMute();
playerRef.current?.isMuted();

// Playback Rate
playerRef.current?.setPlaybackRate(1.5);
playerRef.current?.getPlaybackRate();

// Player State
playerRef.current?.getPlayerState();

// Quality Control
playerRef.current?.getAvailableQualityLevels();
playerRef.current?.setPlaybackQuality('hd720');
playerRef.current?.getPlaybackQuality();

// Video Information
playerRef.current?.getInfo();
// Returns: Promise<{
//   videoId: string;
//   title: string;
//   url: string;
//   embedCode: string;
//   thumbnail: {
//     default: string;
//     mqdefault: string;
//     hqdefault: string;
//     sddefault: string;
//     maxresdefault: string;
//   };
//   channel?: {
//     channelId: string;
//     channelName: string;
//     channelUrl: string;
//     channelLogo?: string;
//     subscriberCount?: string;
//   };
//   stats?: {
//     viewCount?: string;
//     likeCount?: string;
//   };
// } | null>

// Cleanup
playerRef.current?.destroy();

Events

<ApnaYT
  ref={playerRef}
  config={config}
  className=""
  style={{}}
  onReady={() => {}}
  onPlay={() => {}}
  onPause={() => {}}
  onEnd={() => {}}
  onStateChange={(state) => {}}
  onTimeUpdate={(currentTime, duration) => {}}
  onVolumeChange={(volume) => {}}
  onError={(errorCode) => {}}
  onPlaybackQualityChange={(quality) => {}}
/>

Interactive Controls

The player includes built-in interactive controls:

  • Single Click: Toggle play/pause (anywhere on player)
  • Double Click Left: Seek backward 10 seconds
  • Double Click Right: Seek forward 10 seconds
  • Thumbnail Overlay: Automatically shows when video is paused/stopped

Video Information

The getInfo() method returns comprehensive video and channel information:

const info = await playerRef.current?.getInfo();

if (info) {
  console.log(info.title);
  console.log(info.thumbnail.maxresdefault);
  
  if (info.channel) {
    console.log(info.channel.channelName);
    console.log(info.channel.subscriberCount);
  }
  
  if (info.stats) {
    console.log(info.stats.viewCount);
    console.log(info.stats.likeCount);
  }
}

Example with Custom Controls

import React, { useRef, useState } from 'react';
import { ApnaYT, ApnaYTRef, ApnaYTConfig } from 'apnaytplayer';
import 'apnaytplayer/ApnaYT.css';

function CustomPlayer() {
  const playerRef = useRef<ApnaYTRef>(null);
  const [currentTime, setCurrentTime] = useState(0);
  const [duration, setDuration] = useState(0);
  const [volume, setVolume] = useState(100);
  const [isPlaying, setIsPlaying] = useState(false);
  const [videoInfo, setVideoInfo] = useState(null);

  const config: ApnaYTConfig = {
    videoId: 'dQw4w9WgXcQ',
    controls: 0,
    width: '100%',
    height: '500px',
  };

  return (
    <>
      <ApnaYT
        ref={playerRef}
        config={config}
        onReady={async () => {
          const vol = playerRef.current?.getVolume() || 100;
          setVolume(vol);
          
          const info = await playerRef.current?.getInfo();
          setVideoInfo(info);
        }}
        onPlay={() => setIsPlaying(true)}
        onPause={() => setIsPlaying(false)}
        onTimeUpdate={(current, total) => {
          setCurrentTime(current);
          setDuration(total);
        }}
        onVolumeChange={(vol) => setVolume(vol)}
      />

      <div>
        <button onClick={() => playerRef.current?.play()}>Play</button>
        <button onClick={() => playerRef.current?.pause()}>Pause</button>
        <div>
          {Math.floor(currentTime)}s / {Math.floor(duration)}s
        </div>
        <input
          type="range"
          min="0"
          max={duration || 100}
          value={currentTime}
          onChange={(e) => playerRef.current?.seekTo(parseFloat(e.target.value))}
        />
        <input
          type="range"
          min="0"
          max="100"
          value={volume}
          onChange={(e) => playerRef.current?.setVolume(parseInt(e.target.value))}
        />
      </div>

      {videoInfo && (
        <div>
          <h3>{videoInfo.title}</h3>
          {videoInfo.channel && (
            <p>Channel: {videoInfo.channel.channelName}</p>
          )}
          {videoInfo.stats && (
            <p>
              Views: {videoInfo.stats.viewCount} | 
              Likes: {videoInfo.stats.likeCount}
            </p>
          )}
        </div>
      )}
    </>
  );
}

Getting Video ID

To get the video ID from a YouTube URL:

  • URL: https://www.youtube.com/watch?v=dQw4w9WgXcQ
  • Video ID: dQw4w9WgXcQ

License

MIT