I was having some trouble getting sounds to play dynamically using javascript today. I’m not sure dynamically is the right word but basically I wanted different sounds to load and play on the click of a button using javascript without having to preload the sounds.
At first I tried using a single embed object, then changing the src of the embed on a button click and using embedObj.Play(); but for some reason changing the source of the file stopped that happening.
My second idea was to replace the entire embed code each time, and then call Play on the embed to get it to play. Still no luck!
Finally after a bit of searching I found somebody that had managed to do it. Its similar to my second idea only instead of calling .Play() on the embed object you just use autostart=true
in the embed code, simple!