I have a problem in angular with a script for a piece of HTML code that uses A-Frame to make 3D objects and interact with it. The problem is that you can give play with sound as an attribute of a-frame but when the script is tried or from the typescript it does not work and everything has been tried. I hope they can help me
<script>
AFRAME.registerComponent('play', {
init: function () {
console.log("entro al script play");
var variable = document.querySelector('#yellow');
this.variable.addEventListener('click' , function(){
variable.components.sound.playSound();
});
}
});
AFRAME.registerComponent('stop', {
init: function () {
console.log("entro al script stop");
var variable = document.querySelector('#yellow');
this.variable.addEventListener('click' , function(){
variable.components.sound.stopSound();
});
}
});
<a-box id="yellow" color="yellow" position="0 0 -5" sound="src:#bichota">
<!-- Play -->
<a-sphere color="green" radius="0.25" position="-1 1 0" play></a-sphere>
<!-- Stop -->
<a-sphere color="red" radius="0.25" position="1 1 0" stop></a-sphere>
</a-box>
In typescript I get this error "Property 'components' does not exist on type 'Element'"
var entity= document.querySelector('#yellow') ;
if(entity != null){
console.log("enity" , entity);
entity.components.sound.playSound();
}