Skip to content

Commit a83ffe7

Browse files
committed
Fixed possible issues when internal preloading completes.
1 parent 83b1517 commit a83ffe7

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

src/soundjs/AbstractPlugin.js

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -284,14 +284,19 @@ this.createjs = this.createjs || {};
284284
* @protected
285285
*/
286286
p._handlePreloadComplete = function (event) {
287-
var src = event.target.getItem().src;
288-
this._audioSources[src] = event.result;
289-
for (var i = 0, l = this._soundInstances[src].length; i < l; i++) {
290-
var item = this._soundInstances[src][i];
291-
item.playbackResource = this._audioSources[src];
292-
// ToDo consider adding play call here if playstate == playfailed
293-
this._soundInstances[src] = null;
287+
var src = event.target.getItem().src,
288+
result = event.result,
289+
instances = this._soundInstances[src];
290+
this._audioSources[src] = result;
291+
292+
if (instances != null && instances.length > 0) {
293+
for (var i=0, l=instances.length; i<l; i++) {
294+
instances[i].playbackResource = result;
295+
// TODO consider adding play call here if playstate == playfailed
296+
// LM: SoundJS policy is not to play sounds late that previously failed, as it could play unexpectedly.
297+
}
294298
}
299+
this._soundInstances[src] = null;
295300
};
296301

297302
/**
@@ -301,7 +306,7 @@ this.createjs = this.createjs || {};
301306
* @protected
302307
*/
303308
p._handlePreloadError = function(event) {
304-
//delete(this._audioSources[src]);
309+
//delete(this._audioSources[src]); //LM: Not sure why this was commented out.
305310
};
306311

307312
/**

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy