# Music Start on Model Load

**URL:** <https://forum.babylonjs.com/t/music-start-on-model-load/21440>\
**Category:** Questions\
**Created:** [June 6, 2021, 12:56pm UTC](https://forum.babylonjs.com/t/music-start-on-model-load/21440 "2021-06-06T12:56:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![insidef1](https://avatars.discourse-cdn.com/v4/letter/i/f14d63/32.png) [@insidef1](https://forum.babylonjs.com/u/insidef1)\
**Post date:** [June 6, 2021, 12:56pm UTC](https://forum.babylonjs.com/t/music-start-on-model-load/21440/1 "2021-06-06T12:56:32Z")

</div>

Afternoon all,

Thanks for everyone’s help so far. Thus far in my Babylon.js journey I have managed to load my own textured model (exported from blender) and have a camera auto-rotate around it when the model loads up. I also have managed to get atmospheric music to play in the background. However, the music will only start when an un-mute button is clicked in the top corner of the screen. Ideally I want this music to start as soon as the model is loaded and starts auto-rotating.

On various searches it suggests that sounds won’t play under html5 until there is some user interaction. Is this the case? I have found some reference to controlling this behaviour and hiding the mute button using the following:

BABYLON.Engine.audioEngine.useCustomUnlockedButton = true;  
BABYLON.Engine.audioEngine.unlock();

But whilst this hides the un-mute button the music doesn’t play. Again it appears as though the second command can only be called via a user interaction.

If it is not possible to start the music with no user interaction then the second best option would be for the model to not load automatically and both the BABYLON.SceneLoader and BABYLON.Sound commands to be called at the same time from a single user click. is this possible?

Current Code below for reference:

// Add your code here matching the playground format

```
    const createScene = function () {

        //Create Scene    

        var scene = new BABYLON.Scene(engine);  

        //Load Model

        BABYLON.SceneLoader.ImportMeshAsync("", "", "Formula_project_assetto_FINAL_TRIAL.babylon");

        //Camera Controls

        var camera = new BABYLON.ArcRotateCamera("camera", 0, 0, 10, new BABYLON.Vector3(), scene);

        camera.setPosition(new BABYLON.Vector3(3.5, 1.5, 3.5));

        camera.attachControl(canvas, true);

        camera.useAutoRotationBehavior = true;

        camera.autoRotationBehavior.idleRotationSpeed = 0.25;

        //Light Control

        const light = new BABYLON.HemisphericLight("light", new BABYLON.Vector3(1, 1, 0));

        //Sound Control

        const sound = new BABYLON.Sound("f1-theme", "http://localhost:5000/Formula 1 Theme Live in Concert by Brian Tyler.mp3", scene, null, { loop: true, autoplay: true });

        

        //BABYLON.Engine.audioEngine.useCustomUnlockedButton = true;

        //BABYLON.Engine.audioEngine.unlock()

        return scene;

    };
```

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [June 7, 2021, 8:27am UTC](https://forum.babylonjs.com/t/music-start-on-model-load/21440/2 "2021-06-07T08:27:13Z")

</div>

> [@insidef1](#):
>
> On various searches it suggests that sounds won’t play under html5 until there is some user interaction. Is this the case?

Essentially, yes. Chrome has some policies that may make autoplay work, but you can’t really control them: [Chính sách tự động phát trong Chrome &nbsp;|&nbsp; Blog &nbsp;|&nbsp; Chrome for Developers](https://developers.google.com/web/updates/2017/09/autoplay-policy-changes)

So:

> [@insidef1](#):
>
> the second best option would be for the model to not load automatically and both the BABYLON.SceneLoader and BABYLON.Sound commands to be called at the same time from a single user click

is the best thing to do.

Simply put your loading code in the function handling the button click and in the onsuccess callback of the scene loading, start the sound.

---

<div class="post-metadata">

**Author:** ![insidef1](https://avatars.discourse-cdn.com/v4/letter/i/f14d63/32.png) [@insidef1](https://forum.babylonjs.com/u/insidef1)\
**Post date:** [June 7, 2021, 4:05pm UTC](https://forum.babylonjs.com/t/music-start-on-model-load/21440/3 "2021-06-07T16:05:41Z")

</div>

Hello - many thanks for this. I thought that might be the case and I’ve implemented this as suggested. Thanks again!
