This three-part tutorial series will teach you how to build a custom music player with the iOS SDK. Read on!
Welcome to the first of three tutorials in a step-by-step series on building a custom music player with the MediaPlayer framework. In a previous tutorial on Mobiletuts+, I demonstrated how to access an iOS device music library within your own application. This Tuts+ Premium series will focus on building a much more complex player with a custom interface. In this first series installment, we will create the project and display a list of the user's songs and albums.
NOTE: In order to test this app you will need a physical iOS device. You will also need to be a member of the paid iOS developer program in order to deploy the demo app onto your device for testing.
Step 1: Creating the Project
Open Xcode and select "Create a new Xcode project". Select "Empty Application" and click "Next". Enter a name for your project (I called mine "Music") and make sure you select iPhone for device family and select all the checkboxes, except the "Use Core Data" checkbox. After that, click "Next" and choose a place to save your project and then click "Create".
Step 2: Setting Supported Orientations
We only want to use our application in portrait mode, so go to the Supported Interface Orientations section and deselect the landscape orientations.
Step 3: Import the MediaPlayer Framework
Go to the "Build Phases" tab and expend the "Link Binary With Libraries" option. Click the "+" button to add a new Framework. Type "MediaPlayer" into the search box and select the
MediaPlayer.framework option that appears in the list. Click "Add" to include this framework in the linking phase of your project.
Step 4: Create a Storyboard
Go to "File" > "New" > "File..." or press ⌘N to create a new file. Go to the "Use Interface" section, select "Storyboard and click "Next". Make sure that the Device Family is set to iPhone and click "Next" again. Name your storyboard MainStoryboard and click "Create".
￼Now we have to link the storyboard to our project. Select the project name in the navigator menu of Xcode and select the current target (in our case "Music"). Next select the "Summery" tab and go to the "iPhone / iPad Deployment Info" section. Once there select our storyboard called "MainStoryboard" for the Main Storyboard.
Get the Full Series!
Joining Tuts+ Premium. . .
For those unfamiliar, the family of Tuts+ sites runs a premium membership service called Tuts+ Premium. For $19 per month, you gain access to exclusive premium tutorials, screencasts, and freebies from Mobiletuts+, Nettuts+, Aetuts+, Audiotuts+, Vectortuts+, and CgTuts+. You'll learn from some of the best minds in the business. Become a premium member to access this tutorial, as well as hundreds of other advanced tutorials and screencasts.