Preloading / Playing sound effect with no extension at the file name

I took a look at MoonWarrior source code, and spot that for sound effect (either background music, or sound effect), whenever the need to preload stuff or play we don’t have to specify extension (.mp3, .ogg) at the end of the file name.

Does cocos2d-html5 automatic select the right sound format to preload / play for particular browsers? So, we just provide all format like .mp3, and .ogg and place them there?

Note. I tested with full sound effect file (with extension), it can’t play or load.

I just spotted

cc.AudioManager.sharedEngine().init("mp3");

and took a look at AudioManager class in Document that I can specify it in this way

cc.AudioManager.sharedEngine().init("mp3,ogg");

Is that supposed to mean I just provide both of the sound format, or one of them for cocos2d-html5 to look at it?

Because the different browsers support different sound format.
So we provide different audio format (e.g. mp3 and ogg) for browser detection

//for example

   cc.AudioManager.sharedEngine().init("mp3,ogg");

   var s_background = "Resources/background";
   var s_effect = "Resources/effect";
   var g_ressources = [ 
    {type:"bgm", src:s_background },
    {type:"effect", src:s_effect }
   ]

cc.AudioManager.sharedEngine().playBackgroundMusic(s_background, true);
var s = cc.AudioManager.sharedEngine().playEffect(s_effect);

Okay thanks! I got that. :slight_smile: