Archive

Posts Tagged ‘programming’

Prebuffering iPhone Audio Streams For Gapless Playback

August 10th, 2009 pj4533 4 comments

prebuff

I have been working on a project that requires me to stream audio from a webserver to the iPhone, starting at an offset in an mp3 file. I showed how to modify Matt Gallagers awesome AudioStreamer code in a previous post. What I find myself doing quite a bit is stopping play on one file and starting play on another. Obviously you want the gap between tracks to be as minimal as possible.

The easy way to do this would be just to keep track of duration in a ’switcher’ object, Read more…

A Simple Quick Reusable XML Parser For The iPhone

August 5th, 2009 pj4533 2 comments

logo

I found that I was needing an XML parser for nearly every iPhone application I was writing. Once you figure out the streaming nature of NSXMLParser, it really isn’t very difficult to use. However, since I was always having the didStartElement/foundCharacters/didEndElement functions in each application, I really wanted to break them out into a reusable class.

I found that most my XML implementations were VERY simple, as I was just using it for data storage and transfer. However, of course, each XML is different so my class has to handle that properly.

After making several iterations, I settled on using an NSArray for the root of the XML file. Each node is a NSDictionary with three object/key pairs:

Read more…

Streaming Audio To the iPhone Starting At An Offset

August 1st, 2009 pj4533 12 comments

Starting with Matt Gallagher’s awesome AudioStreamer class, I wanted to extend it in a couple ways:

  1. Be able to play my radio show .mp3s hosted on my website (static files, not streams)
  2. Be able to start playback at any point in the file (startWithOffsetInSecs)
  3. Obviously, have it work on the iPhone
  4. Be able to have full control of audio & drawing while audio is playing

Actually, #3 & #4 are really what pushed me to find Matt’s class in the first place…so they aren’t really extensions of AudioStreamer, but rather why I chose to use AudioStreamer in the first place. The other major option was using something like MPMoviePlayerController. But that had several limitations which I won’t get into here.
Read more…