ios - 我可以隐藏 iOS 锁屏音乐控件中的快退按钮吗?

标签 ios objective-c mpnowplayinginfocenter

我的应用程序不支持返回到上一首轨道,我想知道是否可以让锁屏音乐控件隐藏其倒带/上一首轨道按钮。我使用 MPNowPlayingInfoCenter 将该信息传达给锁定屏幕。

很简单的问题,能做到吗?例如,只显示播放/暂停和快进?

最佳答案

从 iOS 7.1 开始,有一种方法可以自定义锁定屏幕和命令中心(可能还有许多其他配件)中可用的控件:MPRemoteCommandCenter

关于您的问题,您可以执行以下操作:

[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 .

关于ios - 我可以隐藏 iOS 锁屏音乐控件中的快退按钮吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21334128/

相关文章:

iphone - SQLite 或 Core Data 用于只有查询的大型数据库

ios - UIButton 启用不起作用

objective-c - WebView 中的 OSX OAuth redirect_uri

ios - 如何在 iOS 锁屏控制面板中启用音频洗涤器?

swift - 从 AVPlayer 播放器周期时间观察器 block 更新 MPNowPlayingInfoCenter 中的播放时间时出现问题

ios - 设置 MPNowPlayingInfoCenter 与其他背景音频播放

ios - 使用 NSScanner 解析 NSString 返回元素结果的重复结尾

ios - 为什么iphone的视频是颠倒的?

objective-c - 从存储在单例中的数组中删除对象

iPhone:以编程方式检查应用内购买状态