-1

In Radio app where for pausing the AVPlayer we are not really pausing it just muting it for some time as per the app requirement. Here the issue is everything is working fine but MPNowPlayingInfoCenter is not updating to pause when I mute the player. Is there is any way I can control MPNowPlayingInfoCenter controlls programmatically?

Tried the all possible solutions like making setActive(false) but this is causing issue in normal player.

Here is the solution for it

When Pausing I'm muting it for 120 secs and if it still in that mode I'm pausing the player here is the code i'm using for it.

  self.player.rate = 0.0 // Automatically handles the MPNowPlayingInfoCenter Controls to Pause state
  self.player.isMuted = true
  secs = 120 
Cœur
  • 37,241
  • 25
  • 195
  • 267
Sowji
  • 1
  • 2
  • `// Automatically handles the MPNowPlayingInfoCenter Controls to Pause state.` Please show how you update MPNowPlayingInfo, maybe there is a problem. – Robin Schmidt Feb 19 '20 at 17:11
  • Additionally, it could be helpful if you add some log outputs to your code which show your execution flow – Robin Schmidt Feb 19 '20 at 17:14

1 Answers1

0

To set MPNowPlayingInfoCenter to paused, you can set playbackRate to 0.0:

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

MPNowPlayingInfoCenter.default().nowPlayingInfo = nowPlayingInfo
Robin Schmidt
  • 1,153
  • 8
  • 15
  • @Sowji If this didn't help you and you're already setting `rate = 0`, please show the code your currently using to pause – Robin Schmidt Feb 19 '20 at 07:01
  • Thanks for the response setting PlaybackRate doesn't make any difference. While muting channel i changed the player rate to 0.0 then it updated the MPNowPlayingInfoCenter controls automatically. – Sowji Feb 19 '20 at 08:54
  • @Sowji pleased update your question to show the code you run on pausing the player – Robin Schmidt Feb 19 '20 at 08:56