Format Audio missing (flac)


In the documentation it says that all audio files supported by the browser work. But the .flac format doesn’t seem to work.

However, it is supported by all browsers. It is for me the best format for browsers (free, quality)

Would it be possible to add this flac format ?

I tested to verify the operation live and it works.

<audio controls>
	 <source src="Data/Musics/Fight_sek_loop.flac" type="audio/flac" />		  

When creating a sound, try to set skipCodecCheck: true in the options object (5th parameter of the constructor).

1 Like

Ok I will try this Evgeni. Edit: It worked. Thanks very much.

I also have a similar question. Currently you can only add one audio format.

But if you use mp3, it won’t work on firefox, ogg will work for him.
But if we use the ogg, it will not work on Chrome, but will work on firefox.

The audio of html5 allows to put several audio sources. If a format is not supported, the second source is test.
BY having several formats for a BABYLON.Sound, it would make it possible to be sure that a format is read.

Is this something already possible or could it be supported?

cc @docEdub

The Sound constructor’s urlOrArrayBuffer argument can be an <audio> element, so you can create an <audio> element with multiple sources and pass it in if you want. I haven’t tried it myself, yet, but the code indicates it should work.

@docEdub You mean something like this should work ? [“sound.mp3”, “sound.ogg”]

this.musicScenes = new BABYLON.Sound("musicScenes", ["sound.mp3", "sound.ogg"], game.scene, null, {
            loop: true,
            autoplay: true,
			streaming: true,
			skipCodecCheck: true

Using an array of URLs like that works for .mp3 and .ogg files if skipCodecCheck is set to false. The URLs in the array are checked for compatibility in the order they’re given, so you may want to put the .ogg file before the .mp3 file, like ["sound.ogg", "sound.mp3"], that way the .ogg file will be used if the browser supports it, and the fallback will be the .mp3 file. If you put the .mp3 file before the .ogg file, then browsers that support both formats will only use the .mp3 file since it comes before the .ogg file in the array.


Ok, I understand. Thanks very much