簡體   English   中英

有沒有一種方法可以防止AVPlayerViewController通過MPNowPlayingInfoCenter更新鎖定屏幕?

[英]Is there a way to prevent AVPlayerViewController from updating the lock screen via MPNowPlayingInfoCenter?

這是我的問題:我有一個應用程序在播放音頻文件,並通過MPNowPlayingInfoCenter.defaultCenter().nowPlayingInfo更新鎖屏信息,並且此部分工作正常。

但是在另一個視圖中,我正在使用AVPlayerViewControllerAVPlayer播放視頻,並且當視頻開始播放時,它將自動更新鎖定屏幕,除了視頻持續時間外什么都沒有。

我沒有在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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM