function MultiFileLoader( sources, audioContext, onLoadProgress, onLoadComplete ) {

     //Private variables
     var self = this;
     this.audioContext = audioContext;
     var sourcesToLoad_ = 0;
     var loadedAudioBuffers_ = [];

     //Private functions
     function init() {

         // If not defined, set empty sources.
         if ( !sources ) {
             log.debug( "Setting empty source. No sound may be heard" );
             onLoadComplete( false, loadedAudioBuffers_ );
             return;
         }

         // Convert to array.
         if ( !( sources instanceof Array ) ) {
             var sourceArray = [];
             sourceArray.push( sources );
             sources = sourceArray;
         }

         // If beyond size limits, log error and callback with false.
         if ( sources.length < self.minSources || sources.length > self.maxSources ) {
             log.error( "Unsupported number of Sources. " + self.modelName + " only supports a minimum of " + self.minSources + " and a maximum of " + self.maxSources + " sources. Trying to load " + sources.length + "." );
             onLoadComplete( false, loadedAudioBuffers_ );
             return;
         }

         // Load each of the sources
         sourcesToLoad_ = sources.length;
         loadedAudioBuffers_ = new Array( sourcesToLoad_ );
         sources.forEach( function ( thisSound, index ) {
             loadSingleSound( thisSound, onSingleLoadAt( index ) );
         } );
     }

     function loadSingleSound( source, onSingleLoad ) {
         var sourceType = Object.prototype.toString.call( source );
         var audioBuffer;
         if ( sourceType === '[object AudioBuffer]' ) {
             audioBuffer = new SPAudioBuffer( self.audioContext, source );
             onSingleLoad( true, audioBuffer );
         } else if ( source && source.isSPAudioBuffer && source.buffer ) {
             onSingleLoad( true, source );
         } else if ( sourceType === '[object String]' ||
             sourceType === '[object File]' ||
             ( source.isSPAudioBuffer && source.sourceURL ) ) {

             var sourceURL;
             if ( source.isSPAudioBuffer && source.sourceURL ) {
                 sourceURL = source.sourceURL;
                 audioBuffer = source;
             } else {
                 sourceURL = source;
                 audioBuffer = new SPAudioBuffer( self.audioContext, sourceURL );
             }

             var fileLoader = new FileLoader( sourceURL, self.audioContext, function ( status ) {
                 if ( status ) {
                     audioBuffer.buffer = fileLoader.getBuffer();
                     onSingleLoad( status, audioBuffer );
                 } else {
                     onSingleLoad( status );
                 }
             }, function ( progressEvent ) {
                 if ( onLoadProgress && typeof onLoadProgress === 'function' ) {
                     onLoadProgress( progressEvent, audioBuffer );
                 }
             } );
         } else {
             log.error( "Incorrect Parameter Type - Source is not a URL, File or AudioBuffer or doesn't have sourceURL or buffer" );
             onSingleLoad( false, {} );
         }
     }

     function onSingleLoadAt( index ) {
         return function ( status, loadedSound ) {
             if ( status ) {
                 log.debug( "Loaded track", index, "successfully" );
                 loadedAudioBuffers_[ index ] = loadedSound;
             }
             sourcesToLoad_--;
             if ( sourcesToLoad_ === 0 ) {
                 var allStatus = true;
                 for ( var bIndex = 0; bIndex < loadedAudioBuffers_.length; ++bIndex ) {
                     if ( !loadedAudioBuffers_[ bIndex ] ) {
                         allStatus = false;
                         break;
                     }
                 }
                 onLoadComplete( allStatus, loadedAudioBuffers_ );
             }
         };
     }
     init();
 }
/**
  * Helper class to loader multiple sources from URL String, File or AudioBuffer or SPAudioBuffer Objects.
  *
  *
  * @method MuliFileLoader
  * @param {Array/String/File} sources Array of or Individual String, AudioBuffer or File Objects which define the sounds to be loaded
  * @param {String} audioContext AudioContext to be used in decoding the file
  * @param {String} [onLoadProgress] Callback function to access the progress of the file loading.
  * @param {String} [onLoadComplete] Callback function to be called when all sources are loaded
  */
Helper class to loader multiple sources from URL String, File or AudioBuffer or SPAudioBuffer Objects.
@method MuliFileLoader
@param {Array/String/File} sources Array of or Individual String, AudioBuffer or File Objects which define the sounds to be loaded
@param {String} audioContext AudioContext to be used in decoding the file
@param {String} [onLoadProgress] Callback function to access the progress of the file loading.
@param {String} [onLoadComplete] Callback function to be called when all sources are loaded
Helper class to loader multiple sources from URL String File or AudioBuffer or SPAudioBuffer Objects . @method MuliFileLoader @param { Array / String / File } sources Array of or Individual String AudioBuffer or File Objects which define the sounds to be loaded @param { String } audioContext AudioContext to be used in decoding the file @param { String } [ onLoadProgress ] Callback function to access the progress of the file loading . @param { String } [ onLoadComplete ] Callback function to be called when all sources are loaded
function MultiFileLoader( sources, audioContext, onLoadProgress, onLoadComplete ) {
     var self = this;
     this.audioContext = audioContext;
     var sourcesToLoad_ = 0;
     var loadedAudioBuffers_ = [];
     function init() {
         if ( !sources ) {
             log.debug( "Setting empty source. No sound may be heard" );
             onLoadComplete( false, loadedAudioBuffers_ );
             return;
         }
         if ( !( sources instanceof Array ) ) {
             var sourceArray = [];
             sourceArray.push( sources );
             sources = sourceArray;
         }
         if ( sources.length < self.minSources || sources.length > self.maxSources ) {
             log.error( "Unsupported number of Sources. " + self.modelName + " only supports a minimum of " + self.minSources + " and a maximum of " + self.maxSources + " sources. Trying to load " + sources.length + "." );
             onLoadComplete( false, loadedAudioBuffers_ );
             return;
         }
         sourcesToLoad_ = sources.length;
         loadedAudioBuffers_ = new Array( sourcesToLoad_ );
         sources.forEach( function ( thisSound, index ) {
             loadSingleSound( thisSound, onSingleLoadAt( index ) );
         } );
     }
     function loadSingleSound( source, onSingleLoad ) {
         var sourceType = Object.prototype.toString.call( source );
         var audioBuffer;
         if ( sourceType === '[object AudioBuffer]' ) {
             audioBuffer = new SPAudioBuffer( self.audioContext, source );
             onSingleLoad( true, audioBuffer );
         } else if ( source && source.isSPAudioBuffer && source.buffer ) {
             onSingleLoad( true, source );
         } else if ( sourceType === '[object String]' ||
             sourceType === '[object File]' ||
             ( source.isSPAudioBuffer && source.sourceURL ) ) {
             var sourceURL;
             if ( source.isSPAudioBuffer && source.sourceURL ) {
                 sourceURL = source.sourceURL;
                 audioBuffer = source;
             } else {
                 sourceURL = source;
                 audioBuffer = new SPAudioBuffer( self.audioContext, sourceURL );
             }
             var fileLoader = new FileLoader( sourceURL, self.audioContext, function ( status ) {
                 if ( status ) {
                     audioBuffer.buffer = fileLoader.getBuffer();
                     onSingleLoad( status, audioBuffer );
                 } else {
                     onSingleLoad( status );
                 }
             }, function ( progressEvent ) {
                 if ( onLoadProgress && typeof onLoadProgress === 'function' ) {
                     onLoadProgress( progressEvent, audioBuffer );
                 }
             } );
         } else {
             log.error( "Incorrect Parameter Type - Source is not a URL, File or AudioBuffer or doesn't have sourceURL or buffer" );
             onSingleLoad( false, {} );
         }
     }
     function onSingleLoadAt( index ) {
         return function ( status, loadedSound ) {
             if ( status ) {
                 log.debug( "Loaded track", index, "successfully" );
                 loadedAudioBuffers_[ index ] = loadedSound;
             }
             sourcesToLoad_--;
             if ( sourcesToLoad_ === 0 ) {
                 var allStatus = true;
                 for ( var bIndex = 0; bIndex < loadedAudioBuffers_.length; ++bIndex ) {
                     if ( !loadedAudioBuffers_[ bIndex ] ) {
                         allStatus = false;
                         break;
                     }
                 }
                 onLoadComplete( allStatus, loadedAudioBuffers_ );
             }
         };
     }
     init();
 }
