Am able to play sound with javascript through the following,
var snd = new Audio('sound.wav');
snd.play();
This plays the required sound but sometimes it loads slowly or might not even load at all so i encoded the sound in base 64 and tried to play it this way.
var splash = {
prefix: "data:audio/wav;base64,",
sound: [ "*base64 string here*" ] };
var snd = new Audio(splash);
snd.play();
but the sound does not play, is there a way around it ?
snd.play().catch(err=>console.log(err))you will see: "NotSupportedError: The element has no supported sources." The solution for me was to use mp3s instead of wavs. The link provided by @Fong-Kah-Chun to generate the string to pass tonew Audioworks great btw. - imjosh