Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / webaudio / resources / buffer-loader.js
blob8aa98b4173a7b34bbeaaeecfbbac0c7ad7ca314b
1 function BufferLoader(context, urlList, callback) {
2 this.context = context;
3 this.urlList = urlList;
4 this.onload = callback;
5 this.bufferList = new Array();
6 this.loadCount = 0;
9 BufferLoader.prototype.loadBuffer = function(url, index) {
10 // Load buffer asynchronously
11 var request = new XMLHttpRequest();
12 request.open("GET", url, true);
13 request.responseType = "arraybuffer";
15 var loader = this;
17 request.onload = function() {
18 loader.context.decodeAudioData(
19 request.response,
20 function (decodedAudio) {
21 try {
22 loader.bufferList[index] = decodedAudio;
23 if (++loader.loadCount == loader.urlList.length)
24 loader.onload(loader.bufferList);
25 } catch(e) {
26 alert('BufferLoader: unable to load buffer' + index);
29 function () {
30 alert('error decoding file data: ' + url);
31 });
34 request.onerror = function() {
35 alert('BufferLoader: XHR error');
38 request.send();
41 BufferLoader.prototype.load = function() {
42 for (var i = 0; i < this.urlList.length; ++i)
43 this.loadBuffer(this.urlList[i], i);