This way.
$( document ).ready(function() {
var snd = new Audio("alarm.wav");
snd.play();
});
And he throws me the following error:
Uncaught (in promise) DOMException: Failed to load because no supported source was found.
I see another way to do it:
$( document ).ready(function() {
let embed = $('<embed/>',{
'src' : 'alarm.wav',
'autostart' : 'false',
'width' : '0',
'height' : '0',
'id' : 'sound1',
'enablejavascript' : 'true'
});
embed.appendTo($('body'));
function PlaySound(soundObj) {
var sound = document.getElementById(soundObj);
sound.Play();
}
PlaySound("sound1");
});
And this other one throws me the following error:
Uncaught TypeError: sound.play is not a function