Sound plays not suport cross domain
brunolight opened this issue · 3 comments
-
I use version 1.3, thank you all for the great job;
-
this version was possible to upload the files using a path 'cross domain';
$(sounds[name]).prop("src", url);
sounds[name].load();
sounds[name].preload = "auto";
sounds[name].volume = volume || settings.volume; -
in the current version does not load files using a path 'cross domain' (XMLHttpRequest );
-
I tried to modify the current version to allow to call 'cross domain', modifying XMLHttpRequest will be possible? Algume have any suggestions?
-
I could not update the version for that reason.
-
Sorry for English, sorry for not knowing how to program, sorry for not knowing where to seek help ..
Hello.
There is a big difference of getting music files via XHR or loading them via simple HTML5 Audio tag. HTML5 Audio does not use XHR, so it have no problems with getting files from other domains.
But the new 2.x version is based on Web Audio API. Completely new browser API for playing music. So, now, we load music files via XHR with full control of that process.
XHR in 2.x have support of CORS by default. But, to get this work, external server with music files should return special header, which will tell the browser that it has allowance to load this file.
Please check this article: https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS
And be sure that external server returns this header:
Access-Control-Allow-Origin: *
- Ok ... thanks for optimal explanation ...
- In my case I can not modify the server serving static files ...
- I'll get around otherwise ...
- Anyway thank you ... thank you and sorry for your time
Hi again.
Remove return
in this line: https://github.com/IonDen/ion.sound/blob/master/js/ion.sound.js#L631
And you will get the latest version of ion.sound, but with fall back to HTML5 audio.