Jump to content

Running sound on init


Raitch
 Share

Recommended Posts

TypeError: Failed to execute 'setPosition' on 'AudioListener': The provided float value is non-finite.
    at Scene._updateAudioParameters 

( audioEngine.audioContext.listener.setPosition(listeningCamera.position.x, listeningCamera.position.y, listeningCamera.position.z); )

I'm getting an inconsistent error when trying to run a sound at the beginning of my game. I can't really find any ways to have the sound run when it's ready. Is this relevant to the camera or something? It solves itself if I just let it wait a couple of seconds, but that's not really ideal for me.

I also use assetsManager to preload the sound and run the `new BABYLON.Sound` call.

Cheers!

Link to comment
Share on other sites

if you just need sound playing with no 3d effects(position, direction, etc),

you can simply use the html5 <audio> tag.

 

<audio id="mySoundId" src="./assets/sounds/mySound.mp3" loop autoplay />

// loop parameter causes the audio to auto-replay.
// autoplay parameter starts the audio file when it's loaded.


//JS controls;
mySoundId.play();
mySoundId.pause();
mySoundId.volume = x;

 

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...