音楽を再生すると、ロック画面の時間の下に音楽のタイトルが表示されます。
また、現在再生中のラジオ局の名前を表示することで、TuneIn ラジオがそれを行う方法も見てきました。
どうやってそれをしますか?
音楽を再生すると、ロック画面の時間の下に音楽のタイトルが表示されます。
また、現在再生中のラジオ局の名前を表示することで、TuneIn ラジオがそれを行う方法も見てきました。
どうやってそれをしますか?
ドキュメントを読む:MPNowPlayingInfoCenter
iOS 5 で動作し、古いバージョンの 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;
}