Retrieving an mp3 URL from the mp3-stream link

1,153 views
Skip to first unread message

danfinlay

unread,
Mar 20, 2012, 10:50:17 PM3/20/12
to SoundCloudAPI
I just asked this on Stack Overflow but got no answer there and
noticed people getting answers here, so please forgive the double
post:
http://stackoverflow.com/questions/9778794/playing-soundcloud-audio-with-audiostreamer

I've got an iOS project that involves streaming audio from SoundCloud.
I'm under the impression that the mp3-download link only works 100
times, and that won't work for my purposes, so I'm trying to get the
"mp3-stream" link working.

Unfortunately, when I pass SoundCloud's "mp3-stream" link to my
AudioStreamer (an open sourced audio streaming class made available
here: http://cocoawithlove.com/2009/06/revisiting-old-post-streaming-and.html),
the console replies "No audio data found," and a dialog box pops up on
the iPhone that says "File Error: Unable to configure network read
stream."

I have a feeling this has to do with the way SC's "mp3-stream" link
involves forwarding, but I don't know how to properly retrieve the
file link from the data that link replies with. Right now if I send a
GET request with the mp3-stream link, I get a NSConcreteMutableData
object with some data I don't know how to read, in this case:
<3c657272 6f723e34 3031202d 20556e61 7574686f 72697a65 643c2f65
72726f72 3e>

Any help would be appreciated!

Daniel Skantze

unread,
Mar 21, 2012, 2:04:30 AM3/21/12
to soundc...@googlegroups.com
I would recommend you to use the AVAudioPlayer classes, which works well (although it is a pain to work the queue while in background).

Earlier I used the AudioQueue api and I got it to work there as well.

Do you send your apikey along with the stream or download url?

/Daniel

Skickat från min iPhone

> --
> You received this message because you are subscribed to the Google Groups "SoundCloudAPI" group.
> To post to this group, send email to soundc...@googlegroups.com.
> To unsubscribe from this group, send email to soundcloudap...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/soundcloudapi?hl=en.
>

danfinlay

unread,
Mar 21, 2012, 2:31:55 AM3/21/12
to SoundCloudAPI
I actually just discovered the "SCAudioStream" class in I think the
older SoundCloudAPI? But it wants "SCSoundCloudAPIAuthentication".
Is that the same as my key? Are either of those the same as my client
ID or secret?

Should I just add the key, whichever it is, at the end of the mp3-
stream URL? Any sample code would be greatly appreciated, I'm
confused about the key and authentication to play part. I got logging
in and uploading to work, but playing seems somehow harder!

danfinlay

unread,
Mar 21, 2012, 2:36:50 AM3/21/12
to SoundCloudAPI
Also, Apple's documentation says AVAudioPlayer is not for playing
audio streams:
http://developer.apple.com/library/mac/#documentation/AVFoundation/Reference/AVAudioPlayerClassReference/Reference/Reference.html

Are you proposing I use it to play the mp3 file directly? And if so,
won't that be limited by the number of times SoundCloud allows a
download?

Daniel Skantze

unread,
Mar 21, 2012, 5:41:04 AM3/21/12
to soundc...@googlegroups.com
Oh, I am sorry, it is AVPlayer I meant. Not AVAudioPlayer. Apple should really do something about their documentation on Audio stuff. It is pretty messy. Before I learnt about AVPlayer I ended up doing the AudioQueue thing which is pretty low level and messy (requires lots of thread synchronization). 


/Daniel

danfinlay

unread,
Mar 21, 2012, 12:49:28 PM3/21/12
to SoundCloudAPI
So passing the AV-Player a "stream_url" link will work, even though it
itself isn't an audio file?

Daniel Skantze

unread,
Mar 21, 2012, 4:09:03 PM3/21/12
to soundc...@googlegroups.com
Yes, that is what I do in my app


On Mar 21, 2012, at 17:49, danfinlay wrote:

> So passing the AV-Player a "stream_url" link will work, even though it
> itself isn't an audio file?
>

danfinlay

unread,
Mar 23, 2012, 4:07:02 PM3/23/12
to SoundCloudAPI
You mentioned passing my apikey along with the link. Could you
explain exactly which number the "apikey" is? (Cookie, client_id,
secret token?)

Also, what is the syntax to include the apikey with the stream_url
when passing it to the AVPlayer?
Reply all
Reply to author
Forward
0 new messages