0

I am trying to load a local mp3 file in the audio tag but I get Not allowed to load local resource in browser console.

I saw this post which says I should be using file:/// in the src but that did not help either.

<audio id="myAudio" src="file:///E:\ss.mp3"></audio>

enter image description here

I am using Chrome, Windows 10. Please advise. Thanks.

Community
  • 1
  • 1
An Illusion
  • 769
  • 1
  • 10
  • 24

2 Answers2

0

Local audio cannot be played by using it in src of the audio tag. This is because browsers are sandboxed and cannot and should not have access to user file system (ref).

I solved this by adding a file input element that requires user to choose a music file which then can be loaded into the src (ref, ref).

Community
  • 1
  • 1
An Illusion
  • 769
  • 1
  • 10
  • 24
0

Local audio can be played only if the document is also a local resource.

Btw, although Chrome accepts backslashes, you should normally use slash for file URIs.

ozdefir
  • 191
  • 1
  • 4