2

I have an audio recording app. How do I show that the app is recording while the lock screen is on, the way the voice memo app that comes with the iPhone does. Tried playing with MPNowPlayingInfoCenter but haven't gotten anything to work. Any ideas?

Here is what I tried to implement in the IBAction that starts the recording

Class playingInfoCenter = NSClassFromString(@"MPNowPlayingInfoCenter");

if (playingInfoCenter) {


    NSMutableDictionary *songInfo = [[NSMutableDictionary alloc] init];


    MPMediaItemArtwork *albumArt = [[MPMediaItemArtwork alloc] initWithImage: [UIImage imageNamed:@"record.png"]];

    [songInfo setObject:@"Recording" forKey:MPMediaItemPropertyTitle];
    [songInfo setObject:albumArt forKey:MPMediaItemPropertyArtwork];
    [[MPNowPlayingInfoCenter defaultCenter] setNowPlayingInfo:songInfo];


}
rmaddy
  • 314,917
  • 42
  • 532
  • 579
MScottWaller
  • 3,321
  • 2
  • 24
  • 47
  • 1
    Try this: http://stackoverflow.com/a/9537112/1153630 – Max Chuquimia Apr 30 '14 at 02:28
  • Yep, that did the trick – MScottWaller Apr 30 '14 at 02:35
  • 1
    However, would still like to find a way to get the elapsed time of the recording on the lock screen. Not sure what to do about that. – MScottWaller Apr 30 '14 at 02:52
  • Depends where you want to put it - you could display a string for `MPMediaItemPropertyArtist` as the elapsed time – Max Chuquimia Apr 30 '14 at 02:55
  • Hey, did you have success in doing this? I was able to show the MPNowPlayingInfoCenter while using CategoryPlayback, but of course you can't record with that. I also had kind of a success, by using CategoryRecordAndPlay, start recording, then switch to CategoryPlayback and show the MPNowPlayingInfoCenter, but it only happens the first time I run the app, afterwards, if I stop and restart the recording, it never shows up again... – Jan Sep 12 '14 at 15:28

0 Answers0