Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Side by Side Diff: LayoutTests/webaudio/resources/buffer-loader.js

Issue 225093020: Remove 2-arg createBuffer from WebAudio (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 function BufferLoader(context, urlList, callback) { 1 function BufferLoader(context, urlList, callback) {
2 this.context = context; 2 this.context = context;
3 this.urlList = urlList; 3 this.urlList = urlList;
4 this.onload = callback; 4 this.onload = callback;
5 this.bufferList = new Array(); 5 this.bufferList = new Array();
6 this.loadCount = 0; 6 this.loadCount = 0;
7 } 7 }
8 8
9 BufferLoader.prototype.loadBuffer = function(url, index) { 9 BufferLoader.prototype.loadBuffer = function(url, index) {
10 // Load buffer asynchronously 10 // Load buffer asynchronously
11 var request = new XMLHttpRequest(); 11 var request = new XMLHttpRequest();
12 request.open("GET", url, true); 12 request.open("GET", url, true);
13 request.responseType = "arraybuffer"; 13 request.responseType = "arraybuffer";
14 14
15 var loader = this; 15 var loader = this;
16 16
17 request.onload = function() { 17 request.onload = function() {
18 var buffer; 18 var buffer;
Ken Russell (switch to Gerrit) 2014/04/13 08:33:54 This variable isn't needed anymore.
Raymond Toy 2014/04/14 16:47:51 Done.
19 try { 19 loader.context.decodeAudioData(
20 buffer = loader.context.createBuffer(request.response, false); 20 request.response,
21 } catch(e) { 21 function (decodedAudio) {
22 alert('error decoding file data: ' + url); 22 try {
23 } 23 loader.bufferList[index] = decodedAudio;
24 24 if (++loader.loadCount == loader.urlList.length)
25 try { 25 loader.onload(loader.bufferList);
26 loader.bufferList[index] = buffer; 26 } catch(e) {
27 if (++loader.loadCount == loader.urlList.length) 27 alert('BufferLoader: unable to load buffer' + index);
28 loader.onload(loader.bufferList); 28 }
29 } catch(e) { 29 },
30 alert('BufferLoader: callback problem'); 30 function () {
31 } 31 alert('error decoding file data: ' + url);
32 });
32 } 33 }
33 34
34 request.onerror = function() { 35 request.onerror = function() {
35 alert('BufferLoader: XHR error'); 36 alert('BufferLoader: XHR error');
36 } 37 }
37 38
38 request.send(); 39 request.send();
39 } 40 }
40 41
41 BufferLoader.prototype.load = function() { 42 BufferLoader.prototype.load = function() {
42 for (var i = 0; i < this.urlList.length; ++i) 43 for (var i = 0; i < this.urlList.length; ++i)
43 this.loadBuffer(this.urlList[i], i); 44 this.loadBuffer(this.urlList[i], i);
44 } 45 }
OLDNEW
« no previous file with comments | « LayoutTests/webaudio/dom-exceptions-expected.txt ('k') | Source/modules/webaudio/AudioContext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698