Skip to content

Instantly share code, notes, and snippets.

@torcelly
Created December 6, 2014 09:23
Show Gist options
  • Save torcelly/8cd8f47aaf7a9f0b1a28 to your computer and use it in GitHub Desktop.
Save torcelly/8cd8f47aaf7a9f0b1a28 to your computer and use it in GitHub Desktop.
Setup iOS Lock Screen (MPMedia)
- (void) setupInfoLockScreen
{
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
// Info
NSString *leftSide = @"Left Side";
NSString *rightSide = @"Right Side";
NSString *titleSide = @"Title";
UIImage *image = ...;
MPMediaItemArtwork *artwork = [[MPMediaItemArtwork alloc]initWithImage:image];
[nowPlaying setValue:leftSide forKey:MPMediaItemPropertyArtist];
[nowPlaying setValue:rightSide forKey:MPMediaItemPropertyAlbumTitle];
[nowPlaying setValue:titleSide forKey:MPMediaItemPropertyTitle]
[nowPlaying setValue:artwork forKey:MPMediaItemPropertyArtwork];
[[MPNowPlayingInfoCenter defaultCenter] setNowPlayingInfo:nowPlaying];
[[MPNowPlayingInfoCenter defaultCenter] setNowPlayingInfo:nowPlaying];
}// setupInfoLockScreen
- (void) cleanLockScreen
{
[[UIApplication sharedApplication]endReceivingRemoteControlEvents];
[[MPNowPlayingInfoCenter defaultCenter]setNowPlayingInfo:nil];
}// cleanLockScreen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment