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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@keithalpichi/audio-player

v0.0.6

Published

An audio player built with Web Audio APIs to load and playback many audio files. This library does not provide a user interface, only a class and methods to perform the features of an audio player.

Downloads

3

Readme

audio-player

A browser audio player built with Typescript and Web Audio APIs to load and playback many audio files. This library does not provide a user interface, only a class and methods to perform the features of an audio player.

Features

This library supports:

  1. loading many audio files as AudioBuffers. Audio is loaded into the player via the .load() and loadToRear() methods. The track list acts as a doubly linked-list. The play head can move forward and back through this track list.
  2. playback via the .play(), .pause(), .stop(), .seek(), .seekAndPlay(), .skipForward(), and .skipBackward() methods. The latter two methods will only skip as far as there is loaded audio.
  3. volume control via the .mute(), .unmute(), .setVolume(), and .maxVolume() methods. If the volume is changed while it is muted, the audio player will not unmute. When it is unmuted, volume will be set to the last known value. That is the value prior to muting or any volumes provided to .setVolume() or .maxVolume().
  4. Typescript

Installation

npm i @keithalpichi/audio-player

Usage

import AudioPlayer from "@keithalpichi/audio-player";
// create an audio player instance
const audioPlayer = new AudioPlayer();
// get an audio file from a server using fetch
const response = await fetch("https://localhost:443/song.wav");
// convert the response to an ArrayBuffer
const arrayBuffer = await response.arrayBuffer();
// load the buffer into the audio player and await the promise to resolve
await audioPlayer.load({ id: "song.wav", arrayBuffer });
// play the sound
audioPlayer.play();
// audio player keeps track of the current audio file.
// invoking .play() plays the sound again.
audioPlayer.play();

// pause the audio
audioPlayer.pause();
// get the current time
const currentTime = audioPlayer.currentTime;
// seek to a specific point in time but pause playback
audioPlayer.seek(currentTime + 1.0);
// seek to a specific point in time and resume playing immediately
audioPlayer.seekAndPlay(currentTime + 1.0);

// stop playback. The time on the audio resets to zero seconds.
audioPlayer.stop();

// load more audio into the player and play them
audioPlayer.skipForward();
audioPlayer.play();

// go back to the previous audio file
audioPlayer.skipBackward();
audioPlayer.play();

// mute audio
audioPlayer.mute();

// unmute audio back to the last known volume
audioPlayer.unmute();

Development

npm i
npm run build

Contributing

If you're interested in proposing changes or have issues please browse the issues page to see if it exists already. If not consider opening a new issue.

Roadmap

  1. Support seeking forward and backwards by increments