How to show the Now Playing Tab in CarPlay?
Asked Answered
C

2

6

I'm working on an app that will support CarPlay.It's an audio app.

I'm able to show 2 tabs (favourite and recommended) though I just don't know how to show the Now Playing Tab. I just cannot find any info regarding this. Do I have to manually show it, and the, how do I push? Do I have to do it manually? If so, what's the viewcontroller?

Thanks.

Chamomile answered 29/1, 2018 at 5:24 Comment(2)
Pretty insane how inadequate the CarPlay documentation is!Dorweiler
WIth iOS 12, it got much better though.Lustral
L
3

For the Transition to the Now Playing tab to work on both the simulator and an actual car, you need to make sure to

  • call beginReceivingRemoteControlEvents on the current UIApplication, and
  • set a nowPlayingIdentifier on the MPPlayableContentManager

before calling the completion handler in playableContentManager:initiatePlaybackOfContentItemAtIndexPath:completionHandler:.

Lustral answered 11/2, 2019 at 7:26 Comment(4)
Great! I've done the first and last suggestion and I think this has done the trick. I wonder if the second one is needed but I don't know how to do it. How do you set the now playing identifier?Relay
@mike-nelson: MPPlayableContentManager.sharedContentManager.nowPlayingIdentifiers = @[ nowPlaying ], where nowPlaying is the ID of the MPContentItem you have started to play.Lustral
Thanks @DrMickeyLauer, this works, it shows a little speaker icon next to the playing item in the carplay list view now. However, the beginReceivingRemoteControlEvents actually prevents now playing screen from showing unless I call endReceivingRemoteControlEvents and begin again every time play is invoked. This almost works perfectly, except the first time an item plays it refuses to show now playing screen. Any suggestion?Relay
@Lustral please can you help me, I have set things like this but it's not working: #64059729Verdugo
B
2

I know this post is a couple months old, but for me, I had to test in an actual device with CarPlay. Apple says always test it on an actual device with CarPlay. At first, I didn't see a Now Playing tab in the simulator, but as soon as it was tested in a device it was there automatically. I didn't do anything special. I think CarPlay knows when you're playing audio via MPNowPlayingInfoCenter and does this automatically in the actual CarPlay device.

Bitolj answered 28/8, 2018 at 13:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.