How to access SoundCloud public stream?

How to play a track from the SoundCloud URL, which, for example, I got from the xml response from the request

<stream-url>https://api.soundcloud.com/tracks/31164607/stream</stream-url> 

I should have thought it would be so simple:

 https://api.soundcloud.com/tracks/31164607/stream&client_id=my_client_id 

while i get

 <error>401 - Unauthorized</error> 

All I want to do is use it in Silverlight MediaElement, so I need to set the URL of the MediaElement Source property.

I checked the application that I wrote about 2 years ago, and THEN, accessing the stream URL was as simple as for a public track:

 http://api.soundcloud.com/tracks/18163056/stream&consumer_key=MY_CONSUMER_KEY 

however this does not work anymore.

For example, all I needed to do in C # was:

 MediaElement me = new MediaElement(); me.Source= new Url("http://api.soundcloud.com/tracks/18163056/stream&consumer_key=MY_CONSUMER_KEY"); me.Play(); 

Any clues would be appreciated.

I had a response on a Microsoft forum that seems to imply that SoundCloud may not be available for streaming to Microsoft Windows 8 Metro devices without consuming the entire stream before playback starts - which is troubling and seems to imply what to do authentication is possible, this would have to be done completely in the url querystring request for using the header:

(The next answer is the answer to the following question: “I can access the audio stream via HTTP using MediaElement, however I need to access it through https, in which I need to add oAuth information to the header of the initial request. How is this done using MediaElement , and if this is not possible, what is the workaround for using the audio stream in Metro 8, which requires header streaming? ')

"Direct access to the underlying network stream is not currently allowed by MediaElement. Because of this, there is currently no way to change the HTTP request header to include any additional authentication information. However, you have control over the URL. You could theoretically configure an HTTP proxy service that translates the HTTP GET request parameters into the required oAuth credentials. Keep in mind that this is just a theoretical solution. In practice, you may find other behavior. oAuth yourself through a raw streaming socket and transfer migrated multimedia data to MediaElement through “Set Source” and “Random Access Stream.” Keep in mind that this method has serious limitations in order to use the “random access stream” using ME, you need to make sure that all data is accessible before than transferring them to ME. "

The proxy server service is not scalable for the application, which is simply distributed free of charge, since each stream must go through the proxy server. And a raw stream socket, although getting around this, would mean that playback cannot start until the entire file has been downloaded - and this contradicts all current UX (User Experience) recommendations.

So again, if anyone has any advice or information on how the whole authentication thing can be achieved in querystring instead of using headers, I would appreciate it!

+4
source share
4 answers

I am a little confused about whether you link to a public or private track? If this is a public track, you do not need to send any authentication data, just your client ID.

When I request https://api.soundcloud.com/tracks/31164607/stream?client_id=YOUR_CLIENT_ID , I get a 302 redirect to the correct mp3 stream.

+10
source

Remember that adding parameters to the URL should start with ? not & . This can (more than likely) cause you to get 401 (SC does not match client_id).

+3
source

After authentication, a link like this

http://api.soundcloud.com/tracks/ 103229681 / stream? consumer_key = d61f17a08f86bfb1dea28539908bc9bf

works fine. I am using Action Script.

+2
source

I follow Tom because he pays attention to the nature of the URL. My HTTP requests accidentally started working with an error today, and I was prefacing my client_Id with ? . As soon as I changed this single ? on & , he started to work. Therefore, in my case, SC did not collect my client_Id because I used the wrong character. I think, depending on where in the request we speak specifically, it is worth noting that the differences are between ? and & really matter.

0
source

All Articles