MPMusicPlayerController “Hello World!” iPhone app with source code

Once I was listening to iPod music player on my iPhone and I decided to look up lyrics for a song that was playing. What do you usually do in that case? Right, go to Google in mobile Safari (that takes 40 seconds, AT&T 3G hi!). What next? Navigate through several adful websites and finally, yes! The good one that has lyrics… Wait, now you’re listening to a completely different song, ughh.

So, the idea came to my mind, why not just to create an app that identifies a song that’s playing right now, no Google, no clicking around, just give me my lyrics right away when I open the app!

So, let’s begin. Open XCode and choose a View-based Application.

Let’s download a LoadingView class by Matt Gallagher to make it all fancy, before we dive into the development. I love using this view, there are several reasons: it’s super fast, because it’s using QuartzCore and it’s highly customizable. This view comes full-screen sized but I think it looks better like this:

Also, now we should add QuartzCode and MediaPlayer frameworks to the project.

We’ll be using UIWebView to download lyrics from lyrics.wikia.com (it’s the best source that I found and URLs are very convenient – http://lyrics.wikia.com/Artist:Song).

First, we need to add UIWebViewDelegate protocol to MainViewController class to handle all user clicks inside the UIWebView browser (otherwise it’ll crash), then add some views and methods.

P.S. Don’t try to submit it to Apple, because they won’t approve it – lyrics are considered to be a copyrighted material. However, I don’t care, with Doejo’s Apple developer account I can use it as long as I want 🙂

P.S.S. There’s no garbage collection, if you want to get this thing working properly you need to dealloc objects that were created. Take a look at what Apple recommends here.

Phil Tadros - Founder
Founder of Doejo an award winning Innovation Studio and INC 5,000 Company. Tadros also Founded and Manages Space by Doejo a Co-working loft in River North. Tadros was featured on CNBC “Planet of the Apps” and a Moxie Award winner. Tadros’s ability to build and support strong, diverse teams with collaborative cultures, coupled with preference for innovation, has made him an authority on design and technology.