How often do you need to update MPNowPlayingInfo?

I am using an AVQueuePlayer to play a series of audio files. While implementing the now playing functionality for the iOS lock screen, I got a little confused with how to use MPNowPlayingInfo. When you update MPNowPlayingInfo, one of the fields is MPNowPlayingInfoPropertyElapsedPlaybackTime. This leads me to believe you need to call it at least once a second to keep that up-to-date.

But if you don't call it that frequently, the Now Playing UI does update correctly as it's playing, so that makes me think you only need to call it once you start playing?

It feels very expensive to keep on calling it every time in my periodic time observer, but is that the correct approach? Or do you just call it when you play/pause/skip, etc. ?

Answered by Engineer in 802975022

Hello @bss. The discussion section in MPNowPlayingInfoPropertyElapsedPlaybackTime mentions that the system automatically calculates the elapsed time from the previously provided elapsed time and the playback rate, and that it isn’t necessary to update this property frequently. There are some cases, such as when playing interstitials during a live stream, for example, where you would wanna provide a new value for the elapsed time at certain transitions. In many circumstances, such as playing fixed media without interstitials, for example, you might not need to set or update the elapsed time at all. Since the elapsed time is calculated from the playback rate, you don't normally need to update it when responding to transport controls.

Hello @bss. The discussion section in MPNowPlayingInfoPropertyElapsedPlaybackTime mentions that the system automatically calculates the elapsed time from the previously provided elapsed time and the playback rate, and that it isn’t necessary to update this property frequently. There are some cases, such as when playing interstitials during a live stream, for example, where you would wanna provide a new value for the elapsed time at certain transitions. In many circumstances, such as playing fixed media without interstitials, for example, you might not need to set or update the elapsed time at all. Since the elapsed time is calculated from the playback rate, you don't normally need to update it when responding to transport controls.

How often do you need to update MPNowPlayingInfo?
 
 
Q