iOS 5 теперь поддерживает настройку названия дорожки, а также изображения обложки альбома как на экране блокировки, так и на удаленных элементах управления воспроизведением (элементы управления, которые вы получаете, если дважды щелкнуть кнопку «Домой» и провести пальцем вправо).Взгляните на класс MPNowPlayingInfoCenter
.Конечно, чтобы максимизировать совместимость, вам нужно проверить, доступна ли MPNowPlayingInfoCenter
, выполнив что-то вроде:
if ([MPNowPlayingInfoCenter class]) {
/* we're on iOS 5, so set up the now playing center */
UIImage *albumArtImage = [UIImage imageNamed:@"HitchHikersGuide"];
albumArt = [[MPMediaItemArtwork alloc] initWithImage:albumArtImage];
NSDictionary *currentlyPlayingTrackInfo = [NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:@"Life, the Universe and Everything", [NSNumber numberWithInt:42], albumArt, nil] forKeys:[NSArray arrayWithObjects:MPMediaItemPropertyTitle, MPMediaItemPropertyPlaybackDuration, MPMediaItemPropertyArtwork, nil]];
[MPNowPlayingInfoCenter defaultCenter].nowPlayingInfo = currentlyPlayingTrackInfo;
}