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!