Re: MPMusicPlayerController playbackState
Re: MPMusicPlayerController playbackState
- Subject: Re: MPMusicPlayerController playbackState
- From: Matt Neuburg <email@hidden>
- Date: Wed, 20 Apr 2011 09:13:14 -0700
On Wed, 20 Apr 2011 08:29:08 -0400, Phillip Mills <email@hidden> said:
>I have a simple program that uses code such as:
>
> MPMusicPlayerController *player = [MPMusicPlayerController applicationMusicPlayer];
> [player setQueueWithQuery:entityQuery];
> [player beginGeneratingPlaybackNotifications];
> [player play];
>
>In case it matters, 'entityQuery' always references a single item.
>
>What then happens is that my MPMusicPlayerControllerPlaybackStateDidChangeNotification handler gets called twice with (playbackState == MPMusicPlaybackStatePlaying). There are no intervening calls, which first got me wondering how 'playing' to 'playing' can be defined as a state change. Some debugging revealed that userInfo for the notification contains a MPMusicPlayerControllerPlaybackStateKey item which is 0 on the first call and 1 on the second.
>
>Assuming (at least somewhat reasonably) that the userInfo code should match the advertised state and checking the associated enum, it seems as if the first call should have reported 'Stopped' rather than 'Playing'.
>
>Anyone have any better information on this? If there's documentation on when and why notifications are sent (and the expected state transitions) beyond the implications in their names, I haven't been able to find it.
It's a fact that certain MPMusicPlayerController notifications tend to be called twice in quick succession. What I do is ignore one of the calls if they are extremely close together in time. It hadn't occurred to me to examine the extra info in the userInfo dictionary; you may have discovered a way of distinguishing the calls, in which case yours is a better solution. m.
--
matt neuburg, phd = email@hidden, <http://www.apeth.net/matt/>
A fool + a tool + an autorelease pool = cool!
Programming iOS 4!
http://www.apeth.net/matt/default.html#iosbook_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden