welcome to this tutorial , in most apps you need to play a sound effect on click , hover and etc ... .
I am using the result from #10 read it to get what we are doing here :
first you need to find sounds that you need , unfortunately many of providers are selling these stuff (cruel!) but I found this website , thanks to them !
var click = document.getElementById("click");
const playPromise = click.play();
if (playPromise !== null){
playPromise.catch(() => { click.play(); })
}
this code will get the tag we create in html part with id of click , then tries to play it , mostly in first attempt .play() returns null and you will see the Uncaught (in promise) DOMException in console . so we are using the if to retry to play it !
welcome to this tutorial , in most apps you need to play a sound effect on click , hover and etc ... . I am using the result from #10 read it to get what we are doing here :
first you need to find sounds that you need , unfortunately many of providers are selling these stuff (cruel!) but I found this website , thanks to them !
now we need to define our sounds with audio tag :
so as you can see I have three mp3 sounds that named them hover , hover2 , click .
after this we need to use them in our function hover1 is for entrance of friendinfo div
hover2 is to for exit of friendinfo div
click is for click on friendinfo div
the code related to audio is :
this code will get the tag we create in html part with id of click , then tries to play it , mostly in first attempt
.play()
returns null and you will see theUncaught (in promise) DOMException
in console . so we are using the if to retry to play it !this is it , easy peasy !