更改锁屏背景音频控制文字? [英] Change lock screen background audio controls text?

查看:112
本文介绍了更改锁屏背景音频控制文字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have an iOS app that streams background audio using AVAudioSession. It is working correctly, but I am curious, is there any way to change the text on the lock screen audio controls? Right now it simply displays the name of my app, but I would like to change it to the name of the track.

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

Additionally, the multi-tasking bar has no text under the controls- is there a way to add the track name there, as the iPod app does?

推荐答案

iOS 5现在支持在锁定屏幕和远程播放控件中设置曲目标题以及专辑封面图像(控制你双击主页按钮并向右滑动时获取。看看
MPNowPlayingInfoCenter 类。当然,为了最大限度地提高兼容性,您需要通过执行以下操作来测试 MPNowPlayingInfoCenter 是否可用:

iOS 5 now supports setting the track title as well as an album art image in both the lock screen and the remote playback controls (the controls you get when you double-click the home button and swipe right). Take a look at the MPNowPlayingInfoCenter class. Of course, to maximize compatibility, you'd want to test whether MPNowPlayingInfoCenter is available, by doing something like:

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

这篇关于更改锁屏背景音频控制文字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