Search code examples
iphoneiosaudiobackgroundios5

Background Audio - Image on Lock Screen


There is a way to add an image to the lock screen for Background Audio, along with setting the Track and Artist name. It was also mentioned in a WWDC 2011 video, but nothing specific to go off of. I have looked everywhere in the docs and cannot find it. I know it is an iOS5 only thing, and Spotify's newest version has this feature. Does anyone know where they can point me in the right direction?

Thank You, Matthew


Solution

  • Here's an answer I found for you:

    (1) You must handle remote control events. You can't be the Now Playing app unless you do. (See the AudioMixer (MixerHost) sample) code.)

    (2) Set the Now Playing info:

    MPNowPlayingInfoCenter *infoCenter = [MPNowPlayingInfoCenter defaultCenter]; 
    infoCenter.nowPlayingInfo = 
        [NSDictionary dictionaryWithObjectsAndKeys:@"my title", MPMediaItemPropertyTitle,
                                                   @"my artist", MPMediaItemPropertyArtist,
                                                   nil];
    

    This is independent of whichever API you are using to play audio or video.