Playing local mp3 file in Visual Studio Code?

Pretty sure the browser is going to block the call to play because there is no user interaction.

Chrome:

Uncaught (in promise) DOMException: play() failed because the user didn't interact with the document first.

Firefox:

Uncaught (in promise) DOMException: The play method is not allowed by the user agent or the platform in the current context, possibly because the user denied permission.


Edit:

Using an audio element in the DOM still works in Chrome but is blocked in Firefox.

Example which works in Chrome, but not Firefox:
https://codepen.io/lasjorg/pen/MWgJRaq

With user interaction (works in both)
https://codepen.io/lasjorg/pen/GRKreyJ

If you had an element inside the DOM, like a play button, it should work as well with the Audio constructor in both browsers.

const audio = new Audio('someSong.mp3');
const btn = document.querySelector('#play');

btn.addEventListener('click', () => {
  audio.play();
});