Registering for Playback Notifications

To efficiently work with music playback, it is important to be aware of the state of the music player. When you are dealing with the music player, there are three notifications to watch. The “now playing” item has changed, the volume has changed, and the playback state has changed. These states can be monitored by using NSNotificationCenter to subscribe to the afore-mentioned events. The sample app uses a new convenience method, registerMediaPlayerNotifications, to keep the sample app’s code clean and readable. After the new observers have been added to NSNotificationCenter, the beginGeneratingPlaybackNotifications needs to be invoked on the player object.

- (void)registerMediaPlayerNotifications ...

Get iOS Components and Frameworks: Understanding the Advanced Features of the iOS SDK now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.