Audio Engine Volume

Cocos Creator v2.0.2

cc.audioEngine.setMusicVolume(0.7) works properly and affects only Music and returns the value 0.7, but
cc.audioEngine.setEffectsVolume(0.7) affects both Music and Effect sounds and returns undefined. Meanwhile the cc.audioEngine.getMusicVolume() will return correct music volume , which means that I can do a workaround

cc.audioEngine.setEffectsVolume(0) // to mute effects, which will mute also music
cc.audioEngine.setMusicVolume(cc.audioEngine.getMusicVolume()) // to set the correct music volume

So there is a bug in setEffectsVolume @jare

I’ve checked also v2.0.4 and the issue is still there. Also noticed that cc.audioEngine.setVolume(1) the value 1 causes an error

cc.audioEngine.setVolume(1);
17:34:55.239 CCAudio.js:469 Uncaught TypeError: Failed to execute 'setTargetAtTime' on 'AudioParam': The provided float value is non-finite.
    at l.volume (CCAudio.js:469)
    at h.19.t.setVolume (CCAudio.js:229)
    at Object.setVolume (CCAudioEngine.js:236)
    at <anonymous>:1:16

@jare can you have someone take a look?

Also I noticed that playMusic overrides the current music. Is it made on purpose? Because I need several layers of music in my game and I would appreciate to be able to play several musics separately

  1. I test it is normal, can you give me a demo project ? thx
  2. Music there can only be one, you can use ‘audioEngine.play’
1 Like

Did you play in a loop a music and after set the EffectVolume to 0?

cc.audioEngine.playMusic(this.musicClip, true);

and after call

cc.audioEngine.setEffectsVolume(0); ? It’s easy to reproduce