• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Fade out mp3

Participant ,
May 03, 2020 May 03, 2020

Copy link to clipboard

Copied

HTML5 canvas how do I do that so I fade out with single mp3 sound.createjs

TOPICS
How to

Views

1.2K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , May 08, 2020 May 08, 2020

assign a reference to your sound (when it's created) and start the fade when you want.

Votes

Translate

Translate
Community Expert ,
May 03, 2020 May 03, 2020

Copy link to clipboard

Copied

start a loop (eg, tick) and adjust the sound's volume in the listener function.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
May 04, 2020 May 04, 2020

Copy link to clipboard

Copied

Can you show me an example with code how I do it.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 04, 2020 May 04, 2020

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);
	}
}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
May 04, 2020 May 04, 2020

Copy link to clipboard

Copied

Thank you for helping me show code examples. Now I can add it to my slideshow.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 04, 2020 May 04, 2020

Copy link to clipboard

Copied

you're welcome.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
May 07, 2020 May 07, 2020

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 08, 2020 May 08, 2020

Copy link to clipboard

Copied

assign a reference to your sound (when it's created) and start the fade when you want.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Feb 04, 2024 Feb 04, 2024

Copy link to clipboard

Copied

Can you give me example how I do that with codes because I'm not that keen on programming.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 04, 2024 Feb 04, 2024

Copy link to clipboard

Copied

import a sound to your library.
assign it linkage id (eg, soundID);
add a button (eg, s) when you want to create your sound and start it's fade out
add the following code:
 
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);
}
}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Feb 04, 2024 Feb 04, 2024

Copy link to clipboard

Copied

I want to play the sound at the beginning and fade out later a few frames ahead. How do I do then.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 04, 2024 Feb 04, 2024

Copy link to clipboard

Copied

the user has to interact with your html before sound can start.

 

place the fadeout tick listener in whatever frame you want.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Feb 04, 2024 Feb 04, 2024

Copy link to clipboard

Copied

Thanks for your help and some programmer I will never be because I miss thinking logically. I can't solve a problem solution with equations, but I'm good at seeing it systematically. I call Sudoku, Kakuro and Hitori systematic puzzles and I can solve these three quite well, but then I have trained my ability with a lot of these. The patience is gained with in training.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Feb 04, 2024 Feb 04, 2024

Copy link to clipboard

Copied

What do you mean this "assign a reference" how do I that with code.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 05, 2024 Feb 05, 2024

Copy link to clipboard

Copied

for the sound, double click the linkage id column adjacent to your library sound.

 

for the button, use the properties panel to assign an instance name.

 

and if you're creating something using code, what are you creating?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Feb 05, 2024 Feb 05, 2024

Copy link to clipboard

Copied

I create a slideshow with pictures where I have a start button. After the start button within the frame so in the next frame there I have this code:

createjs.Sound.on("fileload", handleFileLoad1);
createjs.Sound.registerSound("music1.mp3", "MySound1");

function handleFileLoad1()
{
createjs.Sound.play("MySound1");
}

A few thousand lines ahead and I want to fade out the music that I had at the start ("music1.mp3", "MySound1").
After that I will load new music with the same codes I started with a different instance name.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 05, 2024 Feb 05, 2024

Copy link to clipboard

Copied

create a reference that you can use to fade:

 

var _this = this;

function handleFileLoad1()
{
_this.mysound1_instance = createjs.Sound.play("MySound1");
}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Feb 06, 2024 Feb 06, 2024

Copy link to clipboard

Copied

How should I write the code on fade. Should it be what I have done in the picture I have attached. On console.log I only get red warning where tick loops endlessly. How shall do I.

screen.jpg

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 06, 2024 Feb 06, 2024

Copy link to clipboard

Copied

LATEST

i can't see where you created the sound.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 06, 2024 Feb 06, 2024

Copy link to clipboard

Copied

Hi.

 

Just adding that you can also use the Tween class to fade a sound. Like this:

var sound;

this.yourButton.on("click", function()
{
	if (sound)
		sound.stop();
	
	sound = createjs.Sound.play("YourSoundLinkage");
	createjs.Tween.get(sound).wait(2000).to({ volume: 0 }, 350);
}, this);

 

Regards,

JC

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines