Bucle falso, tamaño de grupo 1.
La ejecución de sound.playSound() reproduce correctamente el sonido, pero sound.isPlaying sigue siendo verdadero incluso después de que se haya reproducido el sonido completo.
Ya intenté agregar el detector de eventos 'finalizado por sonido' en la entidad, pero tampoco se activa.
Debe haber un estado apropiado en alguna parte... ¿verdad?
Puede realizar un seguimiento del estado del componente de sound escuchando el evento con sound-ended . A continuación, haga clic en el botón para reproducir un sonido, permanecerá rojo hasta que termine la pista de audio.
<script src="https://aframe.io/releases/1.3.0/aframe.min.js"></script> <script> AFRAME.registerComponent("foo", { init: function() { const soundComp = this.el.components.sound; // grab the `sound` component // play the sound when the user clicks the button this.el.addEventListener("click", evt => { this.el.setAttribute("color", "red") // turn the button red soundComp.playSound(); // playsound }) // catch the `sound-ended` event this.el.addEventListener("sound-ended", evt => { this.el.setAttribute("color", "green") // turn it back to green }) } }) </script> <a-scene cursor="rayOrigin: mouse" raycaster="objects: a-sphere"> <a-assets> <audio id="ding" crossorigin="anonymous" src="https://gftruj.github.io/webzamples/arjs/sound/sound/Ding-sound-effect.mp3" preload="auto"></audio> </a-assets> <a-sphere position="0 1 -3" radius="0.25" color="green" sound="src: #ding; autoplay: false" foo ></a-sphere> </a-scene>