views:

406

answers:

2

Ok, this isn't an easy question (at least not yet).

I've got AVAudioPlayer working beautifully: I download an mp3 with NSURLConnection then play that data with AVAudioPlayer. My question is how could I start AVAudioPlayer playing at an arbitrary point in the mp3?

I can start downloading at an arbitrary point by setting HTTP headers, no problem. The first two packets of the mp3 download appear to be header information and it seems that AVAudioPlayer needs these to play correctly. Likewise if I take a continuous mp3 and chop a section of data out mid-way AVAudioPlayer doesn't like it.

Is there a way I could peer inside the mp3's encoding to seamlessly stitch the last quarter of the file onto the header? Or anything more obvious?

+1  A: 

Check out : http://cocoawithlove.com/2009/06/revisiting-old-post-streaming-and.html - It walks you through how to setup a streaming MP3 player, which I think is close to what you are after.

David Smith
I'm familiar with that post and I've got a streaming MP3 player already but nowhere can I find anyone who's implemented the feature I'm after.
1ts
+1  A: 

Don't use AVAudioPlayer. Use Core Audio. You have much more control over the audio and can make it play any bit of a file you choose.

AVAudioPlayer is a very simple class that doesn't give you much control.

Jay
Thanks for the tip, I'll check it out.
1ts