Skip to content

Instantly share code, notes, and snippets.

@msching
Last active March 30, 2016 03:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save msching/9ac1c803183bb12cdd4e to your computer and use it in GitHub Desktop.
Save msching/9ac1c803183bb12cdd4e to your computer and use it in GitHub Desktop.
update NowPlayingCenterInfo for iOS 8.2 (even if you only wish to update the artwork).
- (void)updateNowPlayingCenter:(NSDictionary *)info
{
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.2") && SYSTEM_VERSION_LESS_THAN(@"8.3"))
{
NSString *zeroLengthString = @"\u200B";
NSString *title = info[MPMediaItemPropertyTitle];
NSString *currentTitle = [MPNowPlayingInfoCenter defaultCenter].nowPlayingInfo[MPMediaItemPropertyTitle];
NSUInteger index = [currentTitle rangeOfString:zeroLengthString].location;
if (index == NSNotFound)
{
info[MPMediaItemPropertyTitle] = [NSString stringWithFormat:@"%@%@",title,zeroLengthString];
}
else
{
info[MPMediaItemPropertyTitle] = title;
}
}
[MPNowPlayingInfoCenter defaultCenter].nowPlayingInfo = info;
}
@jpittner
Copy link

I've noticed that this works if I change the image once or twice, but after that it just stops updating it until something more drastic changes (eg playback rate). I've also got this issue that after I set the whatever changes to the nowPlayingInfo center, after about 500ms it'll reset everything to empty, and I'll have to re-apply the changes. What on earth, apple!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment