@@ -718,8 +718,9 @@ this.createjs = this.createjs || {};
718718 * @param {Boolean } [preload=true] If the sound should be internally preloaded so that it can be played back
719719 * without an external preloader.
720720 * @param {string } basePath Set a path that will be prepending to src for loading.
721- * @return {Object } An object with the modified values that were passed in, which defines the sound. Returns false
722- * if the source cannot be parsed.
721+ * @return {Object } An object with the modified values that were passed in, which defines the sound.
722+ * Returns false if the source cannot be parsed or no plugins can be initialized.
723+ * Returns true if the source is already loaded.
723724 * @static
724725 * @since 0.4.0
725726 */
@@ -728,7 +729,6 @@ this.createjs = this.createjs || {};
728729 return false ;
729730 }
730731
731-
732732 if ( src instanceof Object ) {
733733 basePath = id ; //this assumes preload will not be passed in as a property // OJR check if arguments == 3
734734 //?? preload = src.preload;
@@ -746,7 +746,7 @@ this.createjs = this.createjs || {};
746746 s . idHash [ id ] = details . src ;
747747 }
748748
749- var numChannels = null ; // null will set all SoundChannel to set this to it's internal maxDefault
749+ var numChannels = null ; // null tells SoundChannel to set this to it's internal maxDefault
750750 if ( data != null ) {
751751 if ( ! isNaN ( data . channels ) ) {
752752 numChannels = parseInt ( data . channels ) ;
@@ -791,10 +791,13 @@ this.createjs = this.createjs || {};
791791 } // we do this so we can store multiple id's and data if needed
792792 s . preloadHash [ details . src ] . push ( { src :src , id :id , data :data } ) ; // keep this data so we can return it in fileload event
793793 if ( s . preloadHash [ details . src ] . length == 1 ) {
794+ // if already loaded once, don't load a second time // OJR note this will disallow reloading a sound if loading fails or the source changes
794795 if ( basePath == null ) { basePath = "" ; }
795796 s . activePlugin . preload ( details . src , loader , basePath ) ;
797+ } else {
798+ // if src already loaded successfully, return true
799+ if ( s . preloadHash [ details . src ] [ 0 ] == true ) { return true ; }
796800 }
797- // if already loaded once, don't load a second time // OJR note this will disallow reloading a sound if loading fails or the source changes
798801 }
799802
800803 return details ;
@@ -819,8 +822,9 @@ this.createjs = this.createjs || {};
819822 * {{#crossLink "Sound/registerSound"}}{{/crossLink}}: <code>{src:srcURI, id:ID, data:Data, preload:UseInternalPreloader}</code>
820823 * with "id", "data", and "preload" being optional.
821824 * @param {string } basePath Set a path that will be prepending to each src when loading.
822- * @return {Object } An array of objects with the modified values that were passed in, which defines each sound. It
823- * will return false for any values that the source cannot be parsed.
825+ * @return {Object } An array of objects with the modified values that were passed in, which defines each sound.
826+ * Like registerSound, it will return false for any values that the source cannot be parsed or if no plugins can be initialized.
827+ * Also, it will returns true for any values that the source is already loaded.
824828 * @static
825829 * @since 0.4.0
826830 */
0 commit comments