【问题标题】:Unable to set NowPlayingInfo to nil无法将 NowPlayingInfo 设置为 nil
【发布时间】:2019-04-26 18:57:48
【问题描述】:

我无法在运行时使用此代码将 NowPlayingInfo 重置为零:

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

但如果我在第一行设置断点,那么它可以正常工作。有什么想法吗?

【问题讨论】:

    标签: ios swift mpnowplayinginfocenter


    【解决方案1】:

    试试这个 -->

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-01-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-05-20
      • 2010-12-13
      • 1970-01-01
      相关资源
      最近更新 更多