Skip to content

Instantly share code, notes, and snippets.

@clinyong
Created May 8, 2016 05:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clinyong/62d4efa81207c04a3ee691cdd9895e79 to your computer and use it in GitHub Desktop.
Save clinyong/62d4efa81207c04a3ee691cdd9895e79 to your computer and use it in GitHub Desktop.
var audioCtx = new AudioContext();
var source = audioCtx.createBufferSource();
fetch(
'http://7xsym0.com2.z0.glb.qiniucdn.com/%E9%82%93%E7%B4%AB%E6%A3%8B%20-%20A.I.N.Y.%2528%E7%88%B1%E4%BD%A0%2529.mp3', {
})
.then(function(resp){
resp.arrayBuffer().then(function(buffer){
audioCtx.decodeAudioData(buffer, function(decodedData) {
source.buffer = decodedData;
source.connect(audioCtx.destination);
source.start(0);
})
})
}).catch(function(e){
console.log(e)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment