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

audio_sequence

v0.0.28

Published

simple module to control, monitor and play multiple audio files in sequences at a time.

Downloads

31

Readme

Install:

NPM: to bundle it however you like:
  • To install it: npm i audio_sequence --save
  • To import it:
// ES5
const AudioSequence = require('audio_sequence').default

// ES6
import AudioSequence from 'audio_sequence'
Browser:
  • You can get the latest bundle from here
  • To Import it:
<script src="https://mrf345.github.io/audio_sequence/bin/AudioSequence.min.js"></script>
<script>
  var Player = new AudioSequence()
</script>

Support:

Should work with anything newer than Internet Explorer 10 and NodeJS 10.

Usage:

var Player = new AudioSequence(
    /**
     * Utility to help import html templates and parse them minimally.
     * @param {object} options contains the module options.
     *
     *`options` = {
     *  files: [], // files inserted will be stored in
     *  repeats: 1, // number of repeats to obey with some adjustments later
     *  repeat_whole: true, // repeat all files as whole
     *  repeat_each: false, // repeat each file for the number of repeats
     *  repeat_forever: false, // to keep repeating endlessly
     *  repeat_delay: 0, // to add a time delay between each repeat
     *  reverse_order: false, // to reverse the order list of audio files
     *  shuffle_order: false, // to randomly shuffle the order of the files list
     *  volume: 0.5, // to set the default volume
     *  auto_start: false, // to auto load and start playing as the module loads
     *  autoplay_warning: true, // to display warning if AutoPlay's disabled
     *  autoplay_message: 'message' // message to show if AutoPlay's disabled
     * 
     *  NOTE: if both `repeat_each` and `repeat_whole` are `true`. In any case
     *        `repeat_each` will always take precedence.
     * }
     */
)

// if the default options work for you out-of-the-box. this should load it:
Player.load()
  .then(function(audios) { console.log(audios) })
  .catch(function(error) { console.warn(error) })

Features:

  • Repeat whole: allows you to repeat a list of audio files as whole for a given number of repeats or forever.
  • Repeat each: allows you to repeat each file of list of audio files for a certain number of repeats.
  • Repeat delay: allows you to add a delay in-between repeats.
  • AutoPlay policy notification: notify the user with an overlay instructions to how to enable AutoPlay.

Interface:

List of typical music player like methods:

| Method | Input | Output | Description| |---------|--------|--------|----------| | .play(file = '') | file: audio file's link. | boolean | to start playing the added audio files. | | .playAfter(files = []) | files: array of files to play. | N/A | play files after the ongoing playlist sequence is done. | | .replay() | N/A | boolean | restart playing the current audio file. | | .stop() | N/A | boolean | stop playing all added audio files. | | .pause() | N/A | boolean | pause the currently playing audio. | | .next() | N/A | boolean | play the next file in the playlist. | | .previous() | N/A | boolean | play the previous file in the playlist. | | .forward(seconds = 0) | seconds: number of seconds to forward with. | boolean | forward the currently playing audio. | | .backward(seconds = 0) | seconds: number of seconds to backward with. | boolean | backward the currently playing audio. | | .mute() | N/A | boolean | mute all audio files. | | .unmute(volume = 0.5) | volume: volume to unmute with. | boolean | unmute all audio files. | | .each() | N/A | N/A | activate repeat each file for the number of Player.repeats mode. | | .whole() | N/A | N/A | activate repeat the whole playlist for the number of Player.repeats mode. | | .forever() | N/A | N/A | activate forever mode to disregard Player.repeats and repeat forever. | | .add(file = '') | file: audio file's link. | Promise() | load and add file to the playlist. | | .remove(file = '') | file: audio file's link. | boolean | remove file from the playlist. | | .load() | N/A | Promise() | to load Player.files manually with a Promise that resolves when all files are loaded. | | .doAfter() | todo: function to call when playlist sequence is finished. | N/A | add a function to list of functions to execute after playlist sequence is finished. |

Examples:

There's a bit old and dated live example, that was created when JQuery was a requirement "no longer it is". But it still works and serves the purpose.

Replaying the playlist sequence: If you want to replay the whole playlist sequence rather than replaying the last audio file with .replay(). You'll have to run Player.load().then(function() { Player.play() }) or you can automate that with setting autoStart option to true.

Player.autoStart = true
Player.load() // will replay automatically as soon as the tracks are loaded.

Development:

  • Run tests with: npm test
  • Auto format with standardJS: npm run format
  • Publish new release: npm run push
  • Update live example: ./pages.sh