[英]Can I hide the rewind button in the iOS Lock Screen Music controls?
我的应用程序不支持返回到以前的曲目,我想知道我是否可以告诉锁屏音乐控件隐藏其倒带/上一曲目按钮。 我使用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)];
过时的:
我认为简短的回答是否定的。 文件说这个 -
“您无法直接控制显示哪些信息或其格式。您可以根据要提供给系统的信息设置正在播放的信息中心字典的值。系统或连接的附件处理信息以一致的方式显示给所有应用。“
我发现如果我没有设置nowPlayingInfo和MPNowPlayingInfoCenter,那么我试图摆脱默认锁定屏幕播放器的更改没有注册。 确保你正在设置MPNowPlayingInfoCenter.defaultCenter()。nowPlayingInfo,如下所示:
var songInfo: NSMutableDictionary = [
MPMediaItemPropertyTitle: "song title",
MPMediaItemPropertyArtist: "artiest ",
]
MPNowPlayingInfoCenter.defaultCenter().nowPlayingInfo = songInfo as [NSObject : AnyObject]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.