leoasis / react-sound

Sound component to play audio in your web apps
ISC License
486 stars 80 forks source link

Sound from local directory. #31

Open AnHal opened 7 years ago

AnHal commented 7 years ago

Hi, i am creating an App with React/Meteor. I installed react-sound and it works fine, when I take an Url from the Internet, for example those from the example. But actually, I wanted to play music, stored in a local directory. I tryed many diffrent absoulute and relative paths, but I always get this error:

   sound0: Failed to load / invalid sound? Zero-length duration reported. 

Is it event possible to play music from local directory or do i have to consider any special things? Thanks

C-Higgins commented 7 years ago

I believe you need to have the files in the /public/ directory to reference them like this

leoasis commented 7 years ago

You need to be able to serve those sounds with a server, then use that url in the Sound component.

aozfen commented 6 years ago

we have no chance to use it from a local file?

peinguin commented 6 years ago

You can. If open html from local file.

aozfen commented 6 years ago

Could you give an example on this? How will I do

peinguin commented 6 years ago

https://stackoverflow.com/questions/371875/local-file-access-with-javascript - but user should select file by hands https://developer.mozilla.org/en-US/docs/Archive/Misc_top_level/Same-origin_policy_for_file:_URIs

peinguin commented 6 years ago

https://en.wikipedia.org/wiki/Same-origin_policy

AndreiEgorov commented 6 years ago

I am storing my audio files in an Audio collection in mongoDB. How can I access those audio files and play them? Or is there a way to reference them as url?