From 42805056ac5ed6dcd88d0c06e671dbbbdb84d046 Mon Sep 17 00:00:00 2001 From: yo mama Date: Tue, 23 Jun 2015 13:14:44 -0700 Subject: cleanup --- bieber_backwards.mp3 | Bin 3412262 -> 0 bytes hello | 1 - index.html | 3 --- test.mp3 | Bin 3412262 -> 0 bytes webaudio.js | 74 --------------------------------------------------- 5 files changed, 78 deletions(-) delete mode 100644 bieber_backwards.mp3 delete mode 100644 hello delete mode 100644 index.html delete mode 100644 test.mp3 delete mode 100644 webaudio.js diff --git a/bieber_backwards.mp3 b/bieber_backwards.mp3 deleted file mode 100644 index 5b20b6b..0000000 Binary files a/bieber_backwards.mp3 and /dev/null differ diff --git a/hello b/hello deleted file mode 100644 index ce01362..0000000 --- a/hello +++ /dev/null @@ -1 +0,0 @@ -hello diff --git a/index.html b/index.html deleted file mode 100644 index ee98701..0000000 --- a/index.html +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/test.mp3 b/test.mp3 deleted file mode 100644 index 5b20b6b..0000000 Binary files a/test.mp3 and /dev/null differ diff --git a/webaudio.js b/webaudio.js deleted file mode 100644 index 71c1dc4..0000000 --- a/webaudio.js +++ /dev/null @@ -1,74 +0,0 @@ -//creating an audio context -var context; -var audioBuffer; -window.addEventListener('load', init); - -function init() -{ - try - { - window.AudioContext = window.AudioContext || window.webkitAudioContext; - context=new AudioContext(); - } - catch(e) - { - alert("Your browser doesn't support Web Audio API"); - } - initAudio(); -} - -function initAudio(){ - console.log("audio ready"); - console.log("inside audio initialized callback"); - var url1 = "someurl" - var url2 = "someotherurl" - loadAndPlay(url1, function(){ - loadAndPlay(url2, function(){ - console.log("played both urls"); - }); - }); - - -} -function loadAndPlay(url, callback) { - var audioURL=url; - - //creating a new request - var request = new XMLHttpRequest(); - request.open("GET",audioURL,true); - request.responseType= 'arraybuffer'; - request.onload = function(){ - //take the audio from http request and decode it in an audio buffer - context.decodeAudioData(request.response, function(buffer){ - audioBuffer = buffer; - console.log(audioBuffer); - if(audioBuffer){ // check here - playSound(callback); - } - }); - - }; - - request.send(); -} - -//playing the audio file -function playSound(callback) { - - //creating source node - var source = context.createBufferSource(); - //passing in file - source.buffer = audioBuffer; - source.onended = function(){ - console.log("inside ended callback"); - console.log("ended"); - if (typeof(callback) != "undefined" ){ - callback(); - } - } - //start playing - source.connect(context.destination); // added - source.start(0); - console.log('playing'); - -} -- cgit v1.2.3-70-g09d2