Forums » HTML5 Framework » Preloading / Playing sound effect with no extension at the file name. »
| Wasin Thonkaew | Preloading / Playing sound effect with no extension at the file name. | ||
|---|---|---|---|
|
Added by Wasin Thonkaew 11 months ago
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. |
||
| Wasin Thonkaew | RE: Preloading / Playing sound effect with no extension at the file name. | ||
|
Added by Wasin Thonkaew 11 months ago
I just spotted
and took a look at AudioManager class in Document that I can specify it in this way
Is that supposed to mean I just provide both of the sound format, or one of them for cocos2d-html5 to look at it? |
||
| Shengxiang Chen | RE: Preloading / Playing sound effect with no extension at the file name. | ||
|
Added by Shengxiang Chen 11 months ago
Because the different browsers support different sound format. //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); |
||
| Wasin Thonkaew | RE: Preloading / Playing sound effect with no extension at the file name. | ||
|
Added by Wasin Thonkaew 11 months ago
Okay thanks! I got that. |
(1-3/3)
