IOS: display current track information in LockScreen?

Starting with iOS 5, we have access to MPNowPlayingInfoCenterdisplay information on the locked screen and in the multimedia controls on the multitasking panel. I have an application that plays local audio files . I want to display information such as artist name, album and cover art on lockscreen with MPNowPlayingInfoCenter, but the only way to do this is (as far as I know) to use MPMusicPlayerControllerand get nowPlayingItem. The problem is that it is MPMusicPlayerControllerused to play only iPod music, not locally stored files. Is there any way around this in iOS 5?

+5
source share
1 answer

You can create your own NSDictionary and provide it in MPNowPlayingInfoCenter.

NSArray *keys = [NSArray arrayWithObjects:MPMediaItemPropertyAlbumTitle, MPMediaItemPropertyArtist, ..., nil];
NSArray *values = [NSArray arrayWithObjects:@"Album", @"Artist", ..., nil];
NSDictionary *mediaInfo = [NSDictionary dictionaryWithObjects:values forKeys:keys];
[[MPNowPlayingInfoCenter defaultCenter] setNowPlayingInfo:mediaInfo];
+17
source

All Articles