Copy link to clipboard
Copied
I'm trying to learn the soundJS in order to add an effect on loading a frame. Struggling to get it to work.
Is there a particular method for html5 to add sound effects as in actionscript format?
I've tried the following without success:
createjs.Sound.on("fileload", this.loadHandler, this);
createjs.Sound.registerSound("Blop.wav", "bloop");
function loadHandler(event) {
// This is fired for each sound that is registered.
var instance = createjs.Sound.on("bloop");
instance.on("complete", this.handleComplete, this);
instance.volume = 0.5;
}
in the actions panel at the frame where you want the sound to play:
var sound1 = createjs.Sound.createInstance("bloop");
sound1.play();
or
createjs.Sound.createInstance("bloop").play();
or
createjs.Sound.play("bloop");
Copy link to clipboard
Copied
what do you mean by "loading a frame"?
do you mean you want a sound to play when the playhead enters a particular frame? or do you mean you are actually loading something from outside your project and you want a sound to play when loading is progressing or when loading is complete or something else?
Copy link to clipboard
Copied
Sorry when it enters a particular frame.
Thanks
Copy link to clipboard
Copied
is the sound an external file (eg, Blop.wav) that you want to load during run-time (more coding and forethought needed) or is the sound imported into your library (easier to code and implement)?
Copy link to clipboard
Copied
It's in the library with a linkage "bloop".
Essentially I'd like the sound to play when particular boxes appear in the timeline, if possible.
Copy link to clipboard
Copied
in the actions panel at the frame where you want the sound to play:
var sound1 = createjs.Sound.createInstance("bloop");
sound1.play();
or
createjs.Sound.createInstance("bloop").play();
or
createjs.Sound.play("bloop");
Copy link to clipboard
Copied
Hello thanks for those.
I had tried the first one suggested before that didn't work.
Now tried the others and none work.
I've added the script on frame 1 in an actions panel, I assume that's correct?
Thanks
Copy link to clipboard
Copied
if any of them failed, embed* a screenshot of showing your library (with the id "bloop" visible) and your actions panel showing the code that failed (and any other code in that frame).
*
Copy link to clipboard
Copied
Thanks for your help on this
Copy link to clipboard
Copied
that looks ok.
select the wav file in the library and play the sound in the library window to make sure it's not corrupted. or even better, import a different wav or mp3 and check that to see if it's a probem with your sound file.
if you confirm it's not a sound file issue, check if you have some unrelated error causing a problem by opening your browser's developer console and checking for an error.
if you seen none (other than the message port and css errors), upload your fla to to file server and post a link.
Copy link to clipboard
Copied
Yes the file was corrupt, tried another sound file that works, but not in Safari, tested it through Firefox and Chrome both working on there.
Does Safari require additional for this?
Thanks
Copy link to clipboard
Copied
open the safari developer console and see if there's an error.
if not, check if safari requires user interaction (eg, button click) to start sound. (apple's a bit of a nanny about controling things.)
Copy link to clipboard
Copied
Yes it appears it requires a trigger, as the sounds worked after a mouse click event.
Is there any way around this on Safari?
Thanks
Copy link to clipboard
Copied
i doubt it but you should google it see if there's a (temporary) work-around (which will eventually fail when apple figures it out).
Copy link to clipboard
Copied
Ok thanks.
Will have a look.
Really appreciate all the assistance the forum gives, it's very welcoming to novices like me.
Copy link to clipboard
Copied
you're welcome.