【发布时间】:2020-05-29 08:16:52
【问题描述】:
在 Radio 应用程序中,为了暂停 AVPlayer,我们并没有真正暂停它,只是根据应用程序要求将其静音一段时间。 这里的问题是一切正常,但是当我将播放器静音时 MPNowPlayingInfoCenter 没有更新为暂停。有什么方法可以以编程方式控制 MPNowPlayingInfoCenter 控件?
尝试了所有可能的解决方案,例如设置 setActive(false) 但这会导致普通播放器出现问题。
这是解决方法
暂停时,我将其静音 120 秒,如果它仍处于该模式,我将暂停播放器,这是我正在使用的代码。
self.player.rate = 0.0 // Automatically handles the MPNowPlayingInfoCenter Controls to Pause state
self.player.isMuted = true
secs = 120
【问题讨论】:
-
// Automatically handles the MPNowPlayingInfoCenter Controls to Pause state.请说明你如何更新 MPNowPlayingInfo,可能有问题。 -
此外,如果您将一些日志输出添加到代码中以显示您的执行流程,这可能会有所帮助
标签: ios swift iphone avplayer mpnowplayinginfocenter