Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/103.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 更改锁屏背景音频控制文本?_Ios_Objective C_Swift_Avaudiosession_Mpnowplayinginfocenter - Fatal编程技术网

Ios 更改锁屏背景音频控制文本?

Ios 更改锁屏背景音频控制文本?,ios,objective-c,swift,avaudiosession,mpnowplayinginfocenter,Ios,Objective C,Swift,Avaudiosession,Mpnowplayinginfocenter,我有一个iOS应用程序,可以使用AVAudioSession流式传输背景音频。它工作正常,但我很好奇,有没有办法更改锁屏音频控件上的文本?现在它只显示我的应用程序的名称,但我想将其更改为曲目的名称 此外,多任务栏的控件下没有文本-是否有办法像iPod应用程序那样在其中添加曲目名称?iOS 5现在支持在锁定屏幕和远程播放控件(双击“主页”按钮并向右滑动时获得的控件)中设置曲目标题和专辑艺术图像. 看一看 班级。当然,为了最大限度地提高兼容性,您需要通过执行以下操作来测试mpnowplayingf

我有一个iOS应用程序,可以使用AVAudioSession流式传输背景音频。它工作正常,但我很好奇,有没有办法更改锁屏音频控件上的文本?现在它只显示我的应用程序的名称,但我想将其更改为曲目的名称


此外,多任务栏的控件下没有文本-是否有办法像iPod应用程序那样在其中添加曲目名称?

iOS 5现在支持在锁定屏幕和远程播放控件(双击“主页”按钮并向右滑动时获得的控件)中设置曲目标题和专辑艺术图像. 看一看 班级。当然,为了最大限度地提高兼容性,您需要通过执行以下操作来测试
mpnowplayingfocenter
是否可用:

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及以上版本)


您希望在这里使用classFromString,因为这将导致较低的操作系统崩溃。在iOS 4.x中没有正式的设置方法。我甚至不认为有一种非官方的方法可以做到这一点。有人知道如何使用网络音频吗?
let albumArt = MPMediaItemArtwork(image: UIImage(named:"HitchHikersGuide"))
let albumDict = [MPMediaItemPropertyTitle: "Life, the Universe and Everything", MPMediaItemPropertyPlaybackDuration: 42, MPMediaItemPropertyArtwork: albumArt]
MPNowPlayingInfoCenter.defaultCenter().nowPlayingInfo = albumDict