Reputation: 541
I tried this code to show media info in Lockscreen and Control center but it does not show anything:
Class playingInfoCenter = NSClassFromString(@"MPNowPlayingInfoCenter");
if (playingInfoCenter) {
NSMutableDictionary *songInfo = [[NSMutableDictionary alloc] init];
MPMediaItemArtwork *albumArt = [[MPMediaItemArtwork alloc] initWithImage: [UIImage imagedNamed:@"AlbumArt"]];
[songInfo setObject:@"Audio Title" forKey:MPMediaItemPropertyTitle];
[songInfo setObject:@"Audio Author" forKey:MPMediaItemPropertyArtist];
[songInfo setObject:@"Audio Album" forKey:MPMediaItemPropertyAlbumTitle];
[songInfo setObject:albumArt forKey:MPMediaItemPropertyArtwork];
[[MPNowPlayingInfoCenter defaultCenter] setNowPlayingInfo:songInfo];
}
I also set FirstResponding
but still not see anything.
- (void) viewDidAppear: (BOOL) animated
{
[super viewDidAppear:animated];
[self becomeFirstResponder];
NSLog(@"is first resp: %i",[self isFirstResponder]);
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
// Initialize the AVAudioSession here.
[[UIApplication sharedApplication] endReceivingRemoteControlEvents];
}
- (BOOL) canBecomeFirstResponder
{
return YES;
}
How can i fix that? Thanks
Upvotes: 2
Views: 477
Reputation: 9507
Have you activated "Audio, AirPlay and Picture in Picture" as shown below?
Upvotes: 1