You are here

How to Build a Realtime Radio App Using the Apple Music API

The Apple Music API lets iOS applications directly control Apple Music playback to provide a more engaging User Experience by incorporating music into third-party apps. The API does have some limitations, such as not allowing apps that offer the ability to save or download music without explicit authorization from the source. But, it still offers a wide range of uses, including checking a user’s membership status and country, queuing up songs based on song ID, and inspecting and creating playlists.

As an example of its potential, shortly after the API’s release, music identification service Shazam used it to add a new feature that allows users to identify a song, then add it directly to their Apple Music Library. In this tutorial on the PubNub blog, Keith Martin explains how to build a real-time radio station app using the Apple Music and iTunes Search APIs.

The radio app will allow Apple Music members to search for and queue songs for playback and DJ their own station that gathers user feedback through upvotes and downvotes in real-time. The project begins with including the SDK using CocoaPods and setting up a PubNub account to get your unique keys. Followers must then request access to their Apple Music library, and membership confirmation will allow the searchItunes() Function to begin using the iTunes Search API. Search results are displayed in a table view so the user can select a track for their playback queue.

Users then select a name for their radio station, which will also be used for their channel, and tracks added to the queue will begin playing. PubNub’s Presence feature detects when another user has joined the channel and delivers the track data and current playback time to synchronise playback across devices. This playback time is automatically updated whenever the DJ changes playback, such as skipping forwards or backwards.

Listening to a radio station is as easy as selecting a station from a table view showing all the stations that have been created, and voting up or down is done by publishing to the channel. The author provides all of the code necessary for you to set up your own broadcast and begin getting user feedback.

Be sure to read the next Application Development article: 9 Red Flags to Look Out for When Selecting an API

Original Article

Realtime Radio Station Application using the Apple Music and iTunes Search API’s