Copy link to clipboard
Copied
HTML5 canvas how do I do that so I fade out with single mp3 sound.createjs
Copy link to clipboard
Copied
start a loop (eg, tick) and adjust the sound's volume in the listener function.
Copy link to clipboard
Copied
Can you show me an example with code how I do it.
Copy link to clipboard
Copied
this.s.addEventListener("click",f.bind(this));
this.fadeOut = fadeOutF.bind(this);
function f(){
this.sound = createjs.Sound.play("soundID");
this.addEventListener("tick", this.fadeOut);
}
function fadeOutF(){
this.sound.volume -= .02;
if(this.sound.volume <= 0){
this.removeEventListener("tick", this.fadeOut);
}
}
Copy link to clipboard
Copied
Thank you for helping me show code examples. Now I can add it to my slideshow.
Copy link to clipboard
Copied
you're welcome.
Copy link to clipboard
Copied
I have this at the beginning of the frame of the slideshow:
createjs.Sound.on("fileload", handleFileLoad1);
createjs.Sound.registerSound("music1.mp3", "MySound1");
function handleFileLoad1()
{
createjs.Sound.play("MySound1");
}
but now several frames ahead I want to fade out the sound because I don't want a button. How do I do that?
Copy link to clipboard
Copied
assign a reference to your sound (when it's created) and start the fade when you want.