function MultiFileLoader ( sources , audioContext , onLoadProgress , onLoadComplete ) { var self = this ; this . audioContext = audioContext ; var sourcesToLoad_ = 0 ; var loadedAudioBuffers_ = [ ] ; function init ( ) { if ( ! sources ) { log . debug ( "Setting empty source. No sound may be heard" ) ; onLoadComplete ( false , loadedAudioBuffers_ ) ; return ; } if ( ! ( sources instanceof Array ) ) { var sourceArray = [ ] ; sourceArray . push ( sources ) ; sources = sourceArray ; } if ( sources . length < self . minSources || sources . length > self . maxSources ) { log . error ( "Unsupported number of Sources. " + self . modelName + " only supports a minimum of " + self . minSources + " and a maximum of " + self . maxSources + " sources. Trying to load " + sources . length + "." ) ; onLoadComplete ( false , loadedAudioBuffers_ ) ; return ; } sourcesToLoad_ = sources . length ; loadedAudioBuffers_ = new Array ( sourcesToLoad_ ) ; sources . forEach ( function ( thisSound , index ) { loadSingleSound ( thisSound , onSingleLoadAt ( index ) ) ; } ) ; } function loadSingleSound ( source , onSingleLoad ) { var sourceType = Object . prototype . toString . call ( source ) ; var audioBuffer ; if ( sourceType === '[object AudioBuffer]' ) { audioBuffer = new SPAudioBuffer ( self . audioContext , source ) ; onSingleLoad ( true , audioBuffer ) ; } else if ( source && source . isSPAudioBuffer && source . buffer ) { onSingleLoad ( true , source ) ; } else if ( sourceType === '[object String]' || sourceType === '[object File]' || ( source . isSPAudioBuffer && source . sourceURL ) ) { var sourceURL ; if ( source . isSPAudioBuffer && source . sourceURL ) { sourceURL = source . sourceURL ; audioBuffer = source ; } else { sourceURL = source ; audioBuffer = new SPAudioBuffer ( self . audioContext , sourceURL ) ; } var fileLoader = new FileLoader ( sourceURL , self . audioContext , function ( status ) { if ( status ) { audioBuffer . buffer = fileLoader . getBuffer ( ) ; onSingleLoad ( status , audioBuffer ) ; } else { onSingleLoad ( status ) ; } } , function ( progressEvent ) { if ( onLoadProgress && typeof onLoadProgress === 'function' ) { onLoadProgress ( progressEvent , audioBuffer ) ; } } ) ; } else { log . error ( "Incorrect Parameter Type - Source is not a URL, File or AudioBuffer or doesn't have sourceURL or buffer" ) ; onSingleLoad ( false , { } ) ; } } function onSingleLoadAt ( index ) { return function ( status , loadedSound ) { if ( status ) { log . debug ( "Loaded track" , index , "successfully" ) ; loadedAudioBuffers_ [ index ] = loadedSound ; } sourcesToLoad_ -- ; if ( sourcesToLoad_ === 0 ) { var allStatus = true ; for ( var bIndex = 0 ; bIndex < loadedAudioBuffers_ . length ; ++ bIndex ) { if ( ! loadedAudioBuffers_ [ bIndex ] ) { allStatus = false ; break ; } } onLoadComplete ( allStatus , loadedAudioBuffers_ ) ; } } ; } init ( ) ; }
Helper class to loader multiple sources from URL String, File or AudioBuffer or SPAudioBuffer Objects.
Helper class to loader multiple sources from URL String File or AudioBuffer or SPAudioBuffer Objects .
//Private variables //Private functions // If not defined, set empty sources. // Convert to array. // If beyond size limits, log error and callback with false. // Load each of the sources