Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top