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

startaudiocontext-fix

v1.2.1

Published

Start the AudioContext on an explicit user action.

Downloads

3

Readme

StartAudioContext starts the Web Audio API's AudioContext on an explicit user action.

This repo fixes a historical issue (https://github.com/tambien/StartAudioContext/issues/3) to resolve the warning.

According to the Apple's documentation:

On iOS, the Web Audio API requires sounds to be triggered from an explicit user action, such as a tap. Calling noteOn() from an onload event will not play sound.

StartAudioContext listens for the first non-dragged touchend or mouseup event on any of the given elements, then triggers a silent AudioBuffer which will start the AudioContext if it isn't already started.

Installation

Choose one:

  • download the js
  • npm install startaudiocontext
  • bower install startaudiocontext

Basic

//pass in the audio context
var context = new AudioContext();

//on iOS, the context will be started on the first valid user action on the #playButton element
StartAudioContext(context, "#playButton")

API

StartAudioContext(AudioContext, (Elements), (Callback)) => Promise

AudioContext

StartAudioContext will monitor the passed in AudioContext and resolve the promise and/or invoke the passed in callback when the AudioContext.state === 'running'.

Elements

The second argument can be an Element, Selector String, NodeList, jQuery Element or an Array of any of those. An event listener is bound to any of the passed in elements which will listen for a valid touch events to trigger a silent AudioBuffer which will start the AudioContext.

StartAudioContext(audioContext, '#button', function(){
	//audio context is started
})

If no element is passed in, it will bind to document.body.

Callback

The third argument is the callback to invoke when the AudioContext has started.

=> Promise

StartAudioContext returns a promise which is resolved when the AudioContext state is 'running'.

StartAudioContext(audioContext).then(function(){
	//context is started	
})

Tone.js

If you're using StartAudioContext with Tone.js or any other library which creates an AudioContext, pass in that AudioContext instead of creating a new one:

StartAudioContext(Tone.context, '#button').then(function(){
	//started
})

MIT License

Copyright 2016 Yotam Mann