如何在MPNowPlayingInfoCenter中以编程方式控制播放按钮

问题描述 投票:-1回答:1

在无线电应用中,为了暂停AVPlayer,我们并没有真正暂停它,只是根据应用要求将其静音了一段时间。这里的问题是一切都工作正常,但是MPNowPlayingInfoCenter不会在我将播放器静音时更新为暂停。我可以通过编程方式控制MPNowPlayingInfoCenter控件吗?

尝试了所有可能的解决方案,例如设置setActive(false),但这在普通播放器中引起了问题。

请帮帮我。

ios swift iphone avplayer mpnowplayinginfocenter
1个回答
0
投票

要将MPNowPlayingInfoCenter设置为暂停,可以将playbackRate设置为0.0:

let nowPlayingInfo : [String: AnyObject] = 
    [MPNowPlayingInfoPropertyPlaybackRate: 0.0]

MPNowPlayingInfoCenter.default().nowPlayingInfo = nowPlayingInfo
© www.soinside.com 2019 - 2024. All rights reserved.