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

audio-resumer

v0.0.1

Published

Automatic AudioContext management for Web Audio API - handles autoplay policy and page visibility

Downloads

116

Readme

audio-resumer

Note: Comments, documentation, and TypeScript types in this package were automatically generated by AI.

Automatic AudioContext management for Web Audio API. Handles browser autoplay policy and page visibility suspend/resume.

Features

  • Autoplay policy bypass - Automatically unlocks AudioContext on user interaction
  • Page visibility management - Suspends AudioContext when page is hidden, resumes when visible
  • Zero dependencies - Uses only standard Web APIs
  • TypeScript support - Full type definitions included
  • Small size - Minimal footprint

Installation

npm install audio-resumer

Usage

import { AudioResumer } from 'audio-resumer';

// Create AudioContext
const audioContext = new AudioContext();

// Enable automatic AudioContext management
AudioResumer.create(audioContext);

// Now AudioContext will be automatically managed:
// - Unlocked on first user interaction
// - Suspended when page is hidden
// - Resumed when page becomes visible

What it solves

1. Browser Autoplay Policy

Modern browsers block autoplay audio without user interaction. AudioResumer creates an invisible empty audio element that unlocks AudioContext when the user first interacts with the page.

2. Resource Saving

When a page is hidden (tab switched, minimized), AudioContext continues running and consumes resources. AudioResumer automatically suspends AudioContext when the page is hidden and resumes it when the page becomes visible again.

API

AudioResumer

Static Method: create

AudioResumer.create(audioContext: AudioContext): AudioResumer

Creates and initializes AudioResumer for the given AudioContext. Starts managing the AudioContext automatically.

Parameters:

  • audioContext - The AudioContext instance to manage

Returns:

  • AudioResumer - The created AudioResumer instance (usually not needed to store)

Example:

const audioContext = new AudioContext();
AudioResumer.create(audioContext);

How it works

  1. Autoplay unlock: Creates an invisible empty WAV file (data URI) and plays it on user interaction to unlock AudioContext
  2. Visibility tracking: Listens to visibilitychange, pagehide, and pageshow events
  3. Automatic suspend/resume: Suspends AudioContext when page is hidden, resumes when visible

Browser Support

Works in all modern browsers that support:

  • Web Audio API
  • Page Visibility API
  • HTMLAudioElement

License

MIT