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

@davland7/rplayer

v3.0.2

Published

Minimal audio stream controller. Lightweight utility for controlling audio streams, with zero dependencies.

Readme

RPlayer III — Minimal Audio Stream Controller

Dependency-free controller for HTMLAudioElement, designed for streaming URLs. Built for modern apps, browser extensions, and lightweight UIs. Mobile-ready.

jsDelivr npm version License: MIT


Overview

  • Simple API wrapping HTMLAudioElement
  • Native HLS detection helpers (HLS.js not included)
  • Works great in browser extensions and small UIs
  • Zero dependencies, tiny footprint

🎵 Live Demo | ⚛️ React Demo (CodeSandbox)

Install

NPM

npm install @davland7/rplayer

CDN (jsDelivr)

<script src="https://cdn.jsdelivr.net/npm/@davland7/rplayer@latest/dist/rplayer.umd.js"></script>

ESM vs UMD

This library ships both ESM and UMD builds.

  • ESM (modern bundlers, frameworks):

    • Import: import RPlayer from '@davland7/rplayer'
    • Entry: module points to dist/rplayer.js
    • Recommended for Vite, Webpack, Rollup, etc.
  • UMD (script tag / no bundler):

    • File: dist/rplayer.umd.js
    • Global name: window.RPlayer (configured via Vite build.lib.name)
    • Usage:
      <script src="https://cdn.jsdelivr.net/npm/@davland7/rplayer@latest/dist/rplayer.umd.js"></script>
      <script>
        const player = new window.RPlayer();
        const audio = document.querySelector('audio');
        player.attachMedia(audio);
        audio.src = 'https://example.com/stream.mp3';
        audio.play();
      </script>

Quick Start

<audio id="audio" preload="none"></audio>
<button id="playPause">Play / Pause</button>
import RPlayer from '@davland7/rplayer';

const audio = document.getElementById('audio');
const playPauseBtn = document.getElementById('playPause');

const player = new RPlayer();
player.attachMedia(audio);

// Load any stream URL (HTTP/HTTPS). User gesture required to play in browsers.
audio.src = 'https://example.com/stream.mp3';

playPauseBtn.addEventListener('click', () => player.togglePlay());

Autoplay Policy (Important)

Browsers require user interaction before playing audio. Calling audio.play() without a user gesture (click/tap) will be blocked and may throw a DOMException.

Best practices:

  • Always wrap audio.play() in a user-initiated event (click, tap)
  • Use player.togglePlay() for combined play/pause buttons
  • Handle the promise from play() to catch autoplay blocks
try {
  await audio.play();
} catch (err) {
  console.warn('Playback blocked by browser:', err);
  // Show a play button or notification to user
}

HLS (.m3u8) Support

RPlayer v3 does not bundle HLS.js. It provides detection helpers and leaves integration up to you.

  • RPlayer.supportsHls() — detects if the browser supports native HLS playback
  • RPlayer.isHls(url) — detects HLS URLs by extension (.m3u8, .m3u) or path patterns (/hls/)
  • Safari supports HLS natively. Chrome has partial support. Firefox does not.
  • Browser compatibility: https://caniuse.com/?search=hls

Recommendation: Use HLS.js for production

Even when native support exists, HLS.js provides more reliable cross-browser playback. Native HLS support can be inconsistent, especially on Chrome.

Integrate HLS.js manually in your app. See the HLS.js documentation for setup instructions.

iOS Considerations

iPad and iPhone enforce volume control through hardware buttons only. Software volume controls have no effect on iOS devices.

Recommendations:

  • Use RPlayer.isIos() to detect iOS devices (iPad, iPhone, iPod)
  • Disable software volume buttons on iOS (they will not work)
  • Native media session controls work automatically on iOS
  • iPadOS 13+ is detected correctly (reports as macOS but with touch support)
const isIos = RPlayer.isIos();

// Disable volume buttons on iOS (hardware buttons only)
volumeUpBtn.disabled = isIos;
volumeDownBtn.disabled = isIos;

API Reference

Class: RPlayer

  • attachMedia(audioElement): Attach an HTMLAudioElement to control
  • togglePlay(): Toggle play/pause state. Returns the play() promise when resuming, so you can catch autoplay rejections
  • stop(forceClear = false): Pause and reset to 0; if forceClear is true, also clears src
  • rewind(seconds = 10): Seek backward by seconds (minimum 0)
  • volumeUp(): Increase volume by 0.1 (clamped to 1.0)
  • volumeDown(): Decrease volume by 0.1 (clamped to 0.0)
  • toggleMute() / mute(): Toggle muted state (mute() is an alias for toggleMute())
  • get isPlaying: Returns true if audio is not paused
  • get isMuted: Returns true if audio is muted

Static Helpers

  • RPlayer.supportsHls(): Returns true if browser supports native HLS (Safari: yes, Chrome: partial, Firefox: no)
  • RPlayer.isHls(url): Detects HLS URLs (.m3u8, .m3u, /hls/ in path)
  • RPlayer.isIos(): Detects iOS devices (iPad, iPhone, iPod — including iPadOS 13+ which reports as macOS)

Types

Type definitions are published at types/rplayer.d.ts for TS consumers.

TypeScript Example

import RPlayer from '@davland7/rplayer';

const audio = document.getElementById('audio') as HTMLAudioElement;
const player = new RPlayer();
player.attachMedia(audio);

audio.src = 'https://example.com/stream.mp3';
await audio.play().catch(console.warn);

// Helpers
const isHls = RPlayer.isHls(audio.src);
const isIos = RPlayer.isIos();

Demo / Development

🎵 Live Demo | ⚛️ React Demo (CodeSandbox)

Run the demo locally with Vite:

npm install
npm run dev

Build the library:

npm run build

Notes for Developers

  • RPlayer focuses on controlling the native HTMLAudioElement and remains dependency-free
  • HLS.js is optional in v3; integrate it manually if targeting browsers without native HLS support
  • Helper methods (isHls(), supportsHls(), isIos()) are provided as static utilities and do not enforce a specific integration strategy
  • togglePlay() returns the play() promise — always handle it to avoid uncaught DOMException errors