SoundCloud Api redirect confusion and Audio Api Streams

后端 未结 1 510
难免孤独
难免孤独 2021-01-15 23:56

I am attempting to make a request to the SoundCloud API. Then when I get the response I set the stream_url as the source of an < audio > element.

This works:

相关标签:
1条回答
  • When you run the request for

     https://api.soundcloud.com/tracks/140326936/stream?client_id=5c6ceaa17461a1c79d503b345a26a54e
    

    you get a HTTP 302 Found response from the server, which is a URL redirect (http://en.wikipedia.org/wiki/HTTP_302). This will cause your browser to load from the new URL that the server returns, and thus the two requests you see. The server basically says "yeah, I know where to find that file, ask that guy over there".

    The reason why one works and the other not, I'd think, is that https://ec-media.sndcdn.com has the Access-Control headers set while https://cf-media.sndcdn.com doesn't. This is an issue with the server configuration and unfortunately nothing you can control from the client side. Dunno if it's a deliberate move by soundcloud or if it's something you could ask them about.

    0 讨论(0)
提交回复
热议问题