更改locking屏幕背景audio控制文本?

我有一个iOS应用程序,使用AVAudioSessionstream式背景audio。 它工作正常,但我很好奇,有没有办法改变锁屏audio控制的文本? 现在它只是显示我的应用程序的名称,但我想将其更改为曲目的名称。

此外,多任务栏在控件下面没有文本 – 有没有办法在那里添加曲目名称,就像iPod应用程序那样?

iOS 5现在支持在locking屏幕和远程播放控件(双击主屏幕button并向右滑动时获得的控件)中设置曲目标题以及专辑封面。 看看MPNowPlayingInfoCenter类。 当然,为了最大限度地提高兼容性,你需要testingMPNowPlayingInfoCenter是否可用,方法是:

 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; } 

这里很快! (无需检查iOS 5及以上)

  let albumArt = MPMediaItemArtwork(image: UIImage(named:"HitchHikersGuide")) let albumDict = [MPMediaItemPropertyTitle: "Life, the Universe and Everything", MPMediaItemPropertyPlaybackDuration: 42, MPMediaItemPropertyArtwork: albumArt] MPNowPlayingInfoCenter.defaultCenter().nowPlayingInfo = albumDict