I am working on a CarPlay app that plays back audio content. When attempting to use the CPNowPlayingPlaybackRateButton
button, it works well for changing the speed, except for when the audio is paused. Then it shows the speed as 0x,
which is technically true but not great for the UI. In looking at how other audio apps handle this, in the case where the app is using the CPNowPlayingPlaybackRateButton
and not an image button, they mostly hide the button when paused. The only apps that don't (that I've found) are Apple's Podcasts and Audiobooks apps, which manage to keep the rate button showing the value it had when playing. So, it's possible? I tried setting the defaultRate
property of the AVPlayer,
along with the rate
property, but that didn't seem to help. I'd like to use the standard button instead of an image button if possible. Any suggestions most welcomed!
Have CPNowPlayingPlaybackRateButton show current playback speed even when paused?
The playback rate displayed should match the value you donated to now playing, in particular MPNowPlayingInfoPropertyPlaybackRate
in your MPNowPlayingInfoCenter
info dictionary, even if your app's playback has been paused. Can you verify you're donating a non-zero value to the info center when paused?
I had been setting the value for the MPNowPlayingInfoPropertyPlaybackRate
key to 0 when pausing. I removed that line, so that value stays at the current rate even when we're paused, but the button still changes to 0x
when paused. I also tried setting the MPNowPlayingInfoPropertyDefaultPlaybackRate
property to the current rate, but that also doesn't help. I check the value of the property before I modified it, and it doesn't look like it is coming in set to 0
(it is nil
prior to me first setting it), so I don't think anything else is changing that value behind my back. Thanks!
I am also seeing this problem. MPNowPlayingInfoPropertyPlaybackRate
is set to the desired playback rate, but as soon as the media is paused, the CPNowPlayingPlaybackRateButton
shows "0x", which is a terrible user experience.