aadsm / jsmediatags

Media Tags Reader (ID3, MP4, FLAC)
Other
748 stars 128 forks source link

Can't read local mp3 file id3 info. #61

Closed zhangruize closed 7 years ago

zhangruize commented 7 years ago

My requirement is try to get the id3 info of local mp3 file which in the same dir of the html page. I know node.js could work, but I need to show these info in html page by js. But these sample code seems didn't work, is there any possible solution on this? Following code all can't work: jsmediatags.read("1.mp3"... jsmediatags.read("http://localhost/1.mp3"...

aadsm commented 7 years ago

jsmediatags.read("http://localhost/1.mp3"... should work, what is the error you're getting?

zhangruize commented 7 years ago

Here is all error info: XMLHttpRequest cannot load http://localhost/1.mp3. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.

ghost commented 7 years ago

This is not JSMediaTags problem. I can read mp3s on 127.0.0.1

aadsm commented 7 years ago

@zhangruize if you're getting that error this means you're making a cross domain request which is not allowed unless the server you're connecting to offers a "Access-Control-Allow-Origin" header. Which address is your app running under? Everything needs to match including the port, say if your app is running under "http://localhost:8080/" and you try to access "http://localhost/" then you won't be able to.

I'm closing because this is not an issue with the library itself.