Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 playing radio station.

How do you do that?

like image 301
samwize Avatar asked Dec 05 '11 15:12

samwize


People also ask

How do I get my iPhone to show the name on lock screen?

To add your name or a short message for anyone who finds your phone: Go to Settings > Security > Owner info. Check Show owner info on lock screen. Type the text to display.

How do I show now playing on my lock screen?

Open your phone's Settings app. Now Playing. Make sure that “Show songs on lock screen” is on.

Why is my iPhone lock screen showing music?

This error – the music app pops up on the lock screen when not playing happens because you didn't close it properly. You have to quit the app completely if you don't want the music app appearing on the locked screen.


1 Answers

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;
}
like image 188
rckoenes Avatar answered Nov 09 '22 22:11

rckoenes