0

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!

MattLoszak
  • 585
  • 2
  • 5
  • 15
  • This could be because you have registered more than once for the notification. – amergin Aug 28 '13 at 19:28
  • @amergin Unfortunately that's not the case... I'm getting notifications properly for many other cases (ipod pause and play in control center while app is open, manual pause and play with UIButton in my app, etc). Yesterday I found someone else on SO with the same problem, looking for the link now. – MattLoszak Aug 28 '13 at 19:32
  • Someone else has the same problem, with slightly different causes: http://stackoverflow.com/questions/11364503/ios-mpmusicplayercontrollerplaybackstatedidchangenotification-called-multiple-t – MattLoszak Aug 28 '13 at 19:34
  • Looking into it further it looks like an apple bug that reoccurred in ios7 betas - suggest you submit a radar. – amergin Aug 29 '13 at 00:31

0 Answers0