I am developing a web application with HTML and Javascript and one of the functions of that web applications is that it alerts user with blinking and audio signal when certain events happen.
Sometimes users would just have that webapp open and not interact with it, only waiting for alert. The problem here is, that chrome doesn't allow sound, until user have already interacted with webpage, so I cannot alert users with audio signal.
Is there a way to bypass this? Is there a way to allow this in Google Chrome settings? It would be okay if it would be on a local level only, as said application will only be running on a few Android tablets on a Google Chrome.
edit:
code for playing sound:
let audio = new Audio('Sound/gentle_sms.mp3');
function PlaySound()
{
audio.loop=true;
audio.play();
}
function StopSound()
{
audio.pause();
audio.currentTime = 0;
}
function PlaySound() is called from socket event listener