Skip to content

Instantly share code, notes, and snippets.

@MattRoelle
Created September 16, 2014 05:27
Show Gist options
  • Save MattRoelle/2a7ed3a925fb81db66e3 to your computer and use it in GitHub Desktop.
Save MattRoelle/2a7ed3a925fb81db66e3 to your computer and use it in GitHub Desktop.
var actx = new AudioContext();
var sound = actx.createBufferSource();
var req = new XMLHttpRequest();
var audioFile = 'https://dl.dropboxusercontent.com/u/87705298/136351__djmastah__requiem-3.mp3';
req.open('GET', audioFile, true); req.responseType = 'arraybuffer';
req.onload = function() {
actx.decodeAudioData(req.response, function(buffer) {
sound.buffer = buffer;
sound.connect(actx.destination);
sound.start();
});
};
req.send();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment