6. Sound - Osilos/openfl-game-template GitHub Wiki

To add sounds, go in directory assets/sounds/

Musics sounds must be in musicsdirectory and sfxs must be in sfxs

Warning : All sound must be in .ogg format (to have compatibility with all platforms)

Example :

assets/sounds/musics/home.ogg
assets/sounds/sfxs/jump.ogg

Then, add yours sound in assets/sounds/sounds.json

Example :

{
    "jump": 1, // "1" correspond to your volume
    "dead": 0.5,
    "homeTheme": 0.9
}

To play sound, call Sound.playSfx("jump") or Sound.playMusic("homeTheme") you can also mute music or sfxs by calling :

Sound.muteSfx()
Sound.unmuteSfx()

or

Sound.muteMusic()
Sound.unmuteMusic()