2

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

NTNT
  • 541
  • 1
  • 7
  • 18

1 Answers1

1

Have you activated "Audio, AirPlay and Picture in Picture" as shown below?

enter image description here

Ana Paula
  • 8,733
  • 3
  • 16
  • 16