Created
February 12, 2014 10:12
-
-
Save callumj/8952878 to your computer and use it in GitHub Desktop.
MPNowPlayingInfoCenter setting
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)reflectNowPlaying | |
{ | |
if (_activeTrack == nil) | |
return; | |
NSMutableDictionary *activeInfo = [[NSMutableDictionary alloc] initWithDictionary:[[MPNowPlayingInfoCenter defaultCenter] nowPlayingInfo]]; | |
if (artworkNeedsReflecting || metaNeedsReflecting) | |
{ | |
[activeInfo setObject:[_activeTrack title] forKey:MPMediaItemPropertyTitle]; | |
[activeInfo setObject:[_activeTrack artistTitle] forKey:MPMediaItemPropertyArtist]; | |
[activeInfo setObject:[_activeTrack duration] forKey:MPMediaItemPropertyPlaybackDuration]; | |
[activeInfo removeObjectForKey:MPMediaItemPropertyArtwork]; | |
metaNeedsReflecting = NO; | |
} | |
if (_currentTiming != nil) | |
[activeInfo setObject:_currentTiming forKey:MPNowPlayingInfoPropertyElapsedPlaybackTime]; | |
if (_activeArtwork != nil && artworkNeedsReflecting) | |
{ | |
[activeInfo setObject:_activeArtwork forKey:MPMediaItemPropertyArtwork]; | |
artworkNeedsReflecting = NO; | |
} | |
[[MPNowPlayingInfoCenter defaultCenter] setNowPlayingInfo:activeInfo]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment