Last active
March 30, 2016 03:09
-
-
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).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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!