【发布时间】:2016-09-14 09:16:39
【问题描述】:
这是我的问题:
我有一个播放音频文件的应用,通过MPNowPlayingInfoCenter.defaultCenter().nowPlayingInfo更新锁屏信息,这部分工作正常。
但在另一个视图中,我正在播放带有AVPlayerViewController 和AVPlayer 的视频,当视频开始播放时,它会自动更新锁定屏幕,除了视频时长之外什么都没有。
我在 Apple 的文档中没有找到任何关于此行为的信息,我找不到禁用它的方法。
到目前为止,我已经尝试在视频开始播放之前调用UIApplication.sharedApplication().endReceivingRemoteControlEvents(),然后在之后调用beginReceivingRemoteControlEvents()。它不起作用。
有人知道防止这种情况的方法吗?
【问题讨论】:
-
更新:我没有找到合适的方法来修复它(低于 iOS10),所以当应用程序进入后台时,我正在暂停视频(这使得它对 MPNowPlayingInfoCenter “不可见”) ,并使用当前歌曲信息更新 nowPlayingInfo。
标签: ios swift avplayer avplayerviewcontroller mpnowplayinginfocenter