This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Is triggered when a chunk is loaded | |
*/ | |
var _onChunkLoaded = function() { | |
// Concat two ArrayBuffers into a new one | |
_activeBuffer = _appendBuffer(_activeBuffer, _request.response); | |
// Use decodeAudioData for creating an AudioBuffer, | |
// so that we don't block the main thread. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* It is responsible for loading all the different chunks | |
* | |
* @private | |
* @type {XMLHttpRequest} | |
*/ | |
var _request = new XMLHttpRequest(); | |
// Set the responseType to arraybuffer | |
_request.responseType = 'arraybuffer'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Adding a bit of scheduling so that we won't have single digit milisecond overlaps. | |
// Thanks to Chris Wilson for his suggestion. | |
var scheduledTime = 0.015; | |
try { | |
_audioSource.stop(scheduledTime); | |
} catch (e) {} | |
_audioSource = _context.createBufferSource(); | |
_audioSource.buffer = _audioBuffer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Creates a new Uint8Array based on two different ArrayBuffers | |
* | |
* @private | |
* @param {ArrayBuffers} buffer1 The first buffer. | |
* @param {ArrayBuffers} buffer2 The second buffer. | |
* @return {ArrayBuffers} The new ArrayBuffer created out of the two. | |
*/ | |
var _appendBuffer = function(buffer1, buffer2) { | |
var tmp = new Uint8Array(buffer1.byteLength + buffer2.byteLength); |
OlderNewer