BabylonJS: Playing Sounds and Music Cheat Sheet

var music = new BABYLON.Sound(
   "Music", "sound.wav", scene, null, { 
      loop: true, 
      autoplay: true 
   }
);

The following parameters related to the sound engine:

  • Name − Name of the sound.
  • URL − URL of the sound to be played.
  • Scene − Scene to which the sound has to be played.
  • Callbackfunction − The callbackfunction which is called when the sound is ready to be played. At present, it is null. We will go through a few examples and learn how to use it.
  • Json object − This object has basic details of what needs to be done.
  • sound.autoplay − With this, the sound plays automatically once the file is downloaded.
  • loop: true − This means the sound will continuously play in a loop.

Leave a Reply

Your email address will not be published. Required fields are marked *