andrew_ Posted August 17, 2015 Share Posted August 17, 2015 I'm doing this: var assets = [];var loader = new BABYLON.AssetsManager(scene);var toLoad = [ {ltype: "m", name : "lilly", src : "assets/507601_Lilly.mp3" } ]; toLoad.forEach(function(obj) { if (obj.ltype=="m") { var binaryTask = loader.addBinaryFileTask(obj.name, obj.src); binaryTask.onSuccess = function (task) { music = new BABYLON.Sound("lilly", task.data, scene, function () { // Sound has been downloaded & decoded music.setVolume(0.1); music.play(); }, { loop: true }); }}and then this:loader.onFinish = function() { // call the createScene function createScene(); // run the render loop engine.runRenderLoop(function(){ scene.render(); });}loader.load();This works fine in that the music plays, but it doesn't start until the scene has been rendered for about 2 seconds.I was trying to get the music to start first, or at the same time as the scene animation starts. Thanks for help! Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted August 17, 2015 Share Posted August 17, 2015 This should work..I'm pulling in @davrous as he is the master of sound andrew_ 1 Quote Link to comment Share on other sites More sharing options...
davrous Posted August 17, 2015 Share Posted August 17, 2015 Hi! I'm going to have a look (or a ear ) asap.Can you please repro it on the playground?David andrew_ 1 Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted August 17, 2015 Share Posted August 17, 2015 One thing I found out looking at when a sound is specified in FileLoader.ts is it puts a block in until the sound is ready to play. Something like this:var sound;sound = new BABYLON.Sound("sceneSound.wav", soundsRootDir + "sceneSound.wav", scene, () => { scene._removePendingData(sound); }, {autoplay: true, loop: false});scene._addPendingData(sound);Maybe this will delay rendering till sound is ready, then block removed in success callback. Wonder what happens should url be wrong though. When implementing this using asset manager, the block and release might go in different spots. I know very little about AssetsManager. andrew_ 1 Quote Link to comment Share on other sites More sharing options...
andrew_ Posted August 18, 2015 Author Share Posted August 18, 2015 Thank you very much. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.