Skip to content

Commit 173ca88

Browse files
author
Lanny McNie
committed
updated registerSound and registerManifest to return true if a source has already been loaded.
* Updated libs & docs Signed-off-by: Lanny McNie <lanny@gskinner.com>
1 parent 95276c1 commit 173ca88

File tree

5 files changed

+16
-11
lines changed

5 files changed

+16
-11
lines changed

VERSIONS.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Version NEXT [Not Released]
1+
Version 0.5.0 [Not Released]
22
************************************************************************************************************************
33
CRITICAL (may break existing content):
44
- removed all onEvent handlers (ex. onClick, onTick, onAnimationEnd, etc)
@@ -16,6 +16,7 @@ CRITICAL (may break existing content):
1616
ie play("music", {loop: -1, volume: 0.5})
1717
- Changed WebAudioPlugin to test if XHR is available for local files rather than assuming it is not.
1818
- implement basePath support for local loading and with PreloadJS
19+
- updated registerSound and registerManifest to return true if a source has already been loaded.
1920
- added getter/setter to volume and pan of SoundInstance, to allow tweening.
2021
- added polyfil for Array.indexOf to allow IE8 support
2122
- fixed an issue with Sound.removeSound not stopping audio with that src.

docs/soundjs_docs-NEXT.zip

232 Bytes
Binary file not shown.

lib/soundjs-NEXT.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/soundjs/Sound.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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
*/

src/soundjs/version.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ this.createjs = this.createjs || {};
2727
* @type String
2828
* @static
2929
**/
30-
s.buildDate = /*date*/"Wed, 11 Sep 2013 18:29:40 GMT"; // injected by build process
30+
s.buildDate = /*date*/"Thu, 12 Sep 2013 21:45:41 GMT"; // injected by build process
3131

3232
})();

0 commit comments

Comments
 (0)