如何在锁屏ios7上设置搜索栏播放器?

时间:2014-10-23 11:23:12

标签: xcode avaudioplayer

当我的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];
}

0 个答案:

没有答案