How to set an title of the currently playing audio in iPhone lock screen?

后端 未结 1 1223
眼角桃花
眼角桃花 2020-12-04 23:12

When you play a music, the music title is shown below the time in the lock screen.

I have also seen how TuneIn radio does that by showing the name of the currently p

相关标签:
1条回答
  • 2020-12-04 23:38

    Read the documentation: MPNowPlayingInfoCenter

    And here is an example code that will work on iOS 5 and it will not crash on older versions of iOS.

    Class playingInfoCenter = NSClassFromString(@"MPNowPlayingInfoCenter");
    
    if (playingInfoCenter) {
        MPNowPlayingInfoCenter *center = [MPNowPlayingInfoCenter defaultCenter];
        NSDictionary *songInfo = [NSDictionary dictionaryWithObjectsAndKeys:
                                 @"Some artist", MPMediaItemPropertyArtist,
                                 @"Some title", MPMediaItemPropertyTitle,
                                 @"Some Album", MPMediaItemPropertyAlbumTitle,
                                 nil];
        center.nowPlayingInfo = songInfo;
    }
    
    0 讨论(0)
提交回复
热议问题