Cc.AudioEngine doesn't work on Firefox

Hi,

If you call

cc.AudioEngine.getInstance().playMusic(path); or
cc.AudioEngine.getInstance().playEffect(path);

an error occured on Firefox:
*TypeError: this._ctx.createGainNode is not a function (cc.SimpleAudioEngine.js Line: 795)*

on Chrome and IE it works well!

Hi Matthias,

This problem has been solved, please get the latest codes from the github or modify " this.*ctx.createGainNode" to " this.*ctx.createGain".

Thanks for feedback.
David

Hi David,

Ok, thank you! Now playMusic() and playEffect() works on each browser.

But now there is another problem:
cc.AudioEngine.getInstance().setEffectsVolume(volume);
doesn’t work!
If you set the effect-volume to 0 and call .getEffectsVolume , the return value is 0, but all effects are playing.

cc.AudioEngine.getInstance().setMusicVolume(volume); works well.

Hello, Matthias.

I have tested this problem by your way on our test case, it works correctly.

on tests’ CocsDenshion Test > press “Repeat Sound Effect”> press “Decrease Sound Effect Volume” many times to set effect volume to 0 (the effect is playing, but no sound.) > press “Increase Sound Effect Volume” many times, then the effect is sounding.
Here are some codes about the test:
var addEffectsVolume = function () { cc.log("add effects volume"); audioEngine.setEffectsVolume(audioEngine.getEffectsVolume() + 0.1); };
@
var subEffectsVolume = function {
cc.log;
audioEngine.setEffectsVolume
0.1);
};@

Hi David,

I have tried your test cases, but it don’t works correctly!
Please try the following:
press “Repeat Sound Effect” —> press “Decrease Sound Effect Volume” till you can’t hear any Sound —> press “Decrease Sound Effect Volume” once or twice more. Now if you press “Repeat Sound Effect” or “Play Sound Effect” again you can hear the sound, although the effects-volume is “0”! You can also try to change the test code to following:

var subEffectsVolume = function {
cc.log;
audioEngine.setEffectsVolume;
};

Now if you press “Repeat Sound Effect” —> press “Decrease Sound Effect Volume” you can’t hear the Effect, but if you now press “Repeat Sound Effect” or “Play Sound Effect” again, the effect is playing, although the effects-volume is “0”! Now if you press “Decrease Sound Effect Volume” once again, nothing will happens.

In my game i play an effect for each button-click. I have a “Sound-button”, which the user can press to turn all effects and the backgroundmusic off. Therefor I set the effects-volume and the music-volume to “0” if the user press this “Sound-button”, but if the user press any other button you can hear the effect , although the effects-volume is “0”!

Have a nice day!
With best regards, Matthias

This problem is not only on firefox, also on Chrome!
IE 10 works correctly.

Thank you, Matthias

This problem has been solved.
Here is the details: https://github.com/cocos2d/cocos2d-html5/pull/1301

Hi David,

Sorry, but I have found some new problems… :slight_smile:

On Safari (Mac OS) the AudioEngine returns the following error:
*TypeError: ‘undefined’ is not a function (evaluating ‘this._ctx.createGain()’) … (SimpleAudioEngine.js Line:1262)*—> similar to the error which was occured on firefox (see my first post).

On Opera, the AudioEngine also doesn’t work. Opera doesn’t return any error, but no music and effects are playing.

With best regards, Matthias

Oh, my god.

I should add some codes for compatibility. more details at: https://github.com/cocos2d/cocos2d-html5/pull/1304

And about the Opera, I have tested our testcase on it. It only supports “ogg” and “wav” format, please provide “ogg” format audio files.

Thanks
David