Soundcloud CORS

本秂侑毒 提交于 2020-01-24 10:24:10

问题


Soundcloud api should support cors as I read in documentation (http://developers.soundcloud.com/docs/api/guide#crossdomain).

But I think this is not the case:

XMLHttpRequest cannot load http://ec-media.soundcloud.com/fxguEjG4ax6B.128.mp3?longurldata... Cannot make any requests from null.

What am I doing wrong? I'm trying to play stream with aurora.js + mp3.js.


回答1:


Unfortunately, at the moment, the CORS headers aren't enabled on the mp3 files that are delivered from the CDN (ec-media subdomain). You'd need to use a proxy if you need to request these files via XHR.

CORS headers are enabled on the JSON data returned from the API, but not the mp3s.

If you are trying to use Web Audio API you could use mediaElementSource and load the mp3 via setting src property of the audio to be used as “media source” as described here.




回答2:


Supporting CORS isn't an all-or-nothing, the server end chooses to support specific origins (and headers, and methods).

In your case, you appear to be making the call from a local file (origin null), e.g. an HTML document you've loaded via double-clicking from the file system or similar. Apparently they don't allow that.



来源:https://stackoverflow.com/questions/15099895/soundcloud-cors

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!