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

@rajeev02/media

v0.2.1

Published

Unified Media Player Engine — adaptive streaming, PiP, offline download, DRM, Hotstar/Netflix style

Readme

@rajeev02/media

npm version license

Unified media player & download manager with adaptive streaming (HLS/DASH), Picture-in-Picture, Chromecast/AirPlay, DRM (Widevine/FairPlay), quality selection, and offline downloads.

Part of Rajeev SDK — cross-platform infrastructure libraries for building apps that work everywhere.

Why use this?

  • Adaptive streaming — HLS & DASH with automatic quality switching based on bandwidth
  • DRM support — Widevine (Android/Web) and FairPlay (iOS) for premium content protection
  • Picture-in-Picture — Floating video player while using other apps
  • Casting — Chromecast and AirPlay integration with unified API
  • Offline downloads — Background download with pause/resume, progress tracking, storage limits
  • Resume playback — Automatic resume from last position across sessions
  • Playback speed — 0.5x to 3x speed with pitch correction

⚠️ Important: Native Media Player Required

This library provides the playback state machine, download manager, and quality selection logic. It does NOT render video/audio or decode media formats.

You need a native media player to pair with:

| Environment | Recommended library | | ----------------- | ---------------------------------------------------------------------------------------------------------------------------------- | | Expo | expo-av | | Bare React Native | react-native-video | | Web | HTML5 <video> with hls.js / dash.js |

DRM: If you use DRM-protected content, you must provide a license server URL:

Casting: Chromecast/AirPlay config types are provided, but actual casting requires native cast SDK setup in your app.

Streaming: Your HLS/DASH streams need a media server or CDN (AWS CloudFront, Mux, Cloudflare Stream, etc.).

What this library provides: Player state management (play/pause/seek/quality), download tracking with pause/resume, resume-from-last-position, and subtitle/audio track selection. Your native player handles the actual media rendering.

Platform Support

| Platform | Engine | Status | | ---------- | ---------- | ------ | | iOS 16+ | TypeScript | ✅ | | Android 7+ | TypeScript | ✅ | | Web | TypeScript | ✅ |

Installation

npm install @rajeev02/media

Peer Dependencies

  • react >= 18.3.0
  • react-native >= 0.84.0 (optional)

Quick Start

Media Player

import { MediaPlayerController } from "@rajeev02/media";

const player = new MediaPlayerController({
  autoPlay: true,
  enablePiP: true,
  enableCast: true,
});

// Load a video with DRM
player.load({
  uri: "https://stream.example.com/video.m3u8",
  type: "video",
  title: "My Movie",
  drm: {
    type: "widevine",
    licenseServerUrl: "https://drm.example.com/license",
  },
});

// Listen for events
player.on((event) => {
  switch (event.type) {
    case "progress":
      updateSeekbar(event.currentTimeMs);
      break;
    case "quality_changed":
      showBadge(event.quality);
      break;
    case "buffering":
      showSpinner(event.isBuffering);
      break;
  }
});

// Playback controls
player.play();
player.pause();
player.seek(60_000); // Seek to 1 minute
player.setRate(1.5); // 1.5x speed
player.setQuality("720p"); // Manual quality selection
player.enterPiP(); // Picture-in-Picture
player.skipForward(10_000); // Skip 10 seconds

Offline Downloads

import { DownloadManager } from "@rajeev02/media";

const dm = new DownloadManager(
  2, // Max concurrent downloads
  2 * 1024 ** 3, // 2 GB storage limit
);

// Enqueue download
dm.enqueue({
  id: "movie-001",
  uri: "https://cdn.example.com/movie.mp4",
  title: "Offline Movie",
  estimatedSizeBytes: 500_000_000, // 500 MB
});

// Track progress
dm.onProgress((progress) => {
  console.log(`${progress.percentComplete}% at ${progress.speedBps} B/s`);
  console.log(`ETA: ${progress.estimatedTimeRemainingMs}ms`);
});

// Manage downloads
dm.pause("movie-001");
dm.resume("movie-001");
dm.cancel("movie-001");
const all = dm.getAll(); // List all downloads with status

API Reference

MediaPlayerController

| Method | Description | | -------------------------------------- | ---------------------------- | | load(source) | Load media source | | play() / pause() | Play or pause | | seek(positionMs) | Seek to position | | setRate(rate) | Set playback speed (0.5–3.0) | | setQuality(quality) | Set video quality | | setVolume(volume) | Set volume (0–1) | | enterPiP() / exitPiP() | Toggle Picture-in-Picture | | skipForward(ms) / skipBackward(ms) | Skip forward/backward | | on(callback) | Subscribe to player events | | destroy() | Release player resources |

DownloadManager

| Method | Description | | -------------------------- | ----------------------- | | enqueue(config) | Start a download | | pause(id) / resume(id) | Pause or resume | | cancel(id) | Cancel and delete | | getAll() | List all downloads | | getById(id) | Get download status | | onProgress(callback) | Track download progress | | getTotalStorageUsed() | Get total bytes used |

Full Documentation

📖 Complete API docs with casting, DRM, and playlist support

License

MIT © 2026 Rajeev Kumar Joshi