a-entity sound component is set but not audible

a-frame
#1

I’m very new to a-frame framework, I’m trying to build my first scene to see how things work on VR, everything is going as planned except for the sound. I’ve set a sound attribute just like the one in the a-frame page, “https://aframe.io/docs/0.9.0/components/sound.html” but the sound isn’t audible. Any ideas?

<a-scene>
      <a-assets>....<audio id="tieSound" 
                   src="tiesound.mp3"></audio>

      <a-asset-item id="TieFighter" 
                        src="tiefighter.glb"></a-asset-item>
      </a-assets>
...
     <a-entity 
             id="3DObject"
             gltf-model="#TieFighter" sound="src: #tieSound; volume: 2; rolloffFactor: 2; refDistance: 1; autoplay: true; distanceModel: exponential; loop: true"
             position="10 40 -900"
             scale="1.2 1.2 1.2"
             rotation="0 0 0 "
             animation="property:object3D.position.z; to: 1200;   dir: normal; dur: 15000; loop: true">
      </a-entity>
#2

Hey @MrDaveMustaine, welcome to the Glitch forum!

I’m not an a-frame expert by any means, so hopefully someone with more expertise might jump in and help. Would you be willing to share your project name so anyone who wants to take a look can see the full context of what you’re trying to accomplish?

#3

Hi @MrDaveMustaine,

I’m not sure, exactly what you are expecting and what your project is- if you share a url, that would help to understand your issue better.
However, if you are just expecting it to start playing when the page loads, your code looks fine to me- I tried your sound settings on a tester project I have and it worked to play audio on loop like expected with my audio file. The volume set to 2 is fairly low, so perhaps you just can’t hear it? Or maybe there’s something going on with the file or file path? Could it be a CORS issue? Try setting the crossorigin=“anonymous” in the audio asset.

But, one thing that I learned the hard way is that if you’re viewing on an iOS device, audio won’t play without user input- and not an internal A-frame raycaster event. You can set up a mute toggle button that users have to tap to enable audio or a play button to start the entire animation. There is a note at the top of the aframe sound docs page you referenced.

1 Like