How to fade out the volume of an audio?

I play a lot of different audio files separately using audioEngine. I need to fade out the volume of one exact audio file.
Is there an easy way to do it?

If you want to change one audio’s volume,first play the audio to cc.audioEngine.playEffect or cc.audioEngine.playMusic.
you can use cc.audioEngine.setEffectsVolume(value);
here you can use for statement or action to set value from 1 to 0;

That will change the volume for all effects
I need to play one effect with different volume others with another volume

I use cc.AudioSource components for all sound fx and music. In that way I can easely manage volumes of audios seperately. I defined several layers my grouping audiosource components and now I can mute or make low volume on any layer I want. Check documentation about cc.AudioSource.

In that case it would work, but cocos has already music and effects grouping which is not implemented well. So one way is to create your own sound grouping as you did or use howler and create a proper wrapper with bunch of new features that doesn’t exist in cc.audioEngine (like changing the pitch or fade in out) until creator will improve its own implementation of the audioengine. Audio is pretty important thing in game development but poorly implemented in creator.

1 Like