In Javascript or HTML, a path starting / is an absolute path to the URLs schema, hostname & port E.G http://localhost
, http://localhost:8080
so URL of /Absolute/path/to/music.mp3
running on localhost would become http://localhost/Absolute/path/to/music.mp3
now while this might not be a problem for you, you should always use absolute filesystem paths when accessing the file system. E.G const player = new Audio('file:///Absolute/path/to/music.mp3');
this will point to the local file.
However, you might run into CORS problems if that is the case you need to disable the CORS on the browser it using, in which case you need to the answers on Electron (chromium) disable web security
If this does not work we need to see the exception that is being uncaught,
player.play().catch(e => console.error("audio play failed with: "+e))
if you have the console output showed, or player.play().catch(e => alert("audio play failed with: "+e))
new Audio(...)
) that is trying to read local files from a web page. – Bethuneplayer.play().catch(e => console.error(e))
? – Baruch