How to emit a sound when passing the mouse in ANGULAR?

Asked

Viewed 132 times

0

I would like it to make a sound by hovering the mouse in the menus of my application, but I don’t know how to do it

HTML:

<div class="itemsMenu" ng-mouseover="playAudio()"><i class="fas fa-users"></i></div>

main.componentts.:

playAudio(){
    let audio = new Audio();
    audio.src = "/assets/menu.wav";
    audio.load();
    audio.play();
  }

1 answer

0

Try changing the tag div to audio. It will work in the following browsers

Firefox 3.5+, Chrome 3+, Opera 10.5+, Safari 4+, IE 9+

<audio>
    <source src="audio/beep.mp3"></source>
    <source src="audio/beep.ogg"></source>
</audio>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.