I have music player app, and when app goes background it show music control on locked screen, in my case currently playing on radio artist and song. I use following:
- (void)applicationWillResignActive:(UIApplication *)application {
[[PlayerManager sharedInstance] setupInfoForLockerScreen];
}
-(void)setupInfoForLockerScreen{
MPNowPlayingInfoCenter *infoCenter = [MPNowPlayingInfoCenter defaultCenter];
NSString *songName = self.currentPlaylist.lastItem.track.song.length > 0 ? self.currentPlaylist.lastItem.track.song : @"";
NSString *artistName = self.currentPlaylist.lastItem.track.artist.length > 0 ? self.currentPlaylist.lastItem.track.artist : @"";
infoCenter.nowPlayingInfo = @{
MPMediaItemPropertyTitle: self.currentPlaylist.title,
MPMediaItemPropertyArtist: songName.length > 0 && artistName.length > 0 ? [NSString stringWithFormat:@"%@ - %@", songName, artistName] : @"",
MPMediaItemPropertyPlaybackDuration: @(0)
};
}
Problem is, when data changed and next song will be on radio, how do i tell my app to refresh itself? applicationWillResignActive
i guess called only once when app initially goes to background.