如何让我的应用程序与锁定屏幕上的媒体控制按钮配合使用?
在最近的 iOS 版本中,应用程序可以对锁定屏幕上的媒体控制按钮进行某种访问,例如播放/暂停按钮:
看起来这些按钮应该与 MPMusicPlayerController
类一起使用,是吗?有没有办法从按钮获取“原始”事件?因为音乐播放器似乎只提供了一个 API 来提供一堆 MPMediaItem
。例如,如果我的应用程序是一个需要以不同方式处理按钮的收音机,该怎么办?
In recent iOS versions apps have some kind of access to the media control buttons on the lock screen, like the Play/Pause button:
It looks like the buttons are supposed to work with the MPMusicPlayerController
class, is that right? Is there a way to get the “raw” events from the buttons? Because the music player only seems to offer an API to supply a bunch of MPMediaItem
s. What if my app is for example a radio that needs to handle the buttons differently?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
经过更多搜索后,我发现这个相关问题使事情变得清晰。音乐播放器控制器类并不是真正正确的轨道,技巧是在控制器中订阅远程事件:
After a bit more searching I have found this related question that makes things clear. The music player controller class is not really the right track, the trick is to subscribe for remote events in your controller: