0

I know the New audio() is expecting a url but I am trying to load a local file and can not seem to get it to play. The path must be wrong cause it will play any existing url that I assign to a var including "data:audio/ogg;base64,T2dnUwACAA...". Example: "C:\Users\Jon\Desktop\tng-doorbell.mp3" will not play- it does nothing. Thanks.

Jon Hogan
  • 3
  • 1
  • 2

2 Answers2

1

You need to load it via a server like Apache or IIS. Try Wampserver

It has to be a URL over http:// and not file://

Rohit Agre
  • 1,528
  • 1
  • 14
  • 25
  • What I using it for is a notification in a script on a 3rd party's page, local files, mp3 wav aren't going to play- I don't think after reading up on the restrictions.Using FireFox btw. – Jon Hogan Apr 15 '16 at 23:02
  • Correct. You need to host it somewhere.. Maybe Dropbox or Google drive and give a direct link in your code – Rohit Agre Apr 16 '16 at 03:03
1

Due to security issues, many HTML5 APIs will refuse to operate on local files (or will impose severe restrictions on how the file can be used). Your best bet is to configure a local webserver, and access whatever you need through it.

Haroldo_OK
  • 6,612
  • 3
  • 43
  • 80