CarPlay - Transition to the Now Playing screen

This is from the documentation:


Transition to the Now Playing screen

When the user selects a playable item such as a radio station or song title to request audio playback, CarPlay should transition to the Now Playing screen as soon as content is available for playback. However, it may take several seconds for audio to actually start playing due to buffering or network conditions. Apple recommends that you let the selected item remain highlighted with an animated spinner to indicate that the content is loading. iOS automatically draws the spinner and it will remain until your app returns the completion handler. However, if your app does not return the completion handler for a long period of time, iOS will eventually timeout and display an error screen.


I try this,

It starts playing, but never transitions to the "Now Playing" screen.

What am I doing wrong?


func playableContentManager(_ contentManager: MPPlayableContentManager, initiatePlaybackOfContentItemAt indexPath: IndexPath, completionHandler: @escaping (Error?) -> Void) {

self.play(mArray[indexPath[0]])


completionHandler(nil)


}

Accepted Reply

.What finally made the transition work for me was having the application *not* receive remote control events when launching playback.


Calling


[[UIApplication sharedApplication] endReceivingRemoteControlEvents];


before (or after) calling the completion handler made the transition work successfully. Curiously, the transition only works if I call beginReceivingRemoteControlEvents followed by endReceivingRemoteControlEvents. Not calling either does not work, nor does calling endReceivingRemoteControlEvents without calling beginReceivingRemoteControlEvents


I'll update here when I understand what is happening better.

Replies

Could this be a simulator problem? XCode 9.2.

The "Now Playing" info. is beeing set, but it does not seem to pick up the: MPNowPlayingInfoPropertyPlaybackRate:1.0

So the play/pause button does not change by itself. The now playing screen does not appear if i start playing manually on the phone either.


Please, anyone?

Same problem here - can't get it to work.

.What finally made the transition work for me was having the application *not* receive remote control events when launching playback.


Calling


[[UIApplication sharedApplication] endReceivingRemoteControlEvents];


before (or after) calling the completion handler made the transition work successfully. Curiously, the transition only works if I call beginReceivingRemoteControlEvents followed by endReceivingRemoteControlEvents. Not calling either does not work, nor does calling endReceivingRemoteControlEvents without calling beginReceivingRemoteControlEvents


I'll update here when I understand what is happening better.

Do you have some sort of example code on github or such? I cannot make the Now Playing tab to appear in my car play simulator. I didn't know that it should automagically transition to that screen...

I've been trying to get the url for the documentation you are referring to but I had no luck...


thanks

Hi,


any updates on your side reagrding this issue?

Would you confirm that this workaround is only required for simulator builds and must not be used for real hardware runs?



cheers


J

I'm having the same issue with the playback rate in the simulator.

Also please file a bug report at <https://developer.apple.com/bug-reporting>.

Very strange. This does indeed work, even though since 7.1 we no longer use this API but the `MPRemoteCommandCenter`. Opening a bugreport.


UPDATE: For me it actually only works in the simulator. In the car, it doesn't.