My app doesn’t support going back to previous tracks, and I’m wondering if I can tell the lock screen music controls to hide their rewind/previous track button. I use the MPNowPlayingInfoCenter
to communicate that information to the lock screen.
我的应用程序不支持回到以前的曲目,我想知道我是否可以告诉锁屏音乐控件隐藏他们的倒带/上一曲目按钮。我使用MPNowPlayingInfoCenter将该信息传递给锁定屏幕。
Pretty simple question, can it be done? For instance, to only show Play/Pause, and Skip Forward?
很简单的问题,可以做到吗?例如,仅显示播放/暂停和跳过?
2 个解决方案
#1
18
As of iOS 7.1 there is a way to customize the controls available in the lock screen and command center (and probably many other accessories): MPRemoteCommandCenter
.
从iOS 7.1开始,有一种方法可以自定义锁定屏幕和命令中心(以及可能的许多其他附件)中可用的控件:MPRemoteCommandCenter。
Regarding your question you can do the following:
关于您的问题,您可以执行以下操作:
[MPRemoteCommandCenter sharedCommandCenter].previousTrackCommand.enabled = NO;
[MPRemoteCommandCenter sharedCommandCenter].skipBackwardCommand.enabled = NO;
[MPRemoteCommandCenter sharedCommandCenter].seekBackwardCommand.enabled = NO;
// You must also register for any other command in order to take control
// of the command center, or else disabling other commands does not work.
// For example:
[MPRemoteCommandCenter sharedCommandCenter].playCommand.enabled = YES;
[[MPRemoteCommandCenter sharedCommandCenter].playCommand addTarget:self action:@selector(play)];
Please see this Stack Overflow answer for more general information about MPRemoteCommandCenter.
有关MPRemoteCommandCenter的更多常规信息,请参阅此Stack Overflow答案。
#2
9
OUTDATED:
I think the short answer is no. The documentation says this -
我认为简短的回答是否定的。文档说这个 -
"You do not have direct control over which information is displayed, or its formatting. You set the values of the now playing info center dictionary according to the information you want to provide to the system. The system, or the connected accessory, handles the information’s display in a consistent manner for all apps."
“您无法直接控制显示哪些信息或其格式。您可以根据要提供给系统的信息设置正在播放的信息中心字典的值。系统或连接的附件处理信息以一致的方式显示给所有应用。“
#1
18
As of iOS 7.1 there is a way to customize the controls available in the lock screen and command center (and probably many other accessories): MPRemoteCommandCenter
.
从iOS 7.1开始,有一种方法可以自定义锁定屏幕和命令中心(以及可能的许多其他附件)中可用的控件:MPRemoteCommandCenter。
Regarding your question you can do the following:
关于您的问题,您可以执行以下操作:
[MPRemoteCommandCenter sharedCommandCenter].previousTrackCommand.enabled = NO;
[MPRemoteCommandCenter sharedCommandCenter].skipBackwardCommand.enabled = NO;
[MPRemoteCommandCenter sharedCommandCenter].seekBackwardCommand.enabled = NO;
// You must also register for any other command in order to take control
// of the command center, or else disabling other commands does not work.
// For example:
[MPRemoteCommandCenter sharedCommandCenter].playCommand.enabled = YES;
[[MPRemoteCommandCenter sharedCommandCenter].playCommand addTarget:self action:@selector(play)];
Please see this Stack Overflow answer for more general information about MPRemoteCommandCenter.
有关MPRemoteCommandCenter的更多常规信息,请参阅此Stack Overflow答案。
#2
9
OUTDATED:
I think the short answer is no. The documentation says this -
我认为简短的回答是否定的。文档说这个 -
"You do not have direct control over which information is displayed, or its formatting. You set the values of the now playing info center dictionary according to the information you want to provide to the system. The system, or the connected accessory, handles the information’s display in a consistent manner for all apps."
“您无法直接控制显示哪些信息或其格式。您可以根据要提供给系统的信息设置正在播放的信息中心字典的值。系统或连接的附件处理信息以一致的方式显示给所有应用。“