Babylon JS Sound issue

I cant figure out what Im doing wrong here.

I created a code pen here:

I used codepen because I wanted to control what libs I was pulling in. If you look in the console you should see the error: “Uncaught TypeError: Cannot read property ‘canUseWebAudio’ of undefined”.

Im using preview builds so perhaps this is a bug?


I know with chrome you have to allow it to play sound, so there should be a small pop up in the upper right corner. That’s what the playground does, anyway. Lets ask @Deltakosh

EDIT: I modded you codepen. copy-paste this to overwrite your javascript

var canvas = document.getElementById("canvas");

        var createScene = function () {
            var scene = new BABYLON.Scene(engine);
            var music = new BABYLON.Sound("Violons", "", scene, null, { loop: true, autoplay: true });

            return scene;
      __createScene = createScene;
        var engine = new BABYLON.Engine(canvas, true, { preserveDrawingBuffer: true, stencil: true });
        var scene = createScene();

        engine.runRenderLoop(function () {
            if (scene) {

1 Like

It seems that the third argument to the engine constructor does the trick. Even if you pass an empty object {} it works with the inital example provided by @tkmoney.


Maybe this is a bug. In BJS 4.0.3 it works without providing the third argument.

Definitely a bug! I will fix that

1 Like


Will be good for next nightly