CreateJS / SoundJS

A Javascript library for working with Audio. It provides a consistent API for loading and playing audio on different browsers and devices. Currently supports WebAudio, HTML5 Audio, Cordova / PhoneGap, and a Flash fallback.
http://createjs.com/
MIT License
4.42k stars 838 forks source link

SoundJs with preloadjs fails when sound already cached in browser #283

Closed bknill closed 6 years ago

bknill commented 6 years ago

I'm registering the sound in Preload and playing the sound very soon afterwards. If I clear the cache it plays fine,

If I reload the page I get this error

soundjs.min.js:18 Uncaught TypeError: Cannot read property 'length' of null
    at WebAudioPlugin.a._handlePreloadComplete (soundjs.min.js:18)
    at soundjs.min.js:17
    at a._dispatchEvent (soundjs.min.js:17)
    at a.dispatchEvent (soundjs.min.js:17)
    at a._sendComplete (soundjs.min.js:17)
    at a.b._handleAudioDecoded (soundjs.min.js:18)
    at AudioContext.<anonymous> (soundjs.min.js:17)

Any clues what might cause it?

lannymcnie commented 6 years ago

There is an issue where the list of early-created sounds was being cleaned up improperly, which I have corrected. I also put in some error-handling which will prevent this particular error - however I am not entirely sure it will prevent whatever is causing the problem you posted.

I have pushed the fix to GitHub, and will build new NEXT libs shortly. I might sneak this change into the 1.0.x that is getting posted to the CDN.

If you are able to, I would appreciate a sanity test of the fix, and if it still persists, or there is other odd behaviour, a simple test case would be awesome.

Thanks!

weituotian commented 5 years ago

@lannymcnie not work!

aitutor22 commented 5 years ago

I'm still having this issue with the next version. Is there something I need to be doing?

jfraboni commented 5 years ago

Same, still experiencing this issue.

nguyenhuutinh commented 4 years ago

try this
createjs.Sound.removeAllSounds();