Note that there are some explanatory texts on larger screens.

plurals
  1. POOpen stream_url of a Soundcloud Track via Client-Side XHR?
    text
    copied!<p>Since you can call the the Soundcloud API via XHR (because of the CORS headers it sends <a href="http://backstage.soundcloud.com/2010/08/of-cors-we-do/" rel="nofollow noreferrer">http://backstage.soundcloud.com/2010/08/of-cors-we-do/</a>, right?) I was wondering if this was possible with the audio data itself, like a tracks' stream_url for example.</p> <p>When trying to open the stream_url with a XHR (from the Client Side) using the Web Audio API, i get a <em>Origin is not allowed by Access-Control-Allow-Origin.</em> error. Is there a way to load Audio resources via XHttpRequest from Client-Side-Javascript, or is it impossible ( <a href="https://stackoverflow.com/questions/10871882/audio-data-api-and-streaming-a-no-go">https://stackoverflow.com/questions/10871882/audio-data-api-and-streaming-a-no-go</a>) ?</p> <p>Would be great as this would allow some really cool things with the Web Audio API.</p> <p>Thanks!</p> <p><strong>UPDATE</strong></p> <p>The problem might have to do with the 302 redirect you get when calling:</p> <pre><code>http://api.soundcloud.com/tracks/5646378/stream.json?client_id=[client_id] </code></pre> <p>or some other call requesting the actual media file (see comments).</p> <pre><code>HTTP/1.1 302 Moved Temporarily Server: nginx Date: Sun, 24 Jun 2012 09:58:01 GMT Content-Type: application/json; charset=utf-8 Connection: keep-alive Cache-Control: no-cache Location: http://ec-media.soundcloud.com/[...] X-Runtime: 41 Content-Length: 339 Access-Control-Allow-Methods: GET, PUT, POST, DELETE Access-Control-Allow-Headers: Accept, Authorization, Content-Type, Origin Access-Control-Allow-Origin: * X-Cacheable: NO:Cache-Control=no-cache X-Varnish: 2433107209 Age: 0 Via: 1.1 varnish X-Cache: MISS HTTP/1.1 200 OK Accept-Ranges: bytes Cache-Control: max-age=252460800 Content-Type: audio/mpeg Date: Sun, 24 Jun 2012 09:58:01 GMT ETag: "c2241e[...]41bbcf7c0d32f09" Last-Modified: Tue, 28 Sep 2010 17:57:26 GMT Server: ECAcc (fra/D484) x-amz-id-2: oB0XzQcc/[...]+mAr/a x-amz-meta-bitrate: 128 x-amz-meta-duration: 152900 x-amz-meta-job: t405jWkfNvx7 x-amz-request-id: D65[...]E1355 X-Cache: HIT Content-Length: 2445478 </code></pre> <p>The original JSON response has the CORS headers, while the location of the redirect don't.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload