【问题标题】:Is there a way to prevent AVPlayerViewController from updating the lock screen via MPNowPlayingInfoCenter?有没有办法防止 AVPlayerViewController 通过 MPNowPlayingInfoCenter 更新锁屏?
【发布时间】:2016-09-14 09:16:39
【问题描述】:

这是我的问题: 我有一个播放音频文件的应用,通过MPNowPlayingInfoCenter.defaultCenter().nowPlayingInfo更新锁屏信息,这部分工作正常。

但在另一个视图中,我正在播放带有AVPlayerViewControllerAVPlayer 的视频,当视频开始播放时,它会自动更新锁定屏幕,除了视频时长之外什么都没有。

我在 Apple 的文档中没有找到任何关于此行为的信息,我找不到禁用它的方法。

到目前为止,我已经尝试在视频开始播放之前调用UIApplication.sharedApplication().endReceivingRemoteControlEvents(),然后在之后调用beginReceivingRemoteControlEvents()。它不起作用。

有人知道防止这种情况的方法吗?

【问题讨论】:

  • 更新:我没有找到合适的方法来修复它(低于 iOS10),所以当应用程序进入后台时,我正在暂停视频(这使得它对 MPNowPlayingInfoCenter “不可见”) ,并使用当前歌曲信息更新 nowPlayingInfo。

标签: ios swift avplayer avplayerviewcontroller mpnowplayinginfocenter


【解决方案1】:

从 iOS 10 开始,AVPlayerViewController 中有一个名为 updatesNowPlayingInfoCenterBOOL 属性,其默认值为:YES。改成NO

//playerController is an instance of AVPlayerViewController
if ([self.playerController respondsToSelector:@selector(setUpdatesNowPlayingInfoCenter:)])
{
    self.playerController.updatesNowPlayingInfoCenter = NO;
}

【讨论】:

  • 感谢您的信息!
猜你喜欢
  • 2019-05-27
  • 1970-01-01
  • 2019-02-15
  • 1970-01-01
  • 1970-01-01
  • 2020-10-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多