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

@vdegenne/audio-player

v0.1.4

Published

Small helper to load and play audio files in your app with the following features:

Readme

@vdegenne/audio-player

Small helper to load and play audio files in your app with the following features:

  • Integrated hash-based audio cache
  • Lazy audio loading: cached audio is reused without invoking the audio loader
  • Volume control and boosting (values above 1 are supported)
  • Optional reverb effects
  • Asynchronous playback with cancellation support
  • Cancel individual playback or all active playbacks

Usage

Initialize the player

Create an AudioPlayer with a provider function that returns an audio key and a lazy audio loader. The key identifies the audio and is used to cache its decoded AudioBuffer.

import {AudioPlayer} from '@vdegenne/audio-player'

const player = new AudioPlayer((name: string) => ({
	key: name,
	audio: () => fetch(name).then((response) => response.blob()),
}))

The provider can return either an AudioRequest directly or a Promise<AudioRequest>.

An AudioRequest has the following shape:

interface AudioRequest {
	key: string
	audio: () => Promise<Blob | AudioBuffer>
}

The audio loader is only called when the requested key is not already cached. This means repeated playback with the same key reuses the decoded audio without making another network request.

Play audio

const {playPromise, cancel} = player.play(['bell.mp3'], {
	volume: 1.2, // Values above 1 boost the volume
})

playPromise
	.then(() => {
		console.log('Audio ended')
	})
	.catch((error) => {
		if (error.name === 'AbortError') {
			console.log('Playback canceled')
		} else {
			console.error('Playback failed', error)
		}
	})

cancel() // Cancel this playback at any time

play() returns an AudioPlayback object containing:

  • playPromise: resolves when playback ends, or rejects if playback is canceled or fails.
  • cancel(): cancels this playback.

All playback options are optional:

| Option | Default | Description | | ------------- | ----------- | ----------------------------------------------------------------------------------------------------- | | volume | 1 | Playback volume. Values above 1 are supported. | | reverb | undefined | Reverb preset to apply. | | reverbLevel | 0 | Reverb intensity. Reverb is applied only when a preset is provided and the level is greater than 0. |

Cancel all audio at once

Use cancelAllSpeeches() to cancel every currently active playback.

player.cancelAllSpeeches()

Each canceled playback's playPromise rejects with an AbortError.

Using reverb

First, copy the reverb files into your project's public directory so they can be served by your application.

cp -r ./node_modules/@vdegenne/audio-player/reverbs/ ./public/.

Alternatively, use this JavaScript script:

import {cp} from 'node:fs/promises'

await cp('./node_modules/@vdegenne/audio-player/reverbs', 'public/reverbs', {
	recursive: true,
})

Then specify a reverb preset and intensity in the play() call:

const {playPromise} = player.play(['hello.mp3'], {
	reverb: 'Deep Space',
	reverbLevel: 1,
})

await playPromise

reverbLevel controls the intensity of the effect. Reverb is disabled by default.

Important: The key must uniquely identify the audio content. If the content changes but the key stays the same, the previously cached audio will be reused.