我可以隐藏iOS锁屏音乐控件中的倒带按钮吗? [英] Can I hide the rewind button in the iOS Lock Screen Music controls?
问题描述
我的应用程序不支持返回上一首曲目,我想知道是否可以告诉锁屏音乐控件隐藏其倒带/上一曲目按钮。我使用 MPNowPlayingInfoCenter
将该信息传达给锁定屏幕。
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.
非常简单的问题,可以做到吗?例如,仅显示播放/暂停和向前跳过?
Pretty simple question, can it be done? For instance, to only show Play/Pause, and Skip Forward?
推荐答案
从iOS 7.1开始,有一种方法可以自定义锁定屏幕和命令中心(以及可能还有许多其他附件)中可用的控件: MPRemoteCommandCenter
。
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
.
关于您的问题您可以执行以下操作:
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)];
请参阅此Stack Overflow答案,了解有关MPRemoteCommandCenter的更多一般信息。
这篇关于我可以隐藏iOS锁屏音乐控件中的倒带按钮吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!