Skip to content

Instantly share code, notes, and snippets.

@callumj
Created February 12, 2014 10:12
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 callumj/8952878 to your computer and use it in GitHub Desktop.
Save callumj/8952878 to your computer and use it in GitHub Desktop.
MPNowPlayingInfoCenter setting
- (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