Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Howler 2.0 - fade() function doesn't update volume property #539

Closed
shibekin69 opened this issue Jun 8, 2016 · 4 comments
Closed

Howler 2.0 - fade() function doesn't update volume property #539

shibekin69 opened this issue Jun 8, 2016 · 4 comments
Milestone

Comments

@shibekin69
Copy link

shibekin69 commented Jun 8, 2016

Hi!

Playing around with Howler 2.0, and I notice that when doing a fade() on a Howler object, upon finishing the fade in or out, the final tweened volume of the object doesn't get updated to reflect the new volume value. So for example:

var sound = new Howl({...});
sound.fade(0, 1, 500);

//Once sound has faded in type the ff in console. Returns 0 rather than 1
sound.volume();

So if sound has a volume of 1, then I fade it out to 0, sound.volume() returns 1 rather than 0.

I also noticed that I can't just assign to the onfade (function) property once the Howl object has been initialized like so:

var sound = new Howl({...});
sound.onfade = function() { console.log('This should show in the console after fading, right?'); }
sound.fade(0, 1, 500);

Update: I went back to Howler 1.1.29, and the fade() function there updates the volume property after the tween.

@goldfire goldfire added this to the 2.0 milestone Jun 8, 2016
@goldfire
Copy link
Owner

goldfire commented Jun 8, 2016

Do you have a test case? I just setup a fiddle with what I thought you were describing, but it works as expected: https://jsfiddle.net/w6Lfodk0/.

Also, you can't assign directly to onfade, that can only be assigned as part of the Howl options. There is an on and a once method for listening for events in 2.0.

@zatnas
Copy link

zatnas commented Oct 23, 2017

I have tested the code and it didn't work as it supposed to be.

var sound = new Howl({
	src: 'https://dl.dropboxusercontent.com/s/1ycx2rq7szhi8sx/test2.mp3',
	autoplay: true,
	volume: 0,
	onload: () => {
		console.log(sound.volume());
		sound.fade(0, 1, 5000);
		sound.once('fade', function(){
			console.log(sound.volume());
		});
	},
	onplay: () => {
		console.log('Sound played')
	}
});

Output is

0
Sound played
0

Both sound.volume() returns 0

goldfire added a commit that referenced this issue Nov 2, 2017
@goldfire
Copy link
Owner

goldfire commented Nov 2, 2017

@eZethNesthrown Thanks for the test case! The latest commit on master should fix this.

bhaskarp-vg pushed a commit to ValueGlobal/howler.js that referenced this issue Feb 7, 2018
ringcrl pushed a commit to ringcrl/howler.js that referenced this issue Apr 21, 2019
@developeratul
Copy link

Is there any way to fade at the ending of the audio?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants