当我的AVAudioPlayer在后台播放时,我可以看到我的歌曲的标题和专辑的图像,但我无法设置搜索栏。我尝试设置MPMediaItemPropertyPlaybackDuration和MPNowPlayingInfoPropertyElapsedPlaybackTime,但锁屏中没有出现任何解决方案?非常感谢!!
更新:
Class playingInfoCenter = NSClassFromString(@"MPNowPlayingInfoCenter");
if (playingInfoCenter) {
NSMutableDictionary *songInfo = [[NSMutableDictionary alloc] init];
UIImage *cover=[UIImage imageNamed:@"cd.jpeg"];
NSNumber *durationTrack= [NSNumber numberWithDouble:[self.audioPlayer getAudioDuration]];
NSNumber *elapsedTime= [NSNumber numberWithDouble:[self.audioPlayer getCurrentAudioTime]];
NSNumber *rate= [NSNumber numberWithDouble:[self.audioPlayer rate]];
[songInfo setObject:@"Arbitri Elegantiae - Medley -" forKey:MPMediaItemPropertyTitle];
[songInfo setObject:cover forKey:MPMediaItemPropertyArtwork];
[songInfo setObject:elapsedTime forKey:MPNowPlayingInfoPropertyElapsedPlaybackTime];
[songInfo setObject:durationTrack forKey:MPMediaItemPropertyPlaybackDuration];
[songInfo setObject:rate forKey:MPNowPlayingInfoPropertyPlaybackRate];
[[MPNowPlayingInfoCenter defaultCenter] setNowPlayingInfo:songInfo];
}