I am trying to add a sound to my Noty instance to my Laravel 5.7 app and seem to be running into some issues. The errors I am getting are Uncaught(in promise) DOMException and Get... 404, but I am using the Path intellisense addon in VScode so I am sure it is right. Here is my code:
new Noty({
text:'Example',
type:'info',
timeout:2000
}).on('onShow', function() {
var audio = new Audio('../../../public/sounds/appointed.mp3');
audio.play();
})
.show();
I really appreciate your help
While
../../../public/sounds/appointed.mp3is correct relative path when you use the editor, it doesn't exist on the server (404 page).Files that are in the
public/folder should be accessed by using/.Your mp3 file should be accessed by using
/sounds/appointed.mp3(withoutpublic/).Test it out by trying to load mp3 file http://localhost/sounds/appointed.mp3