Corporation Unknown Logo

Happy Birthday

They say the best gifts are handmade. For my wife’s birthday last year, I came up with the idea to write a simple little “birthday card” application and slip it on her iPhone to surprise her. I scanned in some graphics from a real birthday card and digitally chopped it up and added some animation to give it that true “Made in Flash” feel, and stayed up until 1 AM working to get ad hoc provisioning working on her phone. I even had it register a protocol handler so I could send her an email while she was at work saying “click this link: <happy://birthday> from your iPhone email” and it would launch the application. It was a hit.

The one thing I had planned but couldn’t get working was for the appliction to play a song. Core Animation took enough of my brainpower at the time, and the idea of learning AudioUnit in such a short time was quickly dismissed—I would have to “ship” without that feature. But a recent post by Mobile Orchard’s Dan Grigsby showing the simplicity of AVAudioPlayer prompted me to pull the code off the shelf and give it an update.

What a dusty shelf that was. The project was configured for SDK 2.1(!) and some of the code was indicative of “tweaking until it works.” As I was updating the project for 3.0, moving code to Interface Builder and swapping lots of Core Animation code for UIView animations, it dawned on me that this has surprisingly many little tidbits of code and would be good to share.

Before even providing the download link, I will warn that this version is somewhat “build your own.” My personal version looks like this:

But since I don’t have distribution rights for the song or art, this version will get “art” (disabusing you of any notion of hiring me as a Graphic Artist) created by me, and not have a song to play. A fresh build will look like this:

When you replace the graphics with your own, and add a song named “Happy Birthday.mp3” you will have your own customized version.

Features this little application demonstrates:

  • Animate view fade in and out transitions.

  • Add repeating animations to views so they “wobble”.

  • Launch in full screen without status bar.

  • Register a protocol handler so any “happy://” url will launch it.

  • Play a bundled mp3 (taken directly from the Mobile Orchard post).

  • Autorotate view using autoresizing properties.

(Ad Hoc installation before 1 AM is left as an exercise for the reader.)

Download Happy.zip

The code is BSD Licensed. Feel free to explore it, enjoy it a bit and maybe even pleasantly surprise your own significant other.

Comments