[英]Is there a way to prevent AVPlayerViewController from updating the lock screen via MPNowPlayingInfoCenter?
這是我的問題:我有一個應用程序在播放音頻文件,並通過MPNowPlayingInfoCenter.defaultCenter().nowPlayingInfo
更新鎖屏信息,並且此部分工作正常。
但是在另一個視圖中,我正在使用AVPlayerViewController
和AVPlayer
播放視頻,並且當視頻開始播放時,它將自動更新鎖定屏幕,除了視頻持續時間外什么都沒有。
我沒有在Apple文檔中找到有關此行為的任何信息,也找不到禁用它的方法。
到目前為止,我已經嘗試在視頻開始播放之前調用UIApplication.sharedApplication().endReceivingRemoteControlEvents()
然后在播放之后開始beginReceivingRemoteControlEvents()
。 沒用
有誰知道防止這種情況的方法?
從iOS 10開始, AVPlayerViewController
有一個BOOL
屬性,稱為updatesNowPlayingInfoCenter
,其默認值為YES
。 只需將其更改為NO
:
//playerController is an instance of AVPlayerViewController
if ([self.playerController respondsToSelector:@selector(setUpdatesNowPlayingInfoCenter:)])
{
self.playerController.updatesNowPlayingInfoCenter = NO;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.