无法将NowPlayingInfo设置为nil

时间:2019-04-26 18:57:49

标签: ios swift mpnowplayinginfocenter

在运行时使用以下代码,我无法将NowPlayingInfo重置为nil:

MPNowPlayingInfoCenter.default().nowPlayingInfo = nil        
    if MPNowPlayingInfoCenter.default().nowPlayingInfo != nil {
        print("3PX: There was a problem Removing nowPlayInfo")
    } else {
        print("3PX: nowPlayInfo Removed")
    }

但是如果我在第一行设置一个断点,则它可以正常工作。有任何想法吗?

1 个答案:

答案 0 :(得分:0)

试试看->

let audioSession = AVAudioSession.sharedInstance()
try? audioSession.setActive(false, with: .notifyOthersOnDeactivation)
MPNowPlayingInfoCenter.default().nowPlayingInfo = [:]