{"_id":"audio-context-polyfill","_rev":"3114826","name":"audio-context-polyfill","description":"Just code for one API by enjoying this polyfill for the Web Audio API.","dist-tags":{"latest":"1.0.0"},"maintainers":[{"name":"jakedchampion","email":""}],"time":{"modified":"2023-11-27T05:49:28.000Z","created":"2015-11-19T20:55:56.211Z","1.0.0":"2015-11-19T20:55:56.211Z"},"users":{},"author":{"name":"Jake Champion"},"repository":{"type":"git","url":"git+https://github.com/JakeChampion/AudioContext.git"},"versions":{"1.0.0":{"name":"audio-context-polyfill","version":"1.0.0","description":"Just code for one API by enjoying this polyfill for the Web Audio API.","main":"AudioContext.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+https://github.com/JakeChampion/AudioContext.git"},"keywords":["audio","context","polyfill"],"author":{"name":"Jake Champion"},"license":"MIT","bugs":{"url":"https://github.com/JakeChampion/AudioContext/issues"},"homepage":"https://github.com/JakeChampion/AudioContext#readme","gitHead":"5425eae7acaa2218d6d1f10ec19ee99b67a7a67c","_id":"audio-context-polyfill@1.0.0","_shasum":"4b728faf0a19555194d4fbd05582f833fdcd137b","_from":".","_npmVersion":"3.3.6","_nodeVersion":"5.0.0","_npmUser":{"name":"jakedchampion","email":"me@jakechampion.name"},"dist":{"shasum":"4b728faf0a19555194d4fbd05582f833fdcd137b","size":2437,"noattachment":false,"key":"/audio-context-polyfill/-/audio-context-polyfill-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/audio-context-polyfill/download/audio-context-polyfill-1.0.0.tgz"},"maintainers":[{"name":"jakedchampion","email":""}],"directories":{},"publish_time":1447966556211,"_hasShrinkwrap":false,"_cnpm_publish_time":1447966556211,"_cnpmcore_publish_time":"2021-12-16T20:20:52.902Z"}},"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```","_attachments":{},"homepage":"https://github.com/JakeChampion/AudioContext#readme","bugs":{"url":"https://github.com/JakeChampion/AudioContext/issues"},"license":"MIT"}