Apple CarPlay - how to update media items?

Viewed 210

Looking for some guidance on how to implement CarPlay with media items that may be somewhat dynamic.

Basically I want to have the user tap on one of the top level item in the hierarchy and then get an event from CarPlay to tell me which item was tapped and give me a chance to supply the child media items for this selection. This is simple to do synchronously but I want to do this asynchronously because I need to download the list of media items, and I only want to download the ones under the parent the user has selected.

beginLoadingChildItemsAtIndexPath looks like a good candidate but I have not been able to figure out how it works. The documentation says "Call this method to start asynchronous batch loading of media items". Sounds like they are saying we should call it, but pretty sure CarPlay should call this, as it has a completionHandler that we are supposed to call when done, right? I think this means if you are developing an external media player you should call it. So then how can we use it (as developers of media sources)?

Ideally I also want to be able to insert or add new media items as the user is listening. This is for an email app (Speaking Email) so new emails will arrive and I would like to slot them in after the currently playing item. Not sure this is possible so any guidance or clues about how this works are appreciated. I notice there is a dearth of information about CarPlay development on the internet.

I just found the reloadData method of MPPlayableContentManager which may be the best approach for this? Set all the items and then reload whenever I get new emails. Only problem is at the start when emails are not loaded. I could add a placeholder “loading…” item under each account and then when CarPlay calls the numberOfChildItemsAtIndexPath synchronous method, I would check the mail and then call reloadData to replace that placeholder.

0 Answers
Related