{"_id":"audio-context-polyfill","_rev":"6-23a832e56fa529137b02b851bc62e99f","name":"audio-context-polyfill","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"audio-context-polyfill","version":"1.0.0","keywords":["audio","context","polyfill"],"author":{"name":"Jake Champion"},"license":"MIT","_id":"audio-context-polyfill@1.0.0","maintainers":[{"name":"jakedchampion","email":"me@jakechampion.name"}],"homepage":"https://github.com/JakeChampion/AudioContext#readme","bugs":{"url":"https://github.com/JakeChampion/AudioContext/issues"},"dist":{"shasum":"4b728faf0a19555194d4fbd05582f833fdcd137b","tarball":"https://registry.npmjs.org/audio-context-polyfill/-/audio-context-polyfill-1.0.0.tgz","integrity":"sha512-Ex1jZc8e3AIiOBm8Tn0oS4yZ8aT5VCLygaov+fxJ4ymgUB2GPqW5DtQ8NBpR2dfvSR6RjWvMU8+nDwIE/he49w==","signatures":[{"sig":"MEQCICfO3VKp4VsEuP90qboa0QDXnumlQ/Z1YgI69ix+LBKKAiB8nDWPzJBtia8iwFA2o+xPU6lVX487JSEsH95Uc/ZDqQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"AudioContext.js","_from":".","_shasum":"4b728faf0a19555194d4fbd05582f833fdcd137b","gitHead":"5425eae7acaa2218d6d1f10ec19ee99b67a7a67c","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"_npmUser":{"name":"jakedchampion","email":"me@jakechampion.name"},"deprecated":"Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.","repository":{"url":"git+https://github.com/JakeChampion/AudioContext.git","type":"git"},"_npmVersion":"3.3.6","description":"Just code for one API by enjoying this polyfill for the Web Audio API.","directories":{},"_nodeVersion":"5.0.0"}},"time":{"created":"2015-11-19T20:55:56.211Z","modified":"2025-04-15T11:40:44.497Z","1.0.0":"2015-11-19T20:55:56.211Z"},"bugs":{"url":"https://github.com/JakeChampion/AudioContext/issues"},"author":{"name":"Jake Champion"},"license":"MIT","homepage":"https://github.com/JakeChampion/AudioContext#readme","keywords":["audio","context","polyfill"],"repository":{"url":"git+https://github.com/JakeChampion/AudioContext.git","type":"git"},"description":"Just code for one API by enjoying this polyfill for the Web Audio API.","maintainers":[{"email":"support@npmjs.com","name":"npm-support"}],"readme":"# AudioContext\n\nJust code for one API by enjoying this polyfill for the **[Web Audio API](http://caniuse.com/audio-api)** at [W3](https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/specification.html), following the upgrade path outlined at [MDN](https://developer.mozilla.org/en-US/docs/Web_Audio_API/Porting_webkitAudioContext_code_to_standards_based_AudioContext).\n\n## Why this is useful\n\nFirst, as the **Web Audio API** evolved, many method names were changed from what we find in older Chrome and Safari browsers (e.g. **buffer.start()** was **bufferNode.noteOn()**). Second, older browsers retained a vendor prefixed **Audio Context** method (e.g. **window.AudioContext** was **window.webkitAudioContext**).\n\n## Which browsers this will effect\n\nIncluding this polyfill will improve your experience coding for Chrome 10-30, Firefox v23-25, Opera 15-16, Safari 6-7, iOS Safari 6-7, and potentially later versions of these browsers as well.\n\n## Examples of the Audio API\n\nLet&rsquo;s load a sound and autoplay it.\n\n```javascript\nvar\n// create the audio context\ncontext = new AudioContext(),\n// create the http request\nrequest = new XMLHttpRequest();\n\n// request the MP3\nrequest.open('GET', 'sound.mp3');\n\n// request as an array buffer\nrequest.responseType = 'arraybuffer';\n\n// when the request loads\nrequest.addEventListener('load', function () {\n\t// decode the array buffer\n\tcontext.decodeAudioData(request.response, function (buffer) {\n\t\tvar\n\t\t// create the audio source\n\t\tsource = context.createBufferSource(),\n\t\t// create the audio volume\n\t\tvolume = context.createGainNode();\n\n\t\t// set the buffer to the audio source\n\t\tsource.buffer = buffer;\n\n\t\t// set the volume to half\n\t\tvolume.gain.value = 0.5;\n\n\t\t// connect the audio source to the audio volume\n\t\tsource.connect(volume);\n\n\t\t// connect the audio volume to the output\n\t\tvolume.connect(context.destination);\n\n\t\t// play the audio source\n\t\tsource.start(0);\n\t});\n});\n\n// begin the request\nrequest.send();\n```","readmeFilename":"README.md"}