0

I am unable to reset NowPlayingInfo to nil, using this code in runtime:

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

but if I set a breakpoint on the first line then it works correctly. Any Ideas ?

cromanelli
  • 576
  • 1
  • 5
  • 21

1 Answers1

0

Try this -->

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