Objective C (iPhone) Strange Behaviour with musicPlayer API

156 Views Asked by At

I'm developing a music app for iPhone that uses the built in iPod library. I noticed a strange behaviour that I was able to replicate in Apple's sample code entitled "AddMusic" simply by NSLogging out what was going on.

My question is:

Has anyone else encountered this, or better yet found a solution?

The behaviour is:

With the musicPlayer API, one is able to get notifications on state changes of the iPhone's built in iPod. For example, when a song is played or paused, it can shoot off a notification.

You can also queue up songs to be played by invoking a mediaPicker which accesses the music library.

The problem occurs while the API is switching the song from the currently playing one to the new song, which was cued up.

What I noticed is that, in both Apple's sample code and my code, the player state change notification is fired 5 or 6 times, seemingly at random. A sample NSLog is as follows:

2013-08-27 17:24:14.676 AddMusic[418:60b] Paused
2013-08-27 17:24:14.937 AddMusic[418:60b] Playing
2013-08-27 17:24:14.943 AddMusic[418:60b] Paused
2013-08-27 17:24:14.950 AddMusic[418:60b] Playing
2013-08-27 17:24:15.842 AddMusic[418:60b] Paused
2013-08-27 17:24:15.853 AddMusic[418:60b] Playing

I am using X-Code DP6 and iOS 7 B6, but I don't think this is an NDA issue since these commands are old. Just thought I'd provide this information in case this is a new problem.

Thanks!

0

There are 0 best solutions below