0

I'm using AVAudioPlayerNode to play musics. But, when I push pause button from Control Center, elapsed time keeps elapsing while music is paused. I want to know how to pause elapsed time in Control Center.

And I already tried to MPNowPlayingInfoPropertyPlaybackRate to 0, but that didn't work as expected.

    var info = MPNowPlayingInfoCenter.default().nowPlayingInfo
    info?[MPNowPlayingInfoPropertyPlaybackRate] = 0.0
    MPNowPlayingInfoCenter.default().nowPlayingInfo = info

Certainly, elapsed time is paused, but it changes to 0. I want to keeep elapsed time.

After I added a code MPNowPlayingInfoPropertyElapsedPlaybackTime to current time, it worked well!

    var info = MPNowPlayingInfoCenter.default().nowPlayingInfo
    info?[MPNowPlayingInfoPropertyPlaybackRate] = 0.0
    info?[MPNowPlayingInfoPropertyElapsedPlaybackTime] = musicController.getCurrentTime()
    MPNowPlayingInfoCenter.default().nowPlayingInfo = info

Thanks a lot!!

Takuto-m
  • 11
  • 1

0 Answers0